Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
fix(block-service): return errors for addBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Apr 22, 2016
1 parent d3e6baf commit 0fea48d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/block-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@ const async = require('async')
function BlockService (ipfsRepo, exchange) {
this.addBlock = (block, callback) => {
const ws = ipfsRepo.datastore.createWriteStream(block.key, block.extension)

let done = false

ws.write(block.data)
ws.once('finish', callback)
ws.once('error', (err) => {
done = true
callback(err)
})
ws.once('finish', () => {
if (!done) callback()
})
ws.end()
}

Expand Down

0 comments on commit 0fea48d

Please sign in to comment.