Commit ed0f4edf authored by Steven Allen's avatar Steven Allen

fix: set the score ledger on start

It's possible to start receiving and processing messages before we get around to starting.
parent 7525baeb
...@@ -178,6 +178,10 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger, ...@@ -178,6 +178,10 @@ func NewEngine(ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger,
func newEngine(ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger, self peer.ID, func newEngine(ctx context.Context, bs bstore.Blockstore, peerTagger PeerTagger, self peer.ID,
maxReplaceSize int, scoreLedger ScoreLedger) *Engine { maxReplaceSize int, scoreLedger ScoreLedger) *Engine {
if scoreLedger == nil {
scoreLedger = NewDefaultScoreLedger()
}
e := &Engine{ e := &Engine{
ledgerMap: make(map[peer.ID]*ledger), ledgerMap: make(map[peer.ID]*ledger),
scoreLedger: scoreLedger, scoreLedger: scoreLedger,
...@@ -221,9 +225,6 @@ func (e *Engine) UseScoreLedger(scoreLedger ScoreLedger) { ...@@ -221,9 +225,6 @@ func (e *Engine) UseScoreLedger(scoreLedger ScoreLedger) {
// if it is unset, initializes the scoreLedger with the default // if it is unset, initializes the scoreLedger with the default
// implementation. // implementation.
func (e *Engine) startScoreLedger(px process.Process) { func (e *Engine) startScoreLedger(px process.Process) {
if e.scoreLedger == nil {
e.scoreLedger = NewDefaultScoreLedger()
}
e.scoreLedger.Start(func(p peer.ID, score int) { e.scoreLedger.Start(func(p peer.ID, score int) {
if score == 0 { if score == 0 {
e.peerTagger.UntagPeer(p, e.tagUseful) e.peerTagger.UntagPeer(p, e.tagUseful)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment