diff --git a/internal/netsync/manager.go b/internal/netsync/manager.go index 7628766e..e89f8157 100644 --- a/internal/netsync/manager.go +++ b/internal/netsync/manager.go @@ -122,20 +122,6 @@ type requestFromPeerResponse struct { err error } -// tipGenerationResponse is a response sent to the reply channel of a -// tipGenerationMsg query. -type tipGenerationResponse struct { - hashes []chainhash.Hash - err error -} - -// tipGenerationMsg is a message type to be sent across the message -// channel for requesting the required the entire generation of a -// block node. -type tipGenerationMsg struct { - reply chan tipGenerationResponse -} - // processBlockResponse is a response sent to the reply channel of a // processBlockMsg. type processBlockResponse struct { @@ -1583,13 +1569,6 @@ out: err: err, } - case tipGenerationMsg: - g, err := m.cfg.Chain.TipGeneration() - msg.reply <- tipGenerationResponse{ - hashes: g, - err: err, - } - case processBlockMsg: forkLen, isOrphan, err := m.processBlockAndOrphans(msg.block, msg.flags) @@ -1837,16 +1816,6 @@ func (m *SyncManager) requestFromPeer(p *peerpkg.Peer, blocks, txs []*chainhash. return nil } -// TipGeneration returns the hashes of all the children of the current best -// chain tip. It is funneled through the sync manager since blockchain is not -// safe for concurrent access. -func (m *SyncManager) TipGeneration() ([]chainhash.Hash, error) { - reply := make(chan tipGenerationResponse) - m.msgChan <- tipGenerationMsg{reply: reply} - response := <-reply - return response.hashes, response.err -} - // ProcessBlock makes use of ProcessBlock on an internal instance of a block // chain. It is funneled through the sync manager since blockchain is not safe // for concurrent access. diff --git a/internal/rpcserver/interface.go b/internal/rpcserver/interface.go index 33b6c9f2..dc00e7e5 100644 --- a/internal/rpcserver/interface.go +++ b/internal/rpcserver/interface.go @@ -158,10 +158,6 @@ type SyncManager interface { LocateBlocks(locator blockchain.BlockLocator, hashStop *chainhash.Hash, maxHashes uint32) []chainhash.Hash - // TipGeneration returns the entire generation of blocks stemming from the - // parent of the current tip. - TipGeneration() ([]chainhash.Hash, error) - // SyncHeight returns latest known block being synced to. SyncHeight() int64 diff --git a/internal/rpcserver/rpcserverhandlers_test.go b/internal/rpcserver/rpcserverhandlers_test.go index d7c2e7ac..9b056e5f 100644 --- a/internal/rpcserver/rpcserverhandlers_test.go +++ b/internal/rpcserver/rpcserverhandlers_test.go @@ -494,7 +494,6 @@ type testSyncManager struct { submitBlockErr error syncPeerID int32 locateBlocks []chainhash.Hash - tipGeneration []chainhash.Hash syncHeight int64 processTransaction []*dcrutil.Tx processTransactionErr error @@ -524,12 +523,6 @@ func (s *testSyncManager) LocateBlocks(locator blockchain.BlockLocator, hashStop return s.locateBlocks } -// TipGeneration returns a mocked entire generation of blocks stemming from the -// parent of the current tip. -func (s *testSyncManager) TipGeneration() ([]chainhash.Hash, error) { - return s.tipGeneration, nil -} - // SyncHeight returns a mocked latest known block being synced to. func (s *testSyncManager) SyncHeight() int64 { return s.syncHeight diff --git a/rpcadaptors.go b/rpcadaptors.go index 87add513..55b25c6f 100644 --- a/rpcadaptors.go +++ b/rpcadaptors.go @@ -353,12 +353,6 @@ func (b *rpcSyncMgr) LocateBlocks(locator blockchain.BlockLocator, hashStop *cha return b.server.chain.LocateBlocks(locator, hashStop, maxHashes) } -// TipGeneration returns the entire generation of blocks stemming from the -// parent of the current tip. -func (b *rpcSyncMgr) TipGeneration() ([]chainhash.Hash, error) { - return b.syncMgr.TipGeneration() -} - // SyncHeight returns latest known block being synced to. func (b *rpcSyncMgr) SyncHeight() int64 { return b.syncMgr.SyncHeight() diff --git a/server.go b/server.go index e363431e..1edb380d 100644 --- a/server.go +++ b/server.go @@ -819,8 +819,7 @@ func (sp *serverPeer) OnGetMiningState(p *peer.Peer, msg *wire.MsgGetMiningState // Obtain the entire generation of blocks stemming from the parent of // the current tip. - sm := sp.server.syncManager - children, err := sm.TipGeneration() + children, err := sp.server.chain.TipGeneration() if err != nil { peerLog.Warnf("failed to access sync manager to get the generation "+ "for a mining state request (block: %v): %v", best.Hash, err) @@ -909,8 +908,7 @@ func (sp *serverPeer) OnGetInitState(p *peer.Peer, msg *wire.MsgGetInitState) { if wantBlocks || wantVotes { // Obtain the entire generation of blocks stemming from the // parent of the current tip. - sm := sp.server.syncManager - children, err := sm.TipGeneration() + children, err := sp.server.chain.TipGeneration() if err != nil { peerLog.Warnf("Failed to access sync manager to get the generation "+ "for a init state request (block: %v): %v", best.Hash, err)