plog.DebugDetailf("HeadSection: <%s> (head: %s) head section received [%s]-[%s]",self.id,hex(self.currentBlockHash),sectionhex(self.headSection),sectionhex(sec))
plog.Debugf("HeadSection: <%s> section with head %s, idle: %v",self.id,hex(self.currentBlockHash),self.idle)
plog.Debugf("HeadSection: <%s> section with head %s, idle: %v",self.id,hex(self.currentBlockHash),self.idle)
// idle timer started when process goes idle
case<-self.idleC:
ifself.idle{
self.peerError(self.bp.peers.errors.New(ErrIdleTooLong,"timed out without providing new blocks...quitting",currentBlockHash))
self.bp.status.lock.Lock()
self.bp.status.badPeers[self.id]++
self.bp.status.lock.Unlock()
}
// signal from AddBlockHashes that head section for current best peer is created
// signal from AddBlockHashes that head section for current best peer is created
// 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)
// local var quit channel is linked to sections suicide channel so that
ifsec==nil{
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
quit=nil
}else{
}else{
quit=sec.suicideC
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
@ -514,7 +516,7 @@ LOOP:
// quitting on timeout
// quitting on timeout
case<-self.suicideC:
case<-self.suicideC:
self.peerError(self.bp.peers.errors.New(ErrInsufficientChainInfo,"timed out without providing block hashes or head block %x",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()
self.bp.status.badPeers[self.id]++
self.bp.status.badPeers[self.id]++
@ -537,6 +539,12 @@ LOOP:
// quit
// quit
case<-quit:
case<-quit:
self.peerError(self.bp.peers.errors.New(ErrIdleTooLong,"timed out without providing new blocks (td: %v, head: %s)...quitting",self.td,self.currentBlockHash))
self.bp.status.lock.Lock()
self.bp.status.badPeers[self.id]++
self.bp.status.lock.Unlock()
plog.Debugf("HeadSection: <%s> (headsection [%s]) quit channel closed : timed out without providing new blocks...quitting",self.id,sectionhex(self.headSection))