aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-24 20:38:16 +0800
committerobscuren <geffobscura@gmail.com>2015-03-24 20:38:16 +0800
commit0ec171ccdfb7514605e7fe16889b4f79904faf76 (patch)
tree484cf2f8e09952c417a7501dc62cd4e100aecc9c
parenteab8f7355de56a6a9128b283c560d00e85c000c4 (diff)
downloadgo-tangerine-0ec171ccdfb7514605e7fe16889b4f79904faf76.tar
go-tangerine-0ec171ccdfb7514605e7fe16889b4f79904faf76.tar.gz
go-tangerine-0ec171ccdfb7514605e7fe16889b4f79904faf76.tar.bz2
go-tangerine-0ec171ccdfb7514605e7fe16889b4f79904faf76.tar.lz
go-tangerine-0ec171ccdfb7514605e7fe16889b4f79904faf76.tar.xz
go-tangerine-0ec171ccdfb7514605e7fe16889b4f79904faf76.tar.zst
go-tangerine-0ec171ccdfb7514605e7fe16889b4f79904faf76.zip
Copy fix
-rw-r--r--core/chain_manager.go2
-rw-r--r--core/types/block.go11
2 files changed, 10 insertions, 3 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index f0d3fd4cf..6e8f7b4fe 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -399,7 +399,7 @@ func (self *ChainManager) GetAncestors(block *types.Block, length int) (blocks [
func (bc *ChainManager) setTotalDifficulty(td *big.Int) {
bc.blockDb.Put([]byte("LTD"), td.Bytes())
- bc.td = td
+ bc.td.Set(td)
}
func (self *ChainManager) CalcTotalDiff(block *types.Block) (*big.Int, error) {
diff --git a/core/types/block.go b/core/types/block.go
index cf2a7080e..5cdde4462 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -131,9 +131,12 @@ func NewBlock(parentHash common.Hash, coinbase common.Address, root common.Hash,
Extra: extra,
GasUsed: new(big.Int),
GasLimit: new(big.Int),
+ Number: new(big.Int),
}
header.SetNonce(nonce)
block := &Block{header: header}
+ block.Td = new(big.Int)
+
return block
}
@@ -302,7 +305,7 @@ func (self *Block) ParentHash() common.Hash {
}
func (self *Block) Copy() *Block {
- block := NewBlock(self.ParentHash(), self.Coinbase(), self.Root(), self.Difficulty(), self.Nonce(), self.header.Extra)
+ block := NewBlock(self.header.ParentHash, self.Coinbase(), self.Root(), new(big.Int), self.Nonce(), self.header.Extra)
block.header.Bloom = self.header.Bloom
block.header.TxHash = self.header.TxHash
block.transactions = self.transactions
@@ -312,9 +315,13 @@ func (self *Block) Copy() *Block {
block.header.GasUsed.Set(self.header.GasUsed)
block.header.ReceiptHash = self.header.ReceiptHash
block.header.Difficulty.Set(self.header.Difficulty)
- block.header.Number = self.header.Number
+ block.header.Number.Set(self.header.Number)
block.header.Time = self.header.Time
block.header.MixDigest = self.header.MixDigest
+ if self.Td != nil {
+ block.Td.Set(self.Td)
+ }
+
return block
}