diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-04 04:04:31 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-04 04:04:31 +0800 |
commit | 26de12d9bf23bce7de26b3b6629601ec2e58ad5b (patch) | |
tree | 0d4b76fcb717049d988b7f283967f43dc5517a5e /core | |
parent | e9f1e868e2bc0205d0b7655cd07fcaba9b2bc97d (diff) | |
download | dexon-26de12d9bf23bce7de26b3b6629601ec2e58ad5b.tar dexon-26de12d9bf23bce7de26b3b6629601ec2e58ad5b.tar.gz dexon-26de12d9bf23bce7de26b3b6629601ec2e58ad5b.tar.bz2 dexon-26de12d9bf23bce7de26b3b6629601ec2e58ad5b.tar.lz dexon-26de12d9bf23bce7de26b3b6629601ec2e58ad5b.tar.xz dexon-26de12d9bf23bce7de26b3b6629601ec2e58ad5b.tar.zst dexon-26de12d9bf23bce7de26b3b6629601ec2e58ad5b.zip |
Changed nonce to a uint64
Diffstat (limited to 'core')
-rw-r--r-- | core/block_processor.go | 4 | ||||
-rw-r--r-- | core/chain_makers.go | 6 | ||||
-rw-r--r-- | core/chain_manager.go | 2 | ||||
-rw-r--r-- | core/genesis.go | 2 | ||||
-rw-r--r-- | core/types/block.go | 10 |
5 files changed, 12 insertions, 12 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index 8974cd94b..a6632fca7 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -277,7 +277,7 @@ func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error { // Verify the nonce of the block. Return an error if it's not valid if !sm.Pow.Verify(block) { - return ValidationError("Block's nonce is invalid (= %v)", ethutil.Bytes2Hex(block.Header().Nonce)) + return ValidationError("Block's nonce is invalid (= %x)", block.Header().Nonce) } return nil @@ -305,7 +305,7 @@ func (sm *BlockProcessor) AccumulateRewards(statedb *state.StateDB, block, paren } if !sm.Pow.Verify(types.NewBlockWithHeader(uncle)) { - return ValidationError("Uncle's nonce is invalid (= %v)", ethutil.Bytes2Hex(uncle.Nonce)) + return ValidationError("Uncle's nonce is invalid (= %x)", uncle.Nonce) } r := new(big.Int) diff --git a/core/chain_makers.go b/core/chain_makers.go index 7afdfde0d..3248975e1 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -14,8 +14,8 @@ import ( // So we can generate blocks easily type FakePow struct{} -func (f FakePow) Search(block pow.Block, stop <-chan struct{}) ([]byte, []byte, []byte) { - return nil, nil, nil +func (f FakePow) Search(block pow.Block, stop <-chan struct{}) (uint64, []byte, []byte) { + return 0, nil, nil } func (f FakePow) Verify(block pow.Block) bool { return true } func (f FakePow) GetHashrate() int64 { return 0 } @@ -55,7 +55,7 @@ func NewCanonical(n int, db ethutil.Database) (*BlockProcessor, error) { // block time is fixed at 10 seconds func newBlockFromParent(addr []byte, parent *types.Block) *types.Block { - block := types.NewBlock(parent.Hash(), addr, parent.Root(), ethutil.BigPow(2, 32), nil, "") + block := types.NewBlock(parent.Hash(), addr, parent.Root(), ethutil.BigPow(2, 32), 0, "") block.SetUncles(nil) block.SetTransactions(nil) block.SetReceipts(nil) diff --git a/core/chain_manager.go b/core/chain_manager.go index 13edeea95..6212fb842 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -197,7 +197,7 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block { coinbase, root, ethutil.BigPow(2, 32), - nil, + 0, "") block.SetUncles(nil) block.SetTransactions(nil) diff --git a/core/genesis.go b/core/genesis.go index decffc541..3e90aa91d 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -23,7 +23,7 @@ var EmptyShaList = crypto.Sha3(ethutil.Encode([]interface{}{})) var EmptyListRoot = crypto.Sha3(ethutil.Encode("")) func GenesisBlock(db ethutil.Database) *types.Block { - genesis := types.NewBlock(ZeroHash256, ZeroHash160, nil, big.NewInt(131072), crypto.Sha3(big.NewInt(42).Bytes()), "") + genesis := types.NewBlock(ZeroHash256, ZeroHash160, nil, big.NewInt(131072), 42, "") genesis.Header().Number = ethutil.Big0 genesis.Header().GasLimit = big.NewInt(1000000) genesis.Header().GasUsed = ethutil.Big0 diff --git a/core/types/block.go b/core/types/block.go index 673c72003..358d0bc2d 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -39,8 +39,8 @@ type Header struct { Time uint64 // Extra data Extra string - // Block Nonce for verification - Nonce ethutil.Bytes + // Nonce + Nonce uint64 // Mix digest for quick checking to prevent DOS MixDigest ethutil.Bytes // SeedHash used for light client verification @@ -94,7 +94,7 @@ type Block struct { Reward *big.Int } -func NewBlock(parentHash []byte, coinbase []byte, root []byte, difficulty *big.Int, nonce []byte, extra string) *Block { +func NewBlock(parentHash []byte, coinbase []byte, root []byte, difficulty *big.Int, nonce uint64, extra string) *Block { header := &Header{ Root: root, ParentHash: parentHash, @@ -195,7 +195,7 @@ func (self *Block) Number() *big.Int { return self.header.Number } func (self *Block) NumberU64() uint64 { return self.header.Number.Uint64() } func (self *Block) MixDigest() []byte { return self.header.MixDigest } func (self *Block) SeedHash() []byte { return self.header.SeedHash } -func (self *Block) Nonce() []byte { return self.header.Nonce } +func (self *Block) Nonce() uint64 { return self.header.Nonce } func (self *Block) Bloom() []byte { return self.header.Bloom } func (self *Block) Coinbase() []byte { return self.header.Coinbase } func (self *Block) Time() int64 { return int64(self.header.Time) } @@ -267,7 +267,7 @@ func (self *Header) String() string { GasUsed: %v Time: %v Extra: %v - Nonce: %x + Nonce: %d MixDigest: %x SeedHash: %x |