Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't Log Old Peers #2487

Merged
merged 2 commits into from
May 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions beacon-chain/sync/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Querier struct {
chainStarted bool
atGenesis bool
bestPeer peer.ID
peerMap map[peer.ID]uint64
}

// NewQuerierService constructs a new Sync Querier Service.
Expand All @@ -81,6 +82,7 @@ func NewQuerierService(ctx context.Context,
chainStarted: false,
powchain: cfg.PowChain,
chainStartBuf: make(chan time.Time, 1),
peerMap: make(map[peer.ID]uint64),
}
}

Expand Down Expand Up @@ -181,12 +183,14 @@ func (q *Querier) run() {
hasReceivedResponse = true
}
response := msg.Data.(*pb.ChainHeadResponse)
queryLog.WithFields(logrus.Fields{
"peerID": msg.Peer.Pretty(),
"highestSlot": response.CanonicalSlot - params.BeaconConfig().GenesisSlot,
}).Info("Received chain head from peer")
if _, ok := q.peerMap[msg.Peer]; !ok {
queryLog.WithFields(logrus.Fields{
"peerID": msg.Peer.Pretty(),
"highestSlot": response.CanonicalSlot - params.BeaconConfig().GenesisSlot,
}).Info("Received chain head from peer")
q.peerMap[msg.Peer] = response.CanonicalSlot
}
if response.CanonicalSlot > q.currentHeadSlot {
q.currentHeadSlot = response.CanonicalSlot
q.bestPeer = msg.Peer
q.currentHeadSlot = response.CanonicalSlot
q.currentStateRoot = response.CanonicalStateRootHash32
Expand Down