From fdf4423c8b2e91a616072be29f84b2092610f43a Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 14 Jul 2015 11:11:16 -0700 Subject: [PATCH] fix race introduced in bitswap License: MIT Signed-off-by: Jeromy --- exchange/bitswap/bitswap.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exchange/bitswap/bitswap.go b/exchange/bitswap/bitswap.go index 75c347fd0..5234aefc9 100644 --- a/exchange/bitswap/bitswap.go +++ b/exchange/bitswap/bitswap.go @@ -228,14 +228,14 @@ func (bs *Bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error { default: } - bs.notifications.Publish(blk) - err := bs.tryPutBlock(blk, 4) // attempt to store block up to four times if err != nil { log.Errorf("Error writing block to datastore: %s", err) return err } + bs.notifications.Publish(blk) + select { case bs.newBlocks <- blk: // send block off to be reprovided