Skip to content

Commit

Permalink
chore(jsrt): move ContentHandle into fleek namespace, read method doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ozwaldorf committed May 29, 2024
1 parent 6137fcc commit 457a8c5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions services/js-poc/src/runtime/js/fleek.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const query_client_bandwidth_balance = async (account) => {
* @property {Uint8Array} proof - Blake3 proof of the content
* @property {number} length - Number of blocks in the content
*/
export class ContentHandle {
class ContentHandle {
proof;
length;

Expand All @@ -54,12 +54,21 @@ export class ContentHandle {
this.length = ((num_hashes + 1) >> 1) | 0;
}

read(id) {
return ops.read_block(this.proof, id);
/**
* Read a given block index from the blockstore
* @param {number} idx - Index of block to read
* @returns {Promise<Uint8Array>}
*/
read(idx) {
return ops.read_block(this.proof, idx);
}
}

/**
* Fleek API namespace
*/
export const Fleek = {
ContentHandle,
fetch_blake3,
load_content,
query_client_flk_balance,
Expand Down

0 comments on commit 457a8c5

Please sign in to comment.