Add lotus net scores for pubsub score visibility

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera
2020-06-03 03:13:49 +02:00
parent 4a983995a8
commit 186fd4da74
8 changed files with 85 additions and 2 deletions
+24
View File
@@ -0,0 +1,24 @@
package dtypes
import (
"sync"
peer "github.com/libp2p/go-libp2p-peer"
)
type ScoreKeeper struct {
lk sync.Mutex
scores map[peer.ID]float64
}
func (sk *ScoreKeeper) Update(scores map[peer.ID]float64) {
sk.lk.Lock()
sk.scores = scores
sk.lk.Unlock()
}
func (sk *ScoreKeeper) Get() map[peer.ID]float64 {
sk.lk.Lock()
defer sk.lk.Unlock()
return sk.scores
}