Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Fix async call to get and put promises #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ async function read (ipfs, cid, options = {}) {
const codec = codecCodes[cid.code]
if (!codec) throw unsupportedCodecError()

const bytes = await ipfs.block.get(cid, { timeout: options.timeout })
const get = (await ipfs).block.get
const bytes = await get(cid, { timeout: options.timeout })
const block = await Block.decode({ bytes, codec, hasher })

if (block.cid.code === dagPb.code) {
Expand Down Expand Up @@ -95,7 +96,8 @@ async function write (ipfs, format, value, options = {}) {
}

const block = await Block.encode({ value, codec, hasher })
await ipfs.block.put(block.bytes, {
const put = (await ipfs).block.put
await put(block.bytes, {
cid: block.cid.bytes,
version: block.cid.version,
format,
Expand Down