fix common.Hash conversion

pull/532/head
zelig 10 years ago
parent 8987750a36
commit d7564a9a25
  1. 2
      blockpool/peers.go
  2. 4
      blockpool/peers_test.go
  3. 2
      blockpool/section.go

@ -7,6 +7,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/errs" "github.com/ethereum/go-ethereum/errs"
) )
@ -471,6 +472,7 @@ func (self *peer) getBlockHashes() {
} }
} }
headKey := self.parentHash.Str() headKey := self.parentHash.Str()
height := self.bp.status.chain[headKey] + 1
self.bp.status.chain[self.currentBlockHash.Str()] = height self.bp.status.chain[self.currentBlockHash.Str()] = height
if height > self.bp.status.values.LongestChain { if height > self.bp.status.values.LongestChain {
self.bp.status.values.LongestChain = height self.bp.status.values.LongestChain = height

@ -170,8 +170,8 @@ func TestPeerPromotionByOptionalTdOnBlock(t *testing.T) {
hashes := blockPoolTester.hashPool.IndexesToHashes([]int{2, 3}) hashes := blockPoolTester.hashPool.IndexesToHashes([]int{2, 3})
peer1.waitBlocksRequests(3) peer1.waitBlocksRequests(3)
blockPool.AddBlock(&types.Block{ blockPool.AddBlock(&types.Block{
HeaderHash: common.Bytes(hashes[1]), HeaderHash: common.Hash(hashes[1]),
ParentHeaderHash: common.Bytes(hashes[0]), ParentHeaderHash: common.Hash(hashes[0]),
Td: common.Big3, Td: common.Big3,
}, "peer1") }, "peer1")

@ -117,7 +117,7 @@ func (self *section) addSectionToBlockChain(p *peer) {
break break
} }
self.poolRootIndex-- self.poolRootIndex--
keys = append(keys, node.hash.Str()) keys = append(keys, n.hash.Str())
blocks = append(blocks, block) blocks = append(blocks, block)
nodes = append(nodes, n) nodes = append(nodes, n)
} }

Loading…
Cancel
Save