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

Commit

Permalink
Merge pull request #488 from Jorropo/fix/nildereferance-if-using-SetS…
Browse files Browse the repository at this point in the history
…endDontHave-option

fix: Nil dereference while using SetSendDontHaves
  • Loading branch information
Stebalien authored Jun 24, 2021
2 parents eac35a4 + 3f031b4 commit f2385cb
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit f2385cb

Please sign in to comment.