-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Version information:
current
Description:
Calling AddBlock or AddBlocks on the block service appears to write to the data store twice. The reason is that the blockservice calls Put here:
https://github.com/ipfs/go-blockservice/blob/master/blockservice.go#L146
And then calls exchange.HasBlock here:
https://github.com/ipfs/go-blockservice/blob/master/blockservice.go#L153
HasBlock eventually calls PutMany here:
https://github.com/ipfs/go-bitswap/blob/master/bitswap.go#L372
I produces a test to repro the issue (it's pretty ugly but should demonstrate that I'm not just reading it wrong): https://github.com/ipfs/go-blockservice/blob/test/prove_double_write/test/blocks_test.go#L108
I believe you could fix it by changing https://github.com/ipfs/go-bitswap/blob/master/bitswap.go#L371 from:
if len(wanted) > 0 {to
if len(wanted) > 0 && from != "" {but I dunno what side effects that might cause.
I just was reading through the code trying to figure some stuff out about designing new ipld-prime interfaces and I saw that. I dunno what the penalty is for double writing but when adding a big DAG I can imagine it might be large.