diff options
Diffstat (limited to 'core/types/block.go')
-rw-r--r-- | core/types/block.go | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/core/types/block.go b/core/types/block.go index d57de1311..673c72003 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -41,12 +41,29 @@ type Header struct { Extra string // Block Nonce for verification Nonce ethutil.Bytes + // Mix digest for quick checking to prevent DOS + MixDigest ethutil.Bytes + // SeedHash used for light client verification + SeedHash ethutil.Bytes } func (self *Header) rlpData(withNonce bool) []interface{} { - fields := []interface{}{self.ParentHash, self.UncleHash, self.Coinbase, self.Root, self.TxHash, self.ReceiptHash, self.Bloom, self.Difficulty, self.Number, self.GasLimit, self.GasUsed, self.Time, self.Extra} + fields := []interface{}{ + self.ParentHash, + self.UncleHash, + self.Coinbase, + self.Root, + self.TxHash, + self.ReceiptHash, + self.Bloom, + self.Difficulty, + self.Number, + self.GasLimit, + self.GasUsed, + self.Time, + self.Extra} if withNonce { - fields = append(fields, self.Nonce) + fields = append(fields, self.Nonce, self.MixDigest, self.SeedHash) } return fields @@ -176,6 +193,8 @@ func (self *Block) RlpDataForStorage() interface{} { // Header accessors (add as you need them) 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) Bloom() []byte { return self.header.Bloom } func (self *Block) Coinbase() []byte { return self.header.Coinbase } @@ -200,7 +219,6 @@ func (self *Block) GetUncle(i int) *Header { // Implement pow.Block func (self *Block) Difficulty() *big.Int { return self.header.Difficulty } -func (self *Block) N() []byte { return self.header.Nonce } func (self *Block) HashNoNonce() []byte { return self.header.HashNoNonce() } func (self *Block) Hash() []byte { @@ -250,7 +268,10 @@ func (self *Header) String() string { Time: %v Extra: %v Nonce: %x -`, self.ParentHash, self.UncleHash, self.Coinbase, self.Root, self.TxHash, self.ReceiptHash, self.Bloom, self.Difficulty, self.Number, self.GasLimit, self.GasUsed, self.Time, self.Extra, self.Nonce) + MixDigest: %x + SeedHash: %x + +`, self.ParentHash, self.UncleHash, self.Coinbase, self.Root, self.TxHash, self.ReceiptHash, self.Bloom, self.Difficulty, self.Number, self.GasLimit, self.GasUsed, self.Time, self.Extra, self.Nonce, self.MixDigest, self.SeedHash) } type Blocks []*Block |