mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-04 05:43:06 +00:00
mesh tracking
This commit is contained in:
parent
535c04481e
commit
283593fbc0
32
score.go
32
score.go
@ -306,11 +306,39 @@ func (ps *peerScore) Join(topic string) {}
|
|||||||
func (ps *peerScore) Leave(topic string) {}
|
func (ps *peerScore) Leave(topic string) {}
|
||||||
|
|
||||||
func (ps *peerScore) Graft(p peer.ID, topic string) {
|
func (ps *peerScore) Graft(p peer.ID, topic string) {
|
||||||
// TODO
|
ps.Lock()
|
||||||
|
defer ps.Unlock()
|
||||||
|
|
||||||
|
pstats, ok := ps.peerStats[p]
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tstats, ok := pstats.getTopicStats(topic, ps.params)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tstats.inMesh = true
|
||||||
|
tstats.graftTime = time.Now()
|
||||||
|
tstats.meshTime = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *peerScore) Prune(p peer.ID, topic string) {
|
func (ps *peerScore) Prune(p peer.ID, topic string) {
|
||||||
// TODO
|
ps.Lock()
|
||||||
|
defer ps.Unlock()
|
||||||
|
|
||||||
|
pstats, ok := ps.peerStats[p]
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tstats, ok := pstats.getTopicStats(topic, ps.params)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tstats.inMesh = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *peerScore) DeliverMessage(msg *Message) {
|
func (ps *peerScore) DeliverMessage(msg *Message) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user