core/types: regenerate marshaling methods with fjl/gencodec@cbfa5be5a8

This commit is contained in:
Felix Lange 2017-04-04 22:21:38 +02:00
parent 80399f57b0
commit 260343ccbb
8 changed files with 180 additions and 188 deletions

View file

@ -68,21 +68,21 @@ func (n *BlockNonce) UnmarshalText(input []byte) error {
// Header represents a block header in the Ethereum blockchain. // Header represents a block header in the Ethereum blockchain.
type Header struct { type Header struct {
ParentHash common.Hash `json:"parentHash"` ParentHash common.Hash `json:"parentHash" gencodec:"required"`
UncleHash common.Hash `json:"sha3Uncles"` UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"`
Coinbase common.Address `json:"miner"` Coinbase common.Address `json:"miner" gencodec:"required"`
Root common.Hash `json:"stateRoot"` Root common.Hash `json:"stateRoot" gencodec:"required"`
TxHash common.Hash `json:"transactionsRoot"` TxHash common.Hash `json:"transactionsRoot" gencodec:"required"`
ReceiptHash common.Hash `json:"receiptsRoot"` ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"`
Bloom Bloom `json:"logsBloom"` Bloom Bloom `json:"logsBloom" gencodec:"required"`
Difficulty *big.Int `json:"difficulty"` Difficulty *big.Int `json:"difficulty" gencodec:"required"`
Number *big.Int `json:"number"` Number *big.Int `json:"number" gencodec:"required"`
GasLimit *big.Int `json:"gasLimit"` GasLimit *big.Int `json:"gasLimit" gencodec:"required"`
GasUsed *big.Int `json:"gasUsed"` GasUsed *big.Int `json:"gasUsed" gencodec:"required"`
Time *big.Int `json:"timestamp"` Time *big.Int `json:"timestamp" gencodec:"required"`
Extra []byte `json:"extraData"` Extra []byte `json:"extraData" gencodec:"required"`
MixDigest common.Hash `json:"mixHash"` MixDigest common.Hash `json:"mixHash" gencodec:"required"`
Nonce BlockNonce `json:"nonce"` Nonce BlockNonce `json:"nonce" gencodec:"required"`
} }
// field type overrides for gencodec // field type overrides for gencodec

View file

@ -12,24 +12,24 @@ import (
) )
func (h Header) MarshalJSON() ([]byte, error) { func (h Header) MarshalJSON() ([]byte, error) {
type HeaderJSON struct { type Header struct {
ParentHash common.Hash `json:"parentHash"` ParentHash common.Hash `json:"parentHash" gencodec:"required"`
UncleHash common.Hash `json:"sha3Uncles"` UncleHash common.Hash `json:"sha3Uncles" gencodec:"required"`
Coinbase common.Address `json:"miner"` Coinbase common.Address `json:"miner" gencodec:"required"`
Root common.Hash `json:"stateRoot"` Root common.Hash `json:"stateRoot" gencodec:"required"`
TxHash common.Hash `json:"transactionsRoot"` TxHash common.Hash `json:"transactionsRoot" gencodec:"required"`
ReceiptHash common.Hash `json:"receiptsRoot"` ReceiptHash common.Hash `json:"receiptsRoot" gencodec:"required"`
Bloom Bloom `json:"logsBloom"` Bloom Bloom `json:"logsBloom" gencodec:"required"`
Difficulty *hexutil.Big `json:"difficulty"` Difficulty *hexutil.Big `json:"difficulty" gencodec:"required"`
Number *hexutil.Big `json:"number"` Number *hexutil.Big `json:"number" gencodec:"required"`
GasLimit *hexutil.Big `json:"gasLimit"` GasLimit *hexutil.Big `json:"gasLimit" gencodec:"required"`
GasUsed *hexutil.Big `json:"gasUsed"` GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"`
Time *hexutil.Big `json:"timestamp"` Time *hexutil.Big `json:"timestamp" gencodec:"required"`
Extra hexutil.Bytes `json:"extraData"` Extra hexutil.Bytes `json:"extraData" gencodec:"required"`
MixDigest common.Hash `json:"mixHash"` MixDigest common.Hash `json:"mixHash" gencodec:"required"`
Nonce BlockNonce `json:"nonce"` Nonce BlockNonce `json:"nonce" gencodec:"required"`
} }
var enc HeaderJSON var enc Header
enc.ParentHash = h.ParentHash enc.ParentHash = h.ParentHash
enc.UncleHash = h.UncleHash enc.UncleHash = h.UncleHash
enc.Coinbase = h.Coinbase enc.Coinbase = h.Coinbase
@ -49,88 +49,86 @@ func (h Header) MarshalJSON() ([]byte, error) {
} }
func (h *Header) UnmarshalJSON(input []byte) error { func (h *Header) UnmarshalJSON(input []byte) error {
type HeaderJSON struct { type Header struct {
ParentHash *common.Hash `json:"parentHash"` ParentHash *common.Hash `json:"parentHash" gencodec:"required"`
UncleHash *common.Hash `json:"sha3Uncles"` UncleHash *common.Hash `json:"sha3Uncles" gencodec:"required"`
Coinbase *common.Address `json:"miner"` Coinbase *common.Address `json:"miner" gencodec:"required"`
Root *common.Hash `json:"stateRoot"` Root *common.Hash `json:"stateRoot" gencodec:"required"`
TxHash *common.Hash `json:"transactionsRoot"` TxHash *common.Hash `json:"transactionsRoot" gencodec:"required"`
ReceiptHash *common.Hash `json:"receiptsRoot"` ReceiptHash *common.Hash `json:"receiptsRoot" gencodec:"required"`
Bloom *Bloom `json:"logsBloom"` Bloom *Bloom `json:"logsBloom" gencodec:"required"`
Difficulty *hexutil.Big `json:"difficulty"` Difficulty *hexutil.Big `json:"difficulty" gencodec:"required"`
Number *hexutil.Big `json:"number"` Number *hexutil.Big `json:"number" gencodec:"required"`
GasLimit *hexutil.Big `json:"gasLimit"` GasLimit *hexutil.Big `json:"gasLimit" gencodec:"required"`
GasUsed *hexutil.Big `json:"gasUsed"` GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"`
Time *hexutil.Big `json:"timestamp"` Time *hexutil.Big `json:"timestamp" gencodec:"required"`
Extra hexutil.Bytes `json:"extraData"` Extra hexutil.Bytes `json:"extraData" gencodec:"required"`
MixDigest *common.Hash `json:"mixHash"` MixDigest *common.Hash `json:"mixHash" gencodec:"required"`
Nonce *BlockNonce `json:"nonce"` Nonce *BlockNonce `json:"nonce" gencodec:"required"`
} }
var dec HeaderJSON var dec Header
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
return err return err
} }
var x Header
if dec.ParentHash == nil { if dec.ParentHash == nil {
return errors.New("missing required field 'parentHash' for Header") return errors.New("missing required field 'parentHash' for Header")
} }
x.ParentHash = *dec.ParentHash h.ParentHash = *dec.ParentHash
if dec.UncleHash == nil { if dec.UncleHash == nil {
return errors.New("missing required field 'sha3Uncles' for Header") return errors.New("missing required field 'sha3Uncles' for Header")
} }
x.UncleHash = *dec.UncleHash h.UncleHash = *dec.UncleHash
if dec.Coinbase == nil { if dec.Coinbase == nil {
return errors.New("missing required field 'miner' for Header") return errors.New("missing required field 'miner' for Header")
} }
x.Coinbase = *dec.Coinbase h.Coinbase = *dec.Coinbase
if dec.Root == nil { if dec.Root == nil {
return errors.New("missing required field 'stateRoot' for Header") return errors.New("missing required field 'stateRoot' for Header")
} }
x.Root = *dec.Root h.Root = *dec.Root
if dec.TxHash == nil { if dec.TxHash == nil {
return errors.New("missing required field 'transactionsRoot' for Header") return errors.New("missing required field 'transactionsRoot' for Header")
} }
x.TxHash = *dec.TxHash h.TxHash = *dec.TxHash
if dec.ReceiptHash == nil { if dec.ReceiptHash == nil {
return errors.New("missing required field 'receiptsRoot' for Header") return errors.New("missing required field 'receiptsRoot' for Header")
} }
x.ReceiptHash = *dec.ReceiptHash h.ReceiptHash = *dec.ReceiptHash
if dec.Bloom == nil { if dec.Bloom == nil {
return errors.New("missing required field 'logsBloom' for Header") return errors.New("missing required field 'logsBloom' for Header")
} }
x.Bloom = *dec.Bloom h.Bloom = *dec.Bloom
if dec.Difficulty == nil { if dec.Difficulty == nil {
return errors.New("missing required field 'difficulty' for Header") 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 { if dec.Number == nil {
return errors.New("missing required field 'number' for Header") 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 { if dec.GasLimit == nil {
return errors.New("missing required field 'gasLimit' for Header") 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 { if dec.GasUsed == nil {
return errors.New("missing required field 'gasUsed' for Header") 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 { if dec.Time == nil {
return errors.New("missing required field 'timestamp' for Header") 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 { if dec.Extra == nil {
return errors.New("missing required field 'extraData' for Header") return errors.New("missing required field 'extraData' for Header")
} }
x.Extra = dec.Extra h.Extra = dec.Extra
if dec.MixDigest == nil { if dec.MixDigest == nil {
return errors.New("missing required field 'mixHash' for Header") return errors.New("missing required field 'mixHash' for Header")
} }
x.MixDigest = *dec.MixDigest h.MixDigest = *dec.MixDigest
if dec.Nonce == nil { if dec.Nonce == nil {
return errors.New("missing required field 'nonce' for Header") return errors.New("missing required field 'nonce' for Header")
} }
x.Nonce = *dec.Nonce h.Nonce = *dec.Nonce
*h = x
return nil return nil
} }

View file

@ -11,18 +11,18 @@ import (
) )
func (l Log) MarshalJSON() ([]byte, error) { func (l Log) MarshalJSON() ([]byte, error) {
type LogJSON struct { type Log struct {
Address common.Address `json:"address"` Address common.Address `json:"address" gencodec:"required"`
Topics []common.Hash `json:"topics"` Topics []common.Hash `json:"topics" gencodec:"required"`
Data hexutil.Bytes `json:"data"` Data hexutil.Bytes `json:"data" gencodec:"required"`
BlockNumber hexutil.Uint64 `json:"blockNumber" optional:"yes"` BlockNumber hexutil.Uint64 `json:"blockNumber"`
TxHash common.Hash `json:"transactionHash"` TxHash common.Hash `json:"transactionHash" gencodec:"required"`
TxIndex hexutil.Uint `json:"transactionIndex"` TxIndex hexutil.Uint `json:"transactionIndex" gencodec:"required"`
BlockHash common.Hash `json:"blockHash" optional:"yes"` BlockHash common.Hash `json:"blockHash"`
Index hexutil.Uint `json:"logIndex"` Index hexutil.Uint `json:"logIndex" gencodec:"required"`
Removed bool `json:"removed" optional:"yes"` Removed bool `json:"removed"`
} }
var enc LogJSON var enc Log
enc.Address = l.Address enc.Address = l.Address
enc.Topics = l.Topics enc.Topics = l.Topics
enc.Data = l.Data enc.Data = l.Data
@ -36,55 +36,53 @@ func (l Log) MarshalJSON() ([]byte, error) {
} }
func (l *Log) UnmarshalJSON(input []byte) error { func (l *Log) UnmarshalJSON(input []byte) error {
type LogJSON struct { type Log struct {
Address *common.Address `json:"address"` Address *common.Address `json:"address" gencodec:"required"`
Topics []common.Hash `json:"topics"` Topics []common.Hash `json:"topics" gencodec:"required"`
Data hexutil.Bytes `json:"data"` Data hexutil.Bytes `json:"data" gencodec:"required"`
BlockNumber *hexutil.Uint64 `json:"blockNumber" optional:"yes"` BlockNumber *hexutil.Uint64 `json:"blockNumber"`
TxHash *common.Hash `json:"transactionHash"` TxHash *common.Hash `json:"transactionHash" gencodec:"required"`
TxIndex *hexutil.Uint `json:"transactionIndex"` TxIndex *hexutil.Uint `json:"transactionIndex" gencodec:"required"`
BlockHash *common.Hash `json:"blockHash" optional:"yes"` BlockHash *common.Hash `json:"blockHash"`
Index *hexutil.Uint `json:"logIndex"` Index *hexutil.Uint `json:"logIndex" gencodec:"required"`
Removed *bool `json:"removed" optional:"yes"` Removed *bool `json:"removed"`
} }
var dec LogJSON var dec Log
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
return err return err
} }
var x Log
if dec.Address == nil { if dec.Address == nil {
return errors.New("missing required field 'address' for Log") return errors.New("missing required field 'address' for Log")
} }
x.Address = *dec.Address l.Address = *dec.Address
if dec.Topics == nil { if dec.Topics == nil {
return errors.New("missing required field 'topics' for Log") return errors.New("missing required field 'topics' for Log")
} }
x.Topics = dec.Topics l.Topics = dec.Topics
if dec.Data == nil { if dec.Data == nil {
return errors.New("missing required field 'data' for Log") return errors.New("missing required field 'data' for Log")
} }
x.Data = dec.Data l.Data = dec.Data
if dec.BlockNumber != nil { if dec.BlockNumber != nil {
x.BlockNumber = uint64(*dec.BlockNumber) l.BlockNumber = uint64(*dec.BlockNumber)
} }
if dec.TxHash == nil { if dec.TxHash == nil {
return errors.New("missing required field 'transactionHash' for Log") return errors.New("missing required field 'transactionHash' for Log")
} }
x.TxHash = *dec.TxHash l.TxHash = *dec.TxHash
if dec.TxIndex == nil { if dec.TxIndex == nil {
return errors.New("missing required field 'transactionIndex' for Log") return errors.New("missing required field 'transactionIndex' for Log")
} }
x.TxIndex = uint(*dec.TxIndex) l.TxIndex = uint(*dec.TxIndex)
if dec.BlockHash != nil { if dec.BlockHash != nil {
x.BlockHash = *dec.BlockHash l.BlockHash = *dec.BlockHash
} }
if dec.Index == nil { if dec.Index == nil {
return errors.New("missing required field 'logIndex' for Log") return errors.New("missing required field 'logIndex' for Log")
} }
x.Index = uint(*dec.Index) l.Index = uint(*dec.Index)
if dec.Removed != nil { if dec.Removed != nil {
x.Removed = *dec.Removed l.Removed = *dec.Removed
} }
*l = x
return nil return nil
} }

View file

@ -12,16 +12,16 @@ import (
) )
func (r Receipt) MarshalJSON() ([]byte, error) { func (r Receipt) MarshalJSON() ([]byte, error) {
type ReceiptJSON struct { type Receipt struct {
PostState hexutil.Bytes `json:"root"` PostState hexutil.Bytes `json:"root" gencodec:"required"`
CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed"` CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed" gencodec:"required"`
Bloom Bloom `json:"logsBloom"` Bloom Bloom `json:"logsBloom" gencodec:"required"`
Logs []*Log `json:"logs"` Logs []*Log `json:"logs" gencodec:"required"`
TxHash common.Hash `json:"transactionHash"` TxHash common.Hash `json:"transactionHash" gencodec:"required"`
ContractAddress common.Address `json:"contractAddress" optional:"true"` ContractAddress common.Address `json:"contractAddress"`
GasUsed *hexutil.Big `json:"gasUsed"` GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"`
} }
var enc ReceiptJSON var enc Receipt
enc.PostState = r.PostState enc.PostState = r.PostState
enc.CumulativeGasUsed = (*hexutil.Big)(r.CumulativeGasUsed) enc.CumulativeGasUsed = (*hexutil.Big)(r.CumulativeGasUsed)
enc.Bloom = r.Bloom enc.Bloom = r.Bloom
@ -33,47 +33,45 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
} }
func (r *Receipt) UnmarshalJSON(input []byte) error { func (r *Receipt) UnmarshalJSON(input []byte) error {
type ReceiptJSON struct { type Receipt struct {
PostState hexutil.Bytes `json:"root"` PostState hexutil.Bytes `json:"root" gencodec:"required"`
CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed"` CumulativeGasUsed *hexutil.Big `json:"cumulativeGasUsed" gencodec:"required"`
Bloom *Bloom `json:"logsBloom"` Bloom *Bloom `json:"logsBloom" gencodec:"required"`
Logs []*Log `json:"logs"` Logs []*Log `json:"logs" gencodec:"required"`
TxHash *common.Hash `json:"transactionHash"` TxHash *common.Hash `json:"transactionHash" gencodec:"required"`
ContractAddress *common.Address `json:"contractAddress" optional:"true"` ContractAddress *common.Address `json:"contractAddress"`
GasUsed *hexutil.Big `json:"gasUsed"` GasUsed *hexutil.Big `json:"gasUsed" gencodec:"required"`
} }
var dec ReceiptJSON var dec Receipt
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
return err return err
} }
var x Receipt
if dec.PostState == nil { if dec.PostState == nil {
return errors.New("missing required field 'root' for Receipt") return errors.New("missing required field 'root' for Receipt")
} }
x.PostState = dec.PostState r.PostState = dec.PostState
if dec.CumulativeGasUsed == nil { if dec.CumulativeGasUsed == nil {
return errors.New("missing required field 'cumulativeGasUsed' for Receipt") 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 { if dec.Bloom == nil {
return errors.New("missing required field 'logsBloom' for Receipt") return errors.New("missing required field 'logsBloom' for Receipt")
} }
x.Bloom = *dec.Bloom r.Bloom = *dec.Bloom
if dec.Logs == nil { if dec.Logs == nil {
return errors.New("missing required field 'logs' for Receipt") return errors.New("missing required field 'logs' for Receipt")
} }
x.Logs = dec.Logs r.Logs = dec.Logs
if dec.TxHash == nil { if dec.TxHash == nil {
return errors.New("missing required field 'transactionHash' for Receipt") return errors.New("missing required field 'transactionHash' for Receipt")
} }
x.TxHash = *dec.TxHash r.TxHash = *dec.TxHash
if dec.ContractAddress != nil { if dec.ContractAddress != nil {
x.ContractAddress = *dec.ContractAddress r.ContractAddress = *dec.ContractAddress
} }
if dec.GasUsed == nil { if dec.GasUsed == nil {
return errors.New("missing required field 'gasUsed' for Receipt") return errors.New("missing required field 'gasUsed' for Receipt")
} }
x.GasUsed = (*big.Int)(dec.GasUsed) r.GasUsed = (*big.Int)(dec.GasUsed)
*r = x
return nil return nil
} }

View file

@ -12,19 +12,19 @@ import (
) )
func (t txdata) MarshalJSON() ([]byte, error) { func (t txdata) MarshalJSON() ([]byte, error) {
type txdataJSON struct { type txdata struct {
AccountNonce hexutil.Uint64 `json:"nonce"` AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"`
Price *hexutil.Big `json:"gasPrice"` Price *hexutil.Big `json:"gasPrice" gencodec:"required"`
GasLimit *hexutil.Big `json:"gas"` GasLimit *hexutil.Big `json:"gas" gencodec:"required"`
Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"` Recipient *common.Address `json:"to" rlp:"nil"`
Amount *hexutil.Big `json:"value"` Amount *hexutil.Big `json:"value" gencodec:"required"`
Payload hexutil.Bytes `json:"input"` Payload hexutil.Bytes `json:"input" gencodec:"required"`
V *hexutil.Big `json:"v"` V *hexutil.Big `json:"v" gencodec:"required"`
R *hexutil.Big `json:"r"` R *hexutil.Big `json:"r" gencodec:"required"`
S *hexutil.Big `json:"s"` S *hexutil.Big `json:"s" gencodec:"required"`
Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"` Hash *common.Hash `json:"hash" rlp:"-"`
} }
var enc txdataJSON var enc txdata
enc.AccountNonce = hexutil.Uint64(t.AccountNonce) enc.AccountNonce = hexutil.Uint64(t.AccountNonce)
enc.Price = (*hexutil.Big)(t.Price) enc.Price = (*hexutil.Big)(t.Price)
enc.GasLimit = (*hexutil.Big)(t.GasLimit) enc.GasLimit = (*hexutil.Big)(t.GasLimit)
@ -39,61 +39,59 @@ func (t txdata) MarshalJSON() ([]byte, error) {
} }
func (t *txdata) UnmarshalJSON(input []byte) error { func (t *txdata) UnmarshalJSON(input []byte) error {
type txdataJSON struct { type txdata struct {
AccountNonce *hexutil.Uint64 `json:"nonce"` AccountNonce *hexutil.Uint64 `json:"nonce" gencodec:"required"`
Price *hexutil.Big `json:"gasPrice"` Price *hexutil.Big `json:"gasPrice" gencodec:"required"`
GasLimit *hexutil.Big `json:"gas"` GasLimit *hexutil.Big `json:"gas" gencodec:"required"`
Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"` Recipient *common.Address `json:"to" rlp:"nil"`
Amount *hexutil.Big `json:"value"` Amount *hexutil.Big `json:"value" gencodec:"required"`
Payload hexutil.Bytes `json:"input"` Payload hexutil.Bytes `json:"input" gencodec:"required"`
V *hexutil.Big `json:"v"` V *hexutil.Big `json:"v" gencodec:"required"`
R *hexutil.Big `json:"r"` R *hexutil.Big `json:"r" gencodec:"required"`
S *hexutil.Big `json:"s"` S *hexutil.Big `json:"s" gencodec:"required"`
Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"` Hash *common.Hash `json:"hash" rlp:"-"`
} }
var dec txdataJSON var dec txdata
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
return err return err
} }
var x txdata
if dec.AccountNonce == nil { if dec.AccountNonce == nil {
return errors.New("missing required field 'nonce' for txdata") return errors.New("missing required field 'nonce' for txdata")
} }
x.AccountNonce = uint64(*dec.AccountNonce) t.AccountNonce = uint64(*dec.AccountNonce)
if dec.Price == nil { if dec.Price == nil {
return errors.New("missing required field 'gasPrice' for txdata") 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 { if dec.GasLimit == nil {
return errors.New("missing required field 'gas' for txdata") 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 { if dec.Recipient != nil {
x.Recipient = dec.Recipient t.Recipient = dec.Recipient
} }
if dec.Amount == nil { if dec.Amount == nil {
return errors.New("missing required field 'value' for txdata") 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 { if dec.Payload == nil {
return errors.New("missing required field 'input' for txdata") return errors.New("missing required field 'input' for txdata")
} }
x.Payload = dec.Payload t.Payload = dec.Payload
if dec.V == nil { if dec.V == nil {
return errors.New("missing required field 'v' for txdata") 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 { if dec.R == nil {
return errors.New("missing required field 'r' for txdata") 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 { if dec.S == nil {
return errors.New("missing required field 's' for txdata") 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 { if dec.Hash != nil {
x.Hash = dec.Hash t.Hash = dec.Hash
} }
*t = x
return nil return nil
} }

View file

@ -32,28 +32,28 @@ import (
type Log struct { type Log struct {
// Consensus fields: // Consensus fields:
// address of the contract that generated the event // 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. // 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 // 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 // Derived fields. These fields are filled in by the node
// but not secured by consensus. // but not secured by consensus.
// block in which the transaction was included // block in which the transaction was included
BlockNumber uint64 `json:"blockNumber" optional:"yes"` BlockNumber uint64 `json:"blockNumber"`
// hash of the transaction // hash of the transaction
TxHash common.Hash `json:"transactionHash"` TxHash common.Hash `json:"transactionHash" gencodec:"required"`
// index of the transaction in the block // 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 // 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 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. // 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. // 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 { type logMarshaling struct {

View file

@ -31,15 +31,15 @@ import (
// Receipt represents the results of a transaction. // Receipt represents the results of a transaction.
type Receipt struct { type Receipt struct {
// Consensus fields // Consensus fields
PostState []byte `json:"root"` PostState []byte `json:"root" gencodec:"required"`
CumulativeGasUsed *big.Int `json:"cumulativeGasUsed"` CumulativeGasUsed *big.Int `json:"cumulativeGasUsed" gencodec:"required"`
Bloom Bloom `json:"logsBloom"` Bloom Bloom `json:"logsBloom" gencodec:"required"`
Logs []*Log `json:"logs"` Logs []*Log `json:"logs" gencodec:"required"`
// Implementation fields (don't reorder!) // Implementation fields (don't reorder!)
TxHash common.Hash `json:"transactionHash"` TxHash common.Hash `json:"transactionHash" gencodec:"required"`
ContractAddress common.Address `json:"contractAddress" optional:"true"` ContractAddress common.Address `json:"contractAddress"`
GasUsed *big.Int `json:"gasUsed"` GasUsed *big.Int `json:"gasUsed" gencodec:"required"`
} }
type receiptMarshaling struct { type receiptMarshaling struct {

View file

@ -55,20 +55,20 @@ type Transaction struct {
} }
type txdata struct { type txdata struct {
AccountNonce uint64 `json:"nonce"` AccountNonce uint64 `json:"nonce" gencodec:"required"`
Price *big.Int `json:"gasPrice"` Price *big.Int `json:"gasPrice" gencodec:"required"`
GasLimit *big.Int `json:"gas"` GasLimit *big.Int `json:"gas" gencodec:"required"`
Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"` // nil means contract creation Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation
Amount *big.Int `json:"value"` Amount *big.Int `json:"value" gencodec:"required"`
Payload []byte `json:"input"` Payload []byte `json:"input" gencodec:"required"`
// Signature values // Signature values
V *big.Int `json:"v"` V *big.Int `json:"v" gencodec:"required"`
R *big.Int `json:"r"` R *big.Int `json:"r" gencodec:"required"`
S *big.Int `json:"s"` S *big.Int `json:"s" gencodec:"required"`
// This is only used when marshaling to JSON. // 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 { type txdataMarshaling struct {