Commit 3ac74b1e authored by Maran's avatar Maran

Implemented IsUpToDate to mark the node as ready to start mining

parent 0512113b
...@@ -138,6 +138,18 @@ func (s *Ethereum) IsMining() bool { ...@@ -138,6 +138,18 @@ func (s *Ethereum) IsMining() bool {
func (s *Ethereum) PeerCount() int { func (s *Ethereum) PeerCount() int {
return s.peers.Len() return s.peers.Len()
} }
func (s *Ethereum) IsUpToDate() bool {
upToDate := true
eachPeer(s.peers, func(peer *Peer, e *list.Element) {
if atomic.LoadInt32(&peer.connected) == 1 {
if peer.catchingUp == true {
upToDate = false
}
}
})
return upToDate
}
func (s *Ethereum) IsListening() bool { func (s *Ethereum) IsListening() bool {
return s.listening return s.listening
} }
......
...@@ -389,6 +389,8 @@ func (p *Peer) HandleInbound() { ...@@ -389,6 +389,8 @@ func (p *Peer) HandleInbound() {
p.CatchupWithPeer(p.ethereum.BlockChain().CurrentBlock.Hash()) p.CatchupWithPeer(p.ethereum.BlockChain().CurrentBlock.Hash())
} }
} }
p.catchingUp = false
case ethwire.MsgTxTy: case ethwire.MsgTxTy:
// If the message was a transaction queue the transaction // If the message was a transaction queue the transaction
// in the TxPool where it will undergo validation and // in the TxPool where it will undergo validation and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment