diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-24 17:39:17 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-24 17:39:17 +0800 |
commit | 57dc435f9b928f5de2a49736a2c71a7bf611289a (patch) | |
tree | 9d6981298eef522382b8c549f190b7204d0dd494 /ethereum.go | |
parent | 615d20598ababa5988d5b36a48640c154d8866fd (diff) | |
download | dexon-57dc435f9b928f5de2a49736a2c71a7bf611289a.tar dexon-57dc435f9b928f5de2a49736a2c71a7bf611289a.tar.gz dexon-57dc435f9b928f5de2a49736a2c71a7bf611289a.tar.bz2 dexon-57dc435f9b928f5de2a49736a2c71a7bf611289a.tar.lz dexon-57dc435f9b928f5de2a49736a2c71a7bf611289a.tar.xz dexon-57dc435f9b928f5de2a49736a2c71a7bf611289a.tar.zst dexon-57dc435f9b928f5de2a49736a2c71a7bf611289a.zip |
Added TD for each block
Diffstat (limited to 'ethereum.go')
-rw-r--r-- | ethereum.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ethereum.go b/ethereum.go index 79e722c26..09665336c 100644 --- a/ethereum.go +++ b/ethereum.go @@ -4,6 +4,7 @@ import ( "container/list" "encoding/json" "fmt" + "math/big" "math/rand" "net" "path" @@ -188,6 +189,18 @@ func (s *Ethereum) IsListening() bool { return s.listening } +func (s *Ethereum) HighestTDPeer() (td *big.Int) { + td = big.NewInt(0) + + eachPeer(s.peers, func(p *Peer, v *list.Element) { + if p.td.Cmp(td) > 0 { + td = p.td + } + }) + + return +} + func (s *Ethereum) AddPeer(conn net.Conn) { peer := NewPeer(conn, s, true) @@ -370,6 +383,7 @@ func (s *Ethereum) ReapDeadPeerHandler() { // Start the ethereum func (s *Ethereum) Start(seed bool) { s.reactor.Start() + s.blockPool.Start() // Bind to addr and port ln, err := net.Listen("tcp", ":"+s.Port) if err != nil { |