diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2017-04-06 16:38:21 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-04-06 16:38:21 +0800 |
commit | 3d8de95f999de6f52f0c1605eb2913278f1d87d2 (patch) | |
tree | 1906f5ec11dbbd304bb30f3e75c117727a4d1e79 /core/types | |
parent | 24b9860c1bc214d2db943bc69117818311406bdb (diff) | |
download | dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.gz dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.bz2 dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.lz dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.xz dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.tar.zst dexon-3d8de95f999de6f52f0c1605eb2913278f1d87d2.zip |
core, core/types: regenerate JSON marshaling, add "hash" to headers (#13868)
* Makefile: fix devtools target
* core: regenerate genesis marshaling with fjl/gencodec@cbfa5be5a8a8
* core/types: regenerate marshaling methods with fjl/gencodec@cbfa5be5a8a8
* core/types: add "hash" to JSON headers
Diffstat (limited to 'core/types')
-rw-r--r-- | core/types/block.go | 31 | ||||
-rw-r--r-- | core/types/gen_header_json.go | 106 | ||||
-rw-r--r-- | core/types/gen_log_json.go | 64 | ||||
-rw-r--r-- | core/types/gen_receipt_json.go | 52 | ||||
-rw-r--r-- | core/types/gen_tx_json.go | 70 | ||||
-rw-r--r-- | core/types/log.go | 18 | ||||
-rw-r--r-- | core/types/receipt.go | 14 | ||||
-rw-r--r-- | core/types/transaction.go | 20 |
8 files changed, 185 insertions, 190 deletions
diff --git a/core/types/block.go b/core/types/block.go index 278594d50..8ca3d0e89 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -68,21 +68,21 @@ func (n *BlockNonce) UnmarshalText(input []byte) error { // Header represents a block header in the Ethereum blockchain. type Header struct { - ParentHash common.Hash `json:"parentHash"` - UncleHash common.Hash `json:"sha3Uncles"` - Coinbase common.Address `json:"miner"` - Root common.Hash `json:"stateRoot"` - TxHash common.Hash `json:"transactionsRoot"` - ReceiptHash common.Hash `json:"receiptsRoot"` - Bloom Bloom `json:"logsBloom"` - Difficulty *big.Int `json:"difficulty"` - Number *big.Int `json:"number"` - GasLimit *big.Int `json:"gasLimit"` - GasUsed *big.Int `json:"gasUsed"` - Time *big.Int `json:"timestamp"` - Extra []byte `json:"extraData"` - MixDigest common.Hash `json:"mixHash"` - Nonce BlockNonce `json:"nonce"` + ParentHash common.Hash `json:"parentHash" gencodec:"required"` + UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` + Coinbase common.Address `json:"miner" gencodec:"required"` + Root common.Hash `json:"stateRoot" gencodec:"required"` + TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` + ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` + Bloom Bloom `json:"logsBloom" gencodec:"required"` + Difficulty *big.Int `json:"difficulty" gencodec:"required"` + Number *big.Int `json:"number" gencodec:"required"` + GasLimit *big.Int `json:"gasLimit" gencodec:"required"` + GasUsed *big.Int `json:"gasUsed" gencodec:"required"` + Time *big.Int `json:"timestamp" gencodec:"required"` + Extra []byte `json:"extraData" gencodec:"required"` + MixDigest common.Hash `json:"mixHash" gencodec:"required"` + Nonce BlockNonce `json:"nonce" gencodec:"required"` } // field type overrides for gencodec @@ -93,6 +93,7 @@ type headerMarshaling struct { GasUsed *hexutil.Big Time *hexutil.Big Extra hexutil.Bytes + Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON } // Hash returns the block hash of the header, which is simply the keccak256 hash of its diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index 91663d9d8..bcff7a940 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -12,24 +12,25 @@ import ( ) func (h Header) MarshalJSON() ([]byte, error) { - type HeaderJSON struct { - ParentHash common.Hash `json:"parentHash"` - UncleHash common.Hash `json:"sha3Uncles"` - Coinbase common.Address `json:"miner"` - Root common.Hash `json:"stateRoot"` - TxHash common.Hash `json:"transactionsRoot"` - ReceiptHash common.Hash `json:"receiptsRoot"` - Bloom Bloom `json:"logsBloom"` - Difficulty *hexutil.Big `json:"difficulty"` - Number *hexutil.Big `json:"number"` - GasLimit *hexutil.Big `json:"gasLimit"` - GasUsed *hexutil.Big `json:"gasUsed"` - Time *hexutil.Big `json:"timestamp"` - Extra hexutil.Bytes `json:"extraData"` - MixDigest common.Hash `json:"mixHash"` - Nonce BlockNonce `json:"nonce"` - } - var enc HeaderJSON + type Header struct { + ParentHash common.Hash `json:"parentHash" gencodec:"required"` + UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"` + Coinbase common.Address `json:"miner" gencodec:"required"` + Root common.Hash `json:"stateRoot" gencodec:"required"` + TxHash common.Hash `json:"transactionsRoot" gencodec:"required"` + ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"` + Bloom Bloom `json:"logsBloom" gencodec:"required"` + Difficulty *hexutil.Big `json:"difficulty" gencodec:"required"` + Number *hexutil.Big `json:"number" gencodec:"required"` + GasLimit *hexutil.Big `json:"gasLimit" gencodec:"required"` + GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"` + Time *hexutil.Big `json:"timestamp" gencodec:"required"` + Extra hexutil.Bytes `json:"extraData" gencodec:"required"` + MixDigest common.Hash `json:"mixHash" gencodec:"required"` + Nonce BlockNonce `json:"nonce" gencodec:"required"` + Hash common.Hash `json:"hash"` + } + var enc Header enc.ParentHash = h.ParentHash enc.UncleHash = h.UncleHash enc.Coinbase = h.Coinbase @@ -45,92 +46,91 @@ func (h Header) MarshalJSON() ([]byte, error) { enc.Extra = h.Extra enc.MixDigest = h.MixDigest enc.Nonce = h.Nonce + enc.Hash = h.Hash() return json.Marshal(&enc) } func (h *Header) UnmarshalJSON(input []byte) error { - type HeaderJSON struct { - ParentHash *common.Hash `json:"parentHash"` - UncleHash *common.Hash `json:"sha3Uncles"` - Coinbase *common.Address `json:"miner"` - Root *common.Hash `json:"stateRoot"` - TxHash *common.Hash `json:"transactionsRoot"` - ReceiptHash *common.Hash `json:"receiptsRoot"` - Bloom *Bloom `json:"logsBloom"` - Difficulty *hexutil.Big `json:"difficulty"` - Number *hexutil.Big `json:"number"` - GasLimit *hexutil.Big `json:"gasLimit"` - GasUsed *hexutil.Big `json:"gasUsed"` - Time *hexutil.Big `json:"timestamp"` - Extra hexutil.Bytes `json:"extraData"` - MixDigest *common.Hash `json:"mixHash"` - Nonce *BlockNonce `json:"nonce"` - } - var dec HeaderJSON + type Header struct { + ParentHash *common.Hash `json:"parentHash" gencodec:"required"` + UncleHash *common.Hash `json:"sha3Uncles" gencodec:"required"` + Coinbase *common.Address `json:"miner" gencodec:"required"` + Root *common.Hash `json:"stateRoot" gencodec:"required"` + TxHash *common.Hash `json:"transactionsRoot" gencodec:"required"` + ReceiptHash *common.Hash `json:"receiptsRoot" gencodec:"required"` + Bloom *Bloom `json:"logsBloom" gencodec:"required"` + Difficulty *hexutil.Big `json:"difficulty" gencodec:"required"` + Number *hexutil.Big `json:"number" gencodec:"required"` + GasLimit *hexutil.Big `json:"gasLimit" gencodec:"required"` + GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"` + Time *hexutil.Big `json:"timestamp" gencodec:"required"` + Extra hexutil.Bytes `json:"extraData" gencodec:"required"` + MixDigest *common.Hash `json:"mixHash" gencodec:"required"` + Nonce *BlockNonce `json:"nonce" gencodec:"required"` + } + var dec Header if err := json.Unmarshal(input, &dec); err != nil { return err } - var x Header if dec.ParentHash == nil { return errors.New("missing required field 'parentHash' for Header") } - x.ParentHash = *dec.ParentHash + h.ParentHash = *dec.ParentHash if dec.UncleHash == nil { return errors.New("missing required field 'sha3Uncles' for Header") } - x.UncleHash = *dec.UncleHash + h.UncleHash = *dec.UncleHash if dec.Coinbase == nil { return errors.New("missing required field 'miner' for Header") } - x.Coinbase = *dec.Coinbase + h.Coinbase = *dec.Coinbase if dec.Root == nil { return errors.New("missing required field 'stateRoot' for Header") } - x.Root = *dec.Root + h.Root = *dec.Root if dec.TxHash == nil { return errors.New("missing required field 'transactionsRoot' for Header") } - x.TxHash = *dec.TxHash + h.TxHash = *dec.TxHash if dec.ReceiptHash == nil { return errors.New("missing required field 'receiptsRoot' for Header") } - x.ReceiptHash = *dec.ReceiptHash + h.ReceiptHash = *dec.ReceiptHash if dec.Bloom == nil { return errors.New("missing required field 'logsBloom' for Header") } - x.Bloom = *dec.Bloom + h.Bloom = *dec.Bloom if dec.Difficulty == nil { return errors.New("missing required field 'difficulty' for Header") } - x.Difficulty = (*big.Int)(dec.Difficulty) + h.Difficulty = (*big.Int)(dec.Difficulty) if dec.Number == nil { return errors.New("missing required field 'number' for Header") } - x.Number = (*big.Int)(dec.Number) + h.Number = (*big.Int)(dec.Number) if dec.GasLimit == nil { return errors.New("missing required field 'gasLimit' for Header") } - x.GasLimit = (*big.Int)(dec.GasLimit) + h.GasLimit = (*big.Int)(dec.GasLimit) if dec.GasUsed == nil { return errors.New("missing required field 'gasUsed' for Header") } - x.GasUsed = (*big.Int)(dec.GasUsed) + h.GasUsed = (*big.Int)(dec.GasUsed) if dec.Time == nil { return errors.New("missing required field 'timestamp' for Header") } - x.Time = (*big.Int)(dec.Time) + h.Time = (*big.Int)(dec.Time) if dec.Extra == nil { return errors.New("missing required field 'extraData' for Header") } - x.Extra = dec.Extra + h.Extra = dec.Extra if dec.MixDigest == nil { return errors.New("missing required field 'mixHash' for Header") } - x.MixDigest = *dec.MixDigest + h.MixDigest = *dec.MixDigest if dec.Nonce == nil { return errors.New("missing required field 'nonce' for Header") } - x.Nonce = *dec.Nonce - *h = x + h.Nonce = *dec.Nonce return nil } diff --git a/core/types/gen_log_json.go b/core/types/gen_log_json.go index 5c8032953..92c699c2a 100644 --- a/core/types/gen_log_json.go +++ b/core/types/gen_log_json.go @@ -11,18 +11,18 @@ import ( ) func (l Log) MarshalJSON() ([]byte, error) { - type LogJSON struct { - Address common.Address `json:"address"` - Topics []common.Hash `json:"topics"` - Data hexutil.Bytes `json:"data"` - BlockNumber hexutil.Uint64 `json:"blockNumber" optional:"yes"` - TxHash common.Hash `json:"transactionHash"` - TxIndex hexutil.Uint `json:"transactionIndex"` - BlockHash common.Hash `json:"blockHash" optional:"yes"` - Index hexutil.Uint `json:"logIndex"` - Removed bool `json:"removed" optional:"yes"` + type Log struct { + Address common.Address `json:"address" gencodec:"required"` + Topics []common.Hash `json:"topics" gencodec:"required"` + Data hexutil.Bytes `json:"data" gencodec:"required"` + BlockNumber hexutil.Uint64 `json:"blockNumber"` + TxHash common.Hash `json:"transactionHash" gencodec:"required"` + TxIndex hexutil.Uint `json:"transactionIndex" gencodec:"required"` + BlockHash common.Hash `json:"blockHash"` + Index hexutil.Uint `json:"logIndex" gencodec:"required"` + Removed bool `json:"removed"` } - var enc LogJSON + var enc Log enc.Address = l.Address enc.Topics = l.Topics enc.Data = l.Data @@ -36,55 +36,53 @@ func (l Log) MarshalJSON() ([]byte, error) { } func (l *Log) UnmarshalJSON(input []byte) error { - type LogJSON struct { - Address *common.Address `json:"address"` - Topics []common.Hash `json:"topics"` - Data hexutil.Bytes `json:"data"` - BlockNumber *hexutil.Uint64 `json:"blockNumber" optional:"yes"` - TxHash *common.Hash `json:"transactionHash"` - TxIndex *hexutil.Uint `json:"transactionIndex"` - BlockHash *common.Hash `json:"blockHash" optional:"yes"` - Index *hexutil.Uint `json:"logIndex"` - Removed *bool `json:"removed" optional:"yes"` + type Log struct { + Address *common.Address `json:"address" gencodec:"required"` + Topics []common.Hash `json:"topics" gencodec:"required"` + Data hexutil.Bytes `json:"data" gencodec:"required"` + BlockNumber *hexutil.Uint64 `json:"blockNumber"` + TxHash *common.Hash `json:"transactionHash" gencodec:"required"` + TxIndex *hexutil.Uint `json:"transactionIndex" gencodec:"required"` + BlockHash *common.Hash `json:"blockHash"` + Index *hexutil.Uint `json:"logIndex" gencodec:"required"` + Removed *bool `json:"removed"` } - var dec LogJSON + var dec Log if err := json.Unmarshal(input, &dec); err != nil { return err } - var x Log if dec.Address == nil { return errors.New("missing required field 'address' for Log") } - x.Address = *dec.Address + l.Address = *dec.Address if dec.Topics == nil { return errors.New("missing required field 'topics' for Log") } - x.Topics = dec.Topics + l.Topics = dec.Topics if dec.Data == nil { return errors.New("missing required field 'data' for Log") } - x.Data = dec.Data + l.Data = dec.Data if dec.BlockNumber != nil { - x.BlockNumber = uint64(*dec.BlockNumber) + l.BlockNumber = uint64(*dec.BlockNumber) } if dec.TxHash == nil { return errors.New("missing required field 'transactionHash' for Log") } - x.TxHash = *dec.TxHash + l.TxHash = *dec.TxHash if dec.TxIndex == nil { return errors.New("missing required field 'transactionIndex' for Log") } - x.TxIndex = uint(*dec.TxIndex) + l.TxIndex = uint(*dec.TxIndex) if dec.BlockHash != nil { - x.BlockHash = *dec.BlockHash + l.BlockHash = *dec.BlockHash } if dec.Index == nil { return errors.New("missing required field 'logIndex' for Log") } - x.Index = uint(*dec.Index) + l.Index = uint(*dec.Index) if dec.Removed != nil { - x.Removed = *dec.Removed + l.Removed = *dec.Removed } - *l = x return nil } diff --git a/core/types/gen_receipt_json.go b/core/types/gen_receipt_json.go index 6583a8ec0..edbd64ba4 100644 --- a/core/types/gen_receipt_json.go +++ b/core/types/gen_receipt_json.go @@ -12,16 +12,16 @@ import ( ) func (r Receipt) MarshalJSON() ([]byte, error) { - type ReceiptJSON struct { - PostState hexutil.Bytes `json:"root"` - CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed"` - Bloom Bloom `json:"logsBloom"` - Logs []*Log `json:"logs"` - TxHash common.Hash `json:"transactionHash"` - ContractAddress common.Address `json:"contractAddress" optional:"true"` - GasUsed *hexutil.Big `json:"gasUsed"` + type Receipt struct { + PostState hexutil.Bytes `json:"root" gencodec:"required"` + CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed" gencodec:"required"` + Bloom Bloom `json:"logsBloom" gencodec:"required"` + Logs []*Log `json:"logs" gencodec:"required"` + TxHash common.Hash `json:"transactionHash" gencodec:"required"` + ContractAddress common.Address `json:"contractAddress"` + GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"` } - var enc ReceiptJSON + var enc Receipt enc.PostState = r.PostState enc.CumulativeGasUsed = (*hexutil.Big)(r.CumulativeGasUsed) enc.Bloom = r.Bloom @@ -33,47 +33,45 @@ func (r Receipt) MarshalJSON() ([]byte, error) { } func (r *Receipt) UnmarshalJSON(input []byte) error { - type ReceiptJSON struct { - PostState hexutil.Bytes `json:"root"` - CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed"` - Bloom *Bloom `json:"logsBloom"` - Logs []*Log `json:"logs"` - TxHash *common.Hash `json:"transactionHash"` - ContractAddress *common.Address `json:"contractAddress" optional:"true"` - GasUsed *hexutil.Big `json:"gasUsed"` + type Receipt struct { + PostState hexutil.Bytes `json:"root" gencodec:"required"` + CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed" gencodec:"required"` + Bloom *Bloom `json:"logsBloom" gencodec:"required"` + Logs []*Log `json:"logs" gencodec:"required"` + TxHash *common.Hash `json:"transactionHash" gencodec:"required"` + ContractAddress *common.Address `json:"contractAddress"` + GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"` } - var dec ReceiptJSON + var dec Receipt if err := json.Unmarshal(input, &dec); err != nil { return err } - var x Receipt if dec.PostState == nil { return errors.New("missing required field 'root' for Receipt") } - x.PostState = dec.PostState + r.PostState = dec.PostState if dec.CumulativeGasUsed == nil { return errors.New("missing required field 'cumulativeGasUsed' for Receipt") } - x.CumulativeGasUsed = (*big.Int)(dec.CumulativeGasUsed) + r.CumulativeGasUsed = (*big.Int)(dec.CumulativeGasUsed) if dec.Bloom == nil { return errors.New("missing required field 'logsBloom' for Receipt") } - x.Bloom = *dec.Bloom + r.Bloom = *dec.Bloom if dec.Logs == nil { return errors.New("missing required field 'logs' for Receipt") } - x.Logs = dec.Logs + r.Logs = dec.Logs if dec.TxHash == nil { return errors.New("missing required field 'transactionHash' for Receipt") } - x.TxHash = *dec.TxHash + r.TxHash = *dec.TxHash if dec.ContractAddress != nil { - x.ContractAddress = *dec.ContractAddress + r.ContractAddress = *dec.ContractAddress } if dec.GasUsed == nil { return errors.New("missing required field 'gasUsed' for Receipt") } - x.GasUsed = (*big.Int)(dec.GasUsed) - *r = x + r.GasUsed = (*big.Int)(dec.GasUsed) return nil } diff --git a/core/types/gen_tx_json.go b/core/types/gen_tx_json.go index 6101b9637..4fb658e0d 100644 --- a/core/types/gen_tx_json.go +++ b/core/types/gen_tx_json.go @@ -12,19 +12,19 @@ import ( ) func (t txdata) MarshalJSON() ([]byte, error) { - type txdataJSON struct { - AccountNonce hexutil.Uint64 `json:"nonce"` - Price *hexutil.Big `json:"gasPrice"` - GasLimit *hexutil.Big `json:"gas"` - Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"` - Amount *hexutil.Big `json:"value"` - Payload hexutil.Bytes `json:"input"` - V *hexutil.Big `json:"v"` - R *hexutil.Big `json:"r"` - S *hexutil.Big `json:"s"` - Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"` + type txdata struct { + AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"` + Price *hexutil.Big `json:"gasPrice" gencodec:"required"` + GasLimit *hexutil.Big `json:"gas" gencodec:"required"` + Recipient *common.Address `json:"to" rlp:"nil"` + Amount *hexutil.Big `json:"value" gencodec:"required"` + Payload hexutil.Bytes `json:"input" gencodec:"required"` + V *hexutil.Big `json:"v" gencodec:"required"` + R *hexutil.Big `json:"r" gencodec:"required"` + S *hexutil.Big `json:"s" gencodec:"required"` + Hash *common.Hash `json:"hash" rlp:"-"` } - var enc txdataJSON + var enc txdata enc.AccountNonce = hexutil.Uint64(t.AccountNonce) enc.Price = (*hexutil.Big)(t.Price) enc.GasLimit = (*hexutil.Big)(t.GasLimit) @@ -39,61 +39,59 @@ func (t txdata) MarshalJSON() ([]byte, error) { } func (t *txdata) UnmarshalJSON(input []byte) error { - type txdataJSON struct { - AccountNonce *hexutil.Uint64 `json:"nonce"` - Price *hexutil.Big `json:"gasPrice"` - GasLimit *hexutil.Big `json:"gas"` - Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"` - Amount *hexutil.Big `json:"value"` - Payload hexutil.Bytes `json:"input"` - V *hexutil.Big `json:"v"` - R *hexutil.Big `json:"r"` - S *hexutil.Big `json:"s"` - Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"` + type txdata struct { + AccountNonce *hexutil.Uint64 `json:"nonce" gencodec:"required"` + Price *hexutil.Big `json:"gasPrice" gencodec:"required"` + GasLimit *hexutil.Big `json:"gas" gencodec:"required"` + Recipient *common.Address `json:"to" rlp:"nil"` + Amount *hexutil.Big `json:"value" gencodec:"required"` + Payload hexutil.Bytes `json:"input" gencodec:"required"` + V *hexutil.Big `json:"v" gencodec:"required"` + R *hexutil.Big `json:"r" gencodec:"required"` + S *hexutil.Big `json:"s" gencodec:"required"` + Hash *common.Hash `json:"hash" rlp:"-"` } - var dec txdataJSON + var dec txdata if err := json.Unmarshal(input, &dec); err != nil { return err } - var x txdata if dec.AccountNonce == nil { return errors.New("missing required field 'nonce' for txdata") } - x.AccountNonce = uint64(*dec.AccountNonce) + t.AccountNonce = uint64(*dec.AccountNonce) if dec.Price == nil { return errors.New("missing required field 'gasPrice' for txdata") } - x.Price = (*big.Int)(dec.Price) + t.Price = (*big.Int)(dec.Price) if dec.GasLimit == nil { return errors.New("missing required field 'gas' for txdata") } - x.GasLimit = (*big.Int)(dec.GasLimit) + t.GasLimit = (*big.Int)(dec.GasLimit) if dec.Recipient != nil { - x.Recipient = dec.Recipient + t.Recipient = dec.Recipient } if dec.Amount == nil { return errors.New("missing required field 'value' for txdata") } - x.Amount = (*big.Int)(dec.Amount) + t.Amount = (*big.Int)(dec.Amount) if dec.Payload == nil { return errors.New("missing required field 'input' for txdata") } - x.Payload = dec.Payload + t.Payload = dec.Payload if dec.V == nil { return errors.New("missing required field 'v' for txdata") } - x.V = (*big.Int)(dec.V) + t.V = (*big.Int)(dec.V) if dec.R == nil { return errors.New("missing required field 'r' for txdata") } - x.R = (*big.Int)(dec.R) + t.R = (*big.Int)(dec.R) if dec.S == nil { return errors.New("missing required field 's' for txdata") } - x.S = (*big.Int)(dec.S) + t.S = (*big.Int)(dec.S) if dec.Hash != nil { - x.Hash = dec.Hash + t.Hash = dec.Hash } - *t = x return nil } diff --git a/core/types/log.go b/core/types/log.go index 57fc7b363..be5de38da 100644 --- a/core/types/log.go +++ b/core/types/log.go @@ -32,28 +32,28 @@ import ( type Log struct { // Consensus fields: // address of the contract that generated the event - Address common.Address `json:"address"` + Address common.Address `json:"address" gencodec:"required"` // list of topics provided by the contract. - Topics []common.Hash `json:"topics"` + Topics []common.Hash `json:"topics" gencodec:"required"` // supplied by the contract, usually ABI-encoded - Data []byte `json:"data"` + Data []byte `json:"data" gencodec:"required"` // Derived fields. These fields are filled in by the node // but not secured by consensus. // block in which the transaction was included - BlockNumber uint64 `json:"blockNumber" optional:"yes"` + BlockNumber uint64 `json:"blockNumber"` // hash of the transaction - TxHash common.Hash `json:"transactionHash"` + TxHash common.Hash `json:"transactionHash" gencodec:"required"` // index of the transaction in the block - TxIndex uint `json:"transactionIndex"` + TxIndex uint `json:"transactionIndex" gencodec:"required"` // hash of the block in which the transaction was included - BlockHash common.Hash `json:"blockHash" optional:"yes"` + BlockHash common.Hash `json:"blockHash"` // index of the log in the receipt - Index uint `json:"logIndex"` + Index uint `json:"logIndex" gencodec:"required"` // The Removed field is true if this log was reverted due to a chain reorganisation. // You must pay attention to this field if you receive logs through a filter query. - Removed bool `json:"removed" optional:"yes"` + Removed bool `json:"removed"` } type logMarshaling struct { diff --git a/core/types/receipt.go b/core/types/receipt.go index 5bfcb15fc..ef6f6a2bb 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -31,15 +31,15 @@ import ( // Receipt represents the results of a transaction. type Receipt struct { // Consensus fields - PostState []byte `json:"root"` - CumulativeGasUsed *big.Int `json:"cumulativeGasUsed"` - Bloom Bloom `json:"logsBloom"` - Logs []*Log `json:"logs"` + PostState []byte `json:"root" gencodec:"required"` + CumulativeGasUsed *big.Int `json:"cumulativeGasUsed" gencodec:"required"` + Bloom Bloom `json:"logsBloom" gencodec:"required"` + Logs []*Log `json:"logs" gencodec:"required"` // Implementation fields (don't reorder!) - TxHash common.Hash `json:"transactionHash"` - ContractAddress common.Address `json:"contractAddress" optional:"true"` - GasUsed *big.Int `json:"gasUsed"` + TxHash common.Hash `json:"transactionHash" gencodec:"required"` + ContractAddress common.Address `json:"contractAddress"` + GasUsed *big.Int `json:"gasUsed" gencodec:"required"` } type receiptMarshaling struct { diff --git a/core/types/transaction.go b/core/types/transaction.go index 3945684a1..8e108b2a3 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -55,20 +55,20 @@ type Transaction struct { } type txdata struct { - AccountNonce uint64 `json:"nonce"` - Price *big.Int `json:"gasPrice"` - GasLimit *big.Int `json:"gas"` - Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"` // nil means contract creation - Amount *big.Int `json:"value"` - Payload []byte `json:"input"` + AccountNonce uint64 `json:"nonce" gencodec:"required"` + Price *big.Int `json:"gasPrice" gencodec:"required"` + GasLimit *big.Int `json:"gas" gencodec:"required"` + Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation + Amount *big.Int `json:"value" gencodec:"required"` + Payload []byte `json:"input" gencodec:"required"` // Signature values - V *big.Int `json:"v"` - R *big.Int `json:"r"` - S *big.Int `json:"s"` + V *big.Int `json:"v" gencodec:"required"` + R *big.Int `json:"r" gencodec:"required"` + S *big.Int `json:"s" gencodec:"required"` // This is only used when marshaling to JSON. - Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"` + Hash *common.Hash `json:"hash" rlp:"-"` } type txdataMarshaling struct { |