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

Commit ed0f4ed

Browse files
committed
fix: set the score ledger on start
It's possible to start receiving and processing messages before we get around to starting.
1 parent 7525bae commit ed0f4ed

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

internal/decision/engine.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger,
178178
func newEngine(ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger, self peer.ID,
179179
maxReplaceSize int, scoreLedger ScoreLedger) *Engine {
180180

181+
if scoreLedger == nil {
182+
scoreLedger = NewDefaultScoreLedger()
183+
}
184+
181185
e := &Engine{
182186
ledgerMap: make(map[peer.ID]*ledger),
183187
scoreLedger: scoreLedger,
@@ -221,9 +225,6 @@ func (e *Engine) UseScoreLedger(scoreLedger ScoreLedger) {
221225
// if it is unset, initializes the scoreLedger with the default
222226
// implementation.
223227
func (e *Engine) startScoreLedger(px process.Process) {
224-
if e.scoreLedger == nil {
225-
e.scoreLedger = NewDefaultScoreLedger()
226-
}
227228
e.scoreLedger.Start(func(p peer.ID, score int) {
228229
if score == 0 {
229230
e.peerTagger.UntagPeer(p, e.tagUseful)

0 commit comments

Comments
 (0)