1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 01:52:26 +08:00

publish block before writing to disk

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Jeromy
2015-07-13 11:24:49 -07:00
parent 7ef1a470c7
commit a25352d80e

View File

@ -228,13 +228,14 @@ func (bs *Bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
default: default:
} }
bs.notifications.Publish(blk)
err := bs.tryPutBlock(blk, 4) // attempt to store block up to four times err := bs.tryPutBlock(blk, 4) // attempt to store block up to four times
if err != nil { if err != nil {
log.Errorf("Error writing block to datastore: %s", err) log.Errorf("Error writing block to datastore: %s", err)
return err return err
} }
bs.notifications.Publish(blk)
select { select {
case bs.newBlocks <- blk: case bs.newBlocks <- blk:
// send block off to be reprovided // send block off to be reprovided