fix race introduced in bitswap
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
Jeromy committed
Jul 14, 2015 at 11:11 UTC
fdf4423c8b2e91a616072be29f84b2092610f43a
1 file changed
+2
-2
exchange/bitswap/bitswap.go
+2
-2
@@ -228,14 +228,14 @@ func (bs *Bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
228
default:
229
}
230
231
- bs.notifications.Publish(blk)
232
-
231
err := bs.tryPutBlock(blk, 4) // attempt to store block up to four times
232
if err != nil {
233
log.Errorf("Error writing block to datastore: %s", err)
234
return err
235
}
236
237
+ bs.notifications.Publish(blk)
238
+
239
select {
240
case bs.newBlocks <- blk:
241
// send block off to be reprovided