- fix status chain map uses common.Hash as key
- add badPeers increment to IncorrectTD errors (forgotten)
- signal head info update to head section process even if parent hash is not in pool (inserted), so that idle timer can be set to nil
- suicideC -> peer.headInfoTimer
- quit -> peer.bestIdleTimer
- and they are properly set from within getBlockHashes and handleSection
// if sec == nil, it signals that chain info has updated (new block message)
// if sec == nil, it signals that chain info has updated (new block message)
casesec:=<-self.headSectionC:
casesec:=<-self.headSectionC:
self.handleSection(sec)
self.handleSection(sec)
ifsec==nil{
plog.Debugf("HeadSection: <%s> (headsection [%s], received: [%s]) quit channel set to nil, catchup happening",self.id,sectionhex(self.headSection),sectionhex(sec))
quit=nil
}else{
plog.Debugf("HeadSection: <%s> (headsection [%s], received: [%s]) quit channel set to go off in IdleBestPeerTimeout",self.id,sectionhex(self.headSection),sectionhex(sec))
// periodic check for block hashes or parent block/section
// periodic check for block hashes or parent block/section
case<-self.blockHashesRequestTimer:
case<-self.blockHashesRequestTimer:
@ -560,7 +558,7 @@ LOOP:
self.getCurrentBlock(nil)
self.getCurrentBlock(nil)
// quitting on timeout
// quitting on timeout
case<-self.suicideC:
case<-self.headInfoTimer:
self.peerError(self.bp.peers.errors.New(ErrInsufficientChainInfo,"timed out without providing block hashes or head block (td: %v, head: %s)",self.td,hex(self.currentBlockHash)))
self.peerError(self.bp.peers.errors.New(ErrInsufficientChainInfo,"timed out without providing block hashes or head block (td: %v, head: %s)",self.td,hex(self.currentBlockHash)))
self.bp.status.lock.Lock()
self.bp.status.lock.Lock()
@ -583,7 +581,7 @@ LOOP:
breakLOOP
breakLOOP
// quit
// quit
case<-quit:
case<-self.bestIdleTimer:
self.peerError(self.bp.peers.errors.New(ErrIdleTooLong,"timed out without providing new blocks (td: %v, head: %s)...quitting",self.td,hex(self.currentBlockHash)))
self.peerError(self.bp.peers.errors.New(ErrIdleTooLong,"timed out without providing new blocks (td: %v, head: %s)...quitting",self.td,hex(self.currentBlockHash)))