mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
optimize section reactivation
This commit is contained in:
parent
1278173372
commit
89763b33a7
1 changed files with 9 additions and 4 deletions
|
|
@ -527,9 +527,11 @@ func (self *BlockPool) activateChain(section *section, peer *peerInfo) {
|
||||||
i := 0
|
i := 0
|
||||||
LOOP:
|
LOOP:
|
||||||
for section != nil {
|
for section != nil {
|
||||||
// register this section with the peer
|
// register this section with the peer and quit if registered
|
||||||
poolLogger.Debugf("[%s] register section with peer %s", sectionName(section), peer.id)
|
poolLogger.Debugf("[%s] register section with peer %s", sectionName(section), peer.id)
|
||||||
peer.addSection(section.top.hash, section)
|
if peer.addSection(section.top.hash, section) == section {
|
||||||
|
return
|
||||||
|
}
|
||||||
poolLogger.Debugf("[%s] activate section process", sectionName(section))
|
poolLogger.Debugf("[%s] activate section process", sectionName(section))
|
||||||
select {
|
select {
|
||||||
case section.controlC <- peer:
|
case section.controlC <- peer:
|
||||||
|
|
@ -947,11 +949,14 @@ func (self *BlockPool) getPeer(peerId string) (*peerInfo, bool) {
|
||||||
return info, false
|
return info, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *peerInfo) addSection(hash []byte, section *section) {
|
func (self *peerInfo) addSection(hash []byte, section *section) (found *section) {
|
||||||
self.lock.Lock()
|
self.lock.Lock()
|
||||||
defer self.lock.Unlock()
|
defer self.lock.Unlock()
|
||||||
|
key := string(hash)
|
||||||
|
found = self.sections[key]
|
||||||
poolLogger.Debugf("section process %s added to %s", sectionName(section), self.id)
|
poolLogger.Debugf("section process %s added to %s", sectionName(section), self.id)
|
||||||
self.sections[string(hash)] = section
|
self.sections[key] = section
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BlockPool) switchPeer(oldPeer, newPeer *peerInfo) {
|
func (self *BlockPool) switchPeer(oldPeer, newPeer *peerInfo) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue