Don't need the blockpeermutex anymore.
Really, it would be nice to pass an interface{} into chain to be given to us when the callback calls, it would avoid the awkward sidchanneling through the map and should actually be more efffieint (pointer passing > hashtable insert, lookup, then remove).
This commit is contained in:
parent
c1b327c06a
commit
2b56e7a397
1 changed files with 0 additions and 10 deletions
|
@ -66,7 +66,6 @@ type blockManager struct {
|
||||||
blockChain *btcchain.BlockChain
|
blockChain *btcchain.BlockChain
|
||||||
blockPeer map[btcwire.ShaHash]*peer
|
blockPeer map[btcwire.ShaHash]*peer
|
||||||
requestedBlocks map[btcwire.ShaHash]bool
|
requestedBlocks map[btcwire.ShaHash]bool
|
||||||
blockPeerMutex sync.Mutex
|
|
||||||
receivedLogBlocks int64
|
receivedLogBlocks int64
|
||||||
receivedLogTx int64
|
receivedLogTx int64
|
||||||
lastBlockLogTime time.Time
|
lastBlockLogTime time.Time
|
||||||
|
@ -224,9 +223,7 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
|
||||||
bmsg.peer.Disconnect()
|
bmsg.peer.Disconnect()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
b.blockPeerMutex.Lock()
|
|
||||||
b.blockPeer[*blockSha] = bmsg.peer
|
b.blockPeer[*blockSha] = bmsg.peer
|
||||||
b.blockPeerMutex.Unlock()
|
|
||||||
|
|
||||||
// Process the block to include validation, best chain selection, orphan
|
// Process the block to include validation, best chain selection, orphan
|
||||||
// handling, etc.
|
// handling, etc.
|
||||||
|
@ -239,9 +236,7 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
|
||||||
delete(b.requestedBlocks, *blockSha)
|
delete(b.requestedBlocks, *blockSha)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.blockPeerMutex.Lock()
|
|
||||||
delete(b.blockPeer, *blockSha)
|
delete(b.blockPeer, *blockSha)
|
||||||
b.blockPeerMutex.Unlock()
|
|
||||||
log.Warnf("[BMGR] Failed to process block %v: %v", blockSha, err)
|
log.Warnf("[BMGR] Failed to process block %v: %v", blockSha, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -249,9 +244,7 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
|
||||||
// Don't keep track of the peer that sent the block any longer if it's
|
// Don't keep track of the peer that sent the block any longer if it's
|
||||||
// not an orphan.
|
// not an orphan.
|
||||||
if !b.blockChain.IsKnownOrphan(blockSha) {
|
if !b.blockChain.IsKnownOrphan(blockSha) {
|
||||||
b.blockPeerMutex.Lock()
|
|
||||||
delete(b.blockPeer, *blockSha)
|
delete(b.blockPeer, *blockSha)
|
||||||
b.blockPeerMutex.Unlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log info about the new block height.
|
// Log info about the new block height.
|
||||||
|
@ -420,9 +413,6 @@ func (b *blockManager) handleNotifyMsg(notification *btcchain.Notification) {
|
||||||
// An orphan block has been accepted by the block chain. Request
|
// An orphan block has been accepted by the block chain. Request
|
||||||
// its parents from the peer that sent it.
|
// its parents from the peer that sent it.
|
||||||
case btcchain.NTOrphanBlock:
|
case btcchain.NTOrphanBlock:
|
||||||
b.blockPeerMutex.Lock()
|
|
||||||
defer b.blockPeerMutex.Unlock()
|
|
||||||
|
|
||||||
orphanHash := notification.Data.(*btcwire.ShaHash)
|
orphanHash := notification.Data.(*btcwire.ShaHash)
|
||||||
if peer, exists := b.blockPeer[*orphanHash]; exists {
|
if peer, exists := b.blockPeer[*orphanHash]; exists {
|
||||||
orphanRoot := b.blockChain.GetOrphanRoot(orphanHash)
|
orphanRoot := b.blockChain.GetOrphanRoot(orphanHash)
|
||||||
|
|
Loading…
Add table
Reference in a new issue