netsync: Remove unneeded TipGeneration.
This removes the TipGeneration method and infrastructure from the sync manager as it is no longer needed since the blockchain is safe for concurrent access.
This commit is contained in:
parent
8e1a062c11
commit
6681bc0b4d
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user