Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

fix: Nil dereference while using SetSendDontHaves #488

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func EngineBlockstoreWorkerCount(count int) Option {
// This option is only used for testing.
func SetSendDontHaves(send bool) Option {
return func(bs *Bitswap) {
bs.engine.SetSendDontHaves(send)
bs.engineSetSendDontHaves = send
}
}

Expand Down Expand Up @@ -210,6 +210,7 @@ func New(parent context.Context, network bsnet.BitSwapNetwork,
provSearchDelay: defaultProvSearchDelay,
rebroadcastDelay: delay.Fixed(time.Minute),
engineBstoreWorkerCount: defaulEngineBlockstoreWorkerCount,
engineSetSendDontHaves: true,
simulateDontHavesOnTimeout: true,
}

Expand All @@ -220,6 +221,7 @@ func New(parent context.Context, network bsnet.BitSwapNetwork,

// Set up decision engine
bs.engine = decision.NewEngine(bstore, bs.engineBstoreWorkerCount, network.ConnectionManager(), network.Self(), bs.engineScoreLedger)
bs.engine.SetSendDontHaves(bs.engineSetSendDontHaves)

bs.pqm.Startup()
network.SetDelegate(bs)
Expand Down Expand Up @@ -304,6 +306,11 @@ type Bitswap struct {
// the score ledger used by the decision engine
engineScoreLedger deciface.ScoreLedger

// indicates what to do when the engine receives a want-block for a block that
// is not in the blockstore. Either send DONT_HAVE or do nothing.
// This is used to simulate older versions of bitswap that did nothing instead of sending back a DONT_HAVE.
engineSetSendDontHaves bool

// whether we should actually simulate dont haves on request timeout
simulateDontHavesOnTimeout bool
}
Expand Down