From 629b76cf4413151c0997030b917a1b50456f048d Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Thu, 2 May 2019 14:36:23 -0500 Subject: [PATCH] Only Perform Initial Sync With a Single Peer (#2471) * fix spacing * use send instead of broadcast in initial sync --- beacon-chain/sync/initial-sync/service.go | 1 - beacon-chain/sync/initial-sync/sync_blocks.go | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/beacon-chain/sync/initial-sync/service.go b/beacon-chain/sync/initial-sync/service.go index 9c7e14648..c27f1b4cc 100644 --- a/beacon-chain/sync/initial-sync/service.go +++ b/beacon-chain/sync/initial-sync/service.go @@ -63,7 +63,6 @@ func DefaultConfig() *Config { } type p2pAPI interface { - p2p.Broadcaster p2p.Sender Subscribe(msg proto.Message, channel chan p2p.Message) event.Subscription } diff --git a/beacon-chain/sync/initial-sync/sync_blocks.go b/beacon-chain/sync/initial-sync/sync_blocks.go index c50bdeffe..23e47de96 100644 --- a/beacon-chain/sync/initial-sync/sync_blocks.go +++ b/beacon-chain/sync/initial-sync/sync_blocks.go @@ -117,10 +117,12 @@ func (s *InitialSync) requestBatchedBlocks(startSlot uint64, endSlot uint64) { "slotSlot": startSlot - params.BeaconConfig().GenesisSlot, "endSlot": endSlot - params.BeaconConfig().GenesisSlot}, ).Debug("Requesting batched blocks") - s.p2p.Broadcast(ctx, &pb.BatchedBeaconBlockRequest{ + if err := s.p2p.Send(ctx, &pb.BatchedBeaconBlockRequest{ StartSlot: startSlot, EndSlot: endSlot, - }) + }, s.bestPeer); err != nil { + log.Errorf("Could not send batch block request to peer %s: %v", s.bestPeer.Pretty(), err) + } } // validateAndSaveNextBlock will validate whether blocks received from the blockfetcher