From 3ac74b1e7840720e8ae426c751328ed7595188a8 Mon Sep 17 00:00:00 2001 From: Maran Date: Wed, 14 May 2014 13:57:04 +0200 Subject: Implemented IsUpToDate to mark the node as ready to start mining --- ethereum.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'ethereum.go') diff --git a/ethereum.go b/ethereum.go index 94e338c56..83a74f302 100644 --- a/ethereum.go +++ b/ethereum.go @@ -138,6 +138,18 @@ func (s *Ethereum) IsMining() bool { func (s *Ethereum) PeerCount() int { 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 { return s.listening } -- cgit v1.2.3