Sample code for block api
travisperson opened this issue · comments
repo.blocks.read('12200007d4e3a319cd8c7c9979280e150fc5dbaae1ce54e790f84ae5fd3c3c1a0475', function (buff, err) {
console.log(err)
})
While this basically works as intended (to print out the data of the block), the variable names are confusing and probably should be switched.
repo.blocks.write(buff, function (buff, err) {
console.log(buff.toString('utf-8'), err)
})
We are following the Node.js pattern of "err first, results last" with (err, res). Not sure if I understand why that is particularly confusing.
Btw, this js-ipfs-repo is in flux still :) We now have locks
and version
working following the new structured presented at #9 (comment)
Got what you were saying, fixed the README :)