Wait until fully synced to process pubsub messages (#3514)

* context timeout for pubsub message processing

* add syncing check

* gofmt

* use a global cache

* lint

* fmt

* fix conflicts

* revert change

* gaz
This commit is contained in:
Preston Van Loon
2019-09-20 10:54:32 -07:00
committed by GitHub
parent c29a7be0ec
commit 9fcc6fc201
29 changed files with 413 additions and 162 deletions

View File

@@ -6,8 +6,8 @@ import (
"sort"
"time"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/sync/peerstatus"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/sirupsen/logrus"
@@ -33,7 +33,7 @@ func (r *RegularSync) processPendingBlocksQueue() {
// processes the block tree inside the queue
func (r *RegularSync) processPendingBlocks(ctx context.Context) error {
pids := r.peerIDs()
pids := peerstatus.Keys()
slots := r.sortedPendingSlots()
for _, s := range slots {
@@ -82,15 +82,6 @@ func (r *RegularSync) processPendingBlocks(ctx context.Context) error {
return nil
}
func (r *RegularSync) peerIDs() []peer.ID {
hellos := r.PeerStatuses()
pids := make([]peer.ID, 0, len(hellos))
for pid := range hellos {
pids = append(pids, pid)
}
return pids
}
func (r *RegularSync) sortedPendingSlots() []int {
r.pendingQueueLock.RLock()
defer r.pendingQueueLock.RUnlock()