Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
16afb5c4
Commit
16afb5c4
authored
Mar 28, 2017
by
Péter Szilágyi
Committed by
GitHub
Mar 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13516 from fjl/core-marshal-non-pointer
core, core/types: use non-pointer receiver for Marshal* methods
parents
225c2871
aa9a78e4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
112 deletions
+106
-112
gen_genesis.go
core/gen_genesis.go
+32
-34
gen_genesis_account.go
core/gen_genesis_account.go
+11
-15
genesis.go
core/genesis.go
+3
-3
gen_header_json.go
core/types/gen_header_json.go
+26
-26
gen_log_json.go
core/types/gen_log_json.go
+18
-18
gen_receipt_json.go
core/types/gen_receipt_json.go
+12
-12
gen_tx_json.go
core/types/gen_tx_json.go
+4
-4
No files found.
core/gen_genesis.go
View file @
16afb5c4
//
generated by github.com/fjl/gencodec, do not edit
.
//
Code generated by github.com/fjl/gencodec. DO NOT EDIT
.
package
core
...
...
@@ -13,31 +13,29 @@ import (
"github.com/ethereum/go-ethereum/params"
)
func
(
g
*
Genesis
)
MarshalJSON
()
([]
byte
,
error
)
{
func
(
g
Genesis
)
MarshalJSON
()
([]
byte
,
error
)
{
type
GenesisJSON
struct
{
C
hainConfig
*
params
.
ChainConfig
`json:"config" optional:"true"`
Nonce
*
math
.
HexOrDecimal64
`json:"nonce" optional:"true"`
Timestamp
*
math
.
HexOrDecimal64
`json:"timestamp" optional:"true"`
ParentHash
*
common
.
Hash
`json:"parentHash" optional:"true"`
ExtraData
hexutil
.
Bytes
`json:"extraData" optional:"true"`
GasLimit
*
math
.
HexOrDecimal64
`json:"gasLimit"`
Difficulty
*
math
.
HexOrDecimal256
`json:"difficulty"`
Mixhash
*
common
.
Hash
`json:"mixHash" optional:"true"`
Coinbase
*
common
.
Address
`json:"coinbase" optional:"true"`
Alloc
map
[
common
.
UnprefixedAddress
]
GenesisAccount
`json:"alloc"`
C
onfig
*
params
.
ChainConfig
`json:"config" optional:"true"`
Nonce
math
.
HexOrDecimal64
`json:"nonce" optional:"true"`
Timestamp
math
.
HexOrDecimal64
`json:"timestamp" optional:"true"`
ParentHash
common
.
Hash
`json:"parentHash" optional:"true"`
ExtraData
hexutil
.
Bytes
`json:"extraData" optional:"true"`
GasLimit
math
.
HexOrDecimal64
`json:"gasLimit"`
Difficulty
*
math
.
HexOrDecimal256
`json:"difficulty"`
Mixhash
common
.
Hash
`json:"mixHash" optional:"true"`
Coinbase
common
.
Address
`json:"coinbase" optional:"true"`
Alloc
map
[
common
.
UnprefixedAddress
]
GenesisAccount
`json:"alloc"`
}
var
enc
GenesisJSON
enc
.
ChainConfig
=
g
.
Config
enc
.
Nonce
=
(
*
math
.
HexOrDecimal64
)(
&
g
.
Nonce
)
enc
.
Timestamp
=
(
*
math
.
HexOrDecimal64
)(
&
g
.
Timestamp
)
enc
.
ParentHash
=
&
g
.
ParentHash
if
g
.
ExtraData
!=
nil
{
enc
.
ExtraData
=
g
.
ExtraData
}
enc
.
GasLimit
=
(
*
math
.
HexOrDecimal64
)(
&
g
.
GasLimit
)
enc
.
Config
=
g
.
Config
enc
.
Nonce
=
math
.
HexOrDecimal64
(
g
.
Nonce
)
enc
.
Timestamp
=
math
.
HexOrDecimal64
(
g
.
Timestamp
)
enc
.
ParentHash
=
g
.
ParentHash
enc
.
ExtraData
=
g
.
ExtraData
enc
.
GasLimit
=
math
.
HexOrDecimal64
(
g
.
GasLimit
)
enc
.
Difficulty
=
(
*
math
.
HexOrDecimal256
)(
g
.
Difficulty
)
enc
.
Mixhash
=
&
g
.
Mixhash
enc
.
Coinbase
=
&
g
.
Coinbase
enc
.
Mixhash
=
g
.
Mixhash
enc
.
Coinbase
=
g
.
Coinbase
if
g
.
Alloc
!=
nil
{
enc
.
Alloc
=
make
(
map
[
common
.
UnprefixedAddress
]
GenesisAccount
,
len
(
g
.
Alloc
))
for
k
,
v
:=
range
g
.
Alloc
{
...
...
@@ -49,24 +47,24 @@ func (g *Genesis) MarshalJSON() ([]byte, error) {
func
(
g
*
Genesis
)
UnmarshalJSON
(
input
[]
byte
)
error
{
type
GenesisJSON
struct
{
C
hainConfig
*
params
.
ChainConfig
`json:"config" optional:"true"`
Nonce
*
math
.
HexOrDecimal64
`json:"nonce" optional:"true"`
Timestamp
*
math
.
HexOrDecimal64
`json:"timestamp" optional:"true"`
ParentHash
*
common
.
Hash
`json:"parentHash" optional:"true"`
ExtraData
hexutil
.
Bytes
`json:"extraData" optional:"true"`
GasLimit
*
math
.
HexOrDecimal64
`json:"gasLimit"`
Difficulty
*
math
.
HexOrDecimal256
`json:"difficulty"`
Mixhash
*
common
.
Hash
`json:"mixHash" optional:"true"`
Coinbase
*
common
.
Address
`json:"coinbase" optional:"true"`
Alloc
map
[
common
.
UnprefixedAddress
]
GenesisAccount
`json:"alloc"`
C
onfig
*
params
.
ChainConfig
`json:"config" optional:"true"`
Nonce
*
math
.
HexOrDecimal64
`json:"nonce" optional:"true"`
Timestamp
*
math
.
HexOrDecimal64
`json:"timestamp" optional:"true"`
ParentHash
*
common
.
Hash
`json:"parentHash" optional:"true"`
ExtraData
hexutil
.
Bytes
`json:"extraData" optional:"true"`
GasLimit
*
math
.
HexOrDecimal64
`json:"gasLimit"`
Difficulty
*
math
.
HexOrDecimal256
`json:"difficulty"`
Mixhash
*
common
.
Hash
`json:"mixHash" optional:"true"`
Coinbase
*
common
.
Address
`json:"coinbase" optional:"true"`
Alloc
map
[
common
.
UnprefixedAddress
]
GenesisAccount
`json:"alloc"`
}
var
dec
GenesisJSON
if
err
:=
json
.
Unmarshal
(
input
,
&
dec
);
err
!=
nil
{
return
err
}
var
x
Genesis
if
dec
.
C
hainC
onfig
!=
nil
{
x
.
Config
=
dec
.
C
hainC
onfig
if
dec
.
Config
!=
nil
{
x
.
Config
=
dec
.
Config
}
if
dec
.
Nonce
!=
nil
{
x
.
Nonce
=
uint64
(
*
dec
.
Nonce
)
...
...
core/gen_genesis_account.go
View file @
16afb5c4
//
generated by github.com/fjl/gencodec, do not edit
.
//
Code generated by github.com/fjl/gencodec. DO NOT EDIT
.
package
core
...
...
@@ -12,31 +12,27 @@ import (
"github.com/ethereum/go-ethereum/common/math"
)
func
(
g
*
GenesisAccount
)
MarshalJSON
()
([]
byte
,
error
)
{
func
(
g
GenesisAccount
)
MarshalJSON
()
([]
byte
,
error
)
{
type
GenesisAccountJSON
struct
{
Code
hexutil
.
Bytes
`json:"code" optional:"true"`
Storage
map
[
common
.
Hash
]
common
.
Hash
`json:"storage" optional:"true"`
Code
hexutil
.
Bytes
`json:"code
,omitempty
" optional:"true"`
Storage
map
[
common
.
Hash
]
common
.
Hash
`json:"storage
,omitempty
" optional:"true"`
Balance
*
math
.
HexOrDecimal256
`json:"balance"`
Nonce
*
math
.
HexOrDecimal64
`json:"nonce
" optional:"true"`
Nonce
math
.
HexOrDecimal64
`json:"nonce,omitempty
" optional:"true"`
}
var
enc
GenesisAccountJSON
if
g
.
Code
!=
nil
{
enc
.
Code
=
g
.
Code
}
if
g
.
Storage
!=
nil
{
enc
.
Storage
=
g
.
Storage
}
enc
.
Code
=
g
.
Code
enc
.
Storage
=
g
.
Storage
enc
.
Balance
=
(
*
math
.
HexOrDecimal256
)(
g
.
Balance
)
enc
.
Nonce
=
(
*
math
.
HexOrDecimal64
)(
&
g
.
Nonce
)
enc
.
Nonce
=
math
.
HexOrDecimal64
(
g
.
Nonce
)
return
json
.
Marshal
(
&
enc
)
}
func
(
g
*
GenesisAccount
)
UnmarshalJSON
(
input
[]
byte
)
error
{
type
GenesisAccountJSON
struct
{
Code
hexutil
.
Bytes
`json:"code" optional:"true"`
Storage
map
[
common
.
Hash
]
common
.
Hash
`json:"storage" optional:"true"`
Code
hexutil
.
Bytes
`json:"code
,omitempty
" optional:"true"`
Storage
map
[
common
.
Hash
]
common
.
Hash
`json:"storage
,omitempty
" optional:"true"`
Balance
*
math
.
HexOrDecimal256
`json:"balance"`
Nonce
*
math
.
HexOrDecimal64
`json:"nonce" optional:"true"`
Nonce
*
math
.
HexOrDecimal64
`json:"nonce
,omitempty
" optional:"true"`
}
var
dec
GenesisAccountJSON
if
err
:=
json
.
Unmarshal
(
input
,
&
dec
);
err
!=
nil
{
...
...
core/genesis.go
View file @
16afb5c4
...
...
@@ -58,10 +58,10 @@ type GenesisAlloc map[common.Address]GenesisAccount
// GenesisAccount is an account in the state of the genesis block.
type
GenesisAccount
struct
{
Code
[]
byte
`json:"code" optional:"true"`
Storage
map
[
common
.
Hash
]
common
.
Hash
`json:"storage" optional:"true"`
Code
[]
byte
`json:"code
,omitempty
" optional:"true"`
Storage
map
[
common
.
Hash
]
common
.
Hash
`json:"storage
,omitempty
" optional:"true"`
Balance
*
big
.
Int
`json:"balance"`
Nonce
uint64
`json:"nonce" optional:"true"`
Nonce
uint64
`json:"nonce
,omitempty
" optional:"true"`
}
// field type overrides for gencodec
...
...
core/types/gen_header_json.go
View file @
16afb5c4
//
generated by github.com/fjl/gencodec, do not edit
.
//
Code generated by github.com/fjl/gencodec. DO NOT EDIT
.
package
types
...
...
@@ -11,40 +11,40 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
)
func
(
h
*
Header
)
MarshalJSON
()
([]
byte
,
error
)
{
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"`
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
enc
.
ParentHash
=
&
h
.
ParentHash
enc
.
UncleHash
=
&
h
.
UncleHash
enc
.
Coinbase
=
&
h
.
Coinbase
enc
.
Root
=
&
h
.
Root
enc
.
TxHash
=
&
h
.
TxHash
enc
.
ReceiptHash
=
&
h
.
ReceiptHash
enc
.
Bloom
=
&
h
.
Bloom
enc
.
ParentHash
=
h
.
ParentHash
enc
.
UncleHash
=
h
.
UncleHash
enc
.
Coinbase
=
h
.
Coinbase
enc
.
Root
=
h
.
Root
enc
.
TxHash
=
h
.
TxHash
enc
.
ReceiptHash
=
h
.
ReceiptHash
enc
.
Bloom
=
h
.
Bloom
enc
.
Difficulty
=
(
*
hexutil
.
Big
)(
h
.
Difficulty
)
enc
.
Number
=
(
*
hexutil
.
Big
)(
h
.
Number
)
enc
.
GasLimit
=
(
*
hexutil
.
Big
)(
h
.
GasLimit
)
enc
.
GasUsed
=
(
*
hexutil
.
Big
)(
h
.
GasUsed
)
enc
.
Time
=
(
*
hexutil
.
Big
)(
h
.
Time
)
enc
.
Extra
=
h
.
Extra
enc
.
MixDigest
=
&
h
.
MixDigest
enc
.
Nonce
=
&
h
.
Nonce
enc
.
MixDigest
=
h
.
MixDigest
enc
.
Nonce
=
h
.
Nonce
return
json
.
Marshal
(
&
enc
)
}
...
...
core/types/gen_log_json.go
View file @
16afb5c4
//
generated by github.com/fjl/gencodec, do not edit
.
//
Code generated by github.com/fjl/gencodec. DO NOT EDIT
.
package
types
...
...
@@ -10,28 +10,28 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
)
func
(
l
*
Log
)
MarshalJSON
()
([]
byte
,
error
)
{
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"`
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"`
}
var
enc
LogJSON
enc
.
Address
=
&
l
.
Address
enc
.
Address
=
l
.
Address
enc
.
Topics
=
l
.
Topics
enc
.
Data
=
l
.
Data
enc
.
BlockNumber
=
(
*
hexutil
.
Uint64
)(
&
l
.
BlockNumber
)
enc
.
TxHash
=
&
l
.
TxHash
enc
.
TxIndex
=
(
*
hexutil
.
Uint
)(
&
l
.
TxIndex
)
enc
.
BlockHash
=
&
l
.
BlockHash
enc
.
Index
=
(
*
hexutil
.
Uint
)(
&
l
.
Index
)
enc
.
Removed
=
&
l
.
Removed
enc
.
BlockNumber
=
hexutil
.
Uint64
(
l
.
BlockNumber
)
enc
.
TxHash
=
l
.
TxHash
enc
.
TxIndex
=
hexutil
.
Uint
(
l
.
TxIndex
)
enc
.
BlockHash
=
l
.
BlockHash
enc
.
Index
=
hexutil
.
Uint
(
l
.
Index
)
enc
.
Removed
=
l
.
Removed
return
json
.
Marshal
(
&
enc
)
}
...
...
core/types/gen_receipt_json.go
View file @
16afb5c4
//
generated by github.com/fjl/gencodec, do not edit
.
//
Code generated by github.com/fjl/gencodec. DO NOT EDIT
.
package
types
...
...
@@ -11,23 +11,23 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
)
func
(
r
*
Receipt
)
MarshalJSON
()
([]
byte
,
error
)
{
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"`
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"`
}
var
enc
ReceiptJSON
enc
.
PostState
=
r
.
PostState
enc
.
CumulativeGasUsed
=
(
*
hexutil
.
Big
)(
r
.
CumulativeGasUsed
)
enc
.
Bloom
=
&
r
.
Bloom
enc
.
Bloom
=
r
.
Bloom
enc
.
Logs
=
r
.
Logs
enc
.
TxHash
=
&
r
.
TxHash
enc
.
ContractAddress
=
&
r
.
ContractAddress
enc
.
TxHash
=
r
.
TxHash
enc
.
ContractAddress
=
r
.
ContractAddress
enc
.
GasUsed
=
(
*
hexutil
.
Big
)(
r
.
GasUsed
)
return
json
.
Marshal
(
&
enc
)
}
...
...
core/types/gen_tx_json.go
View file @
16afb5c4
//
generated by github.com/fjl/gencodec, do not edit
.
//
Code generated by github.com/fjl/gencodec. DO NOT EDIT
.
package
types
...
...
@@ -11,9 +11,9 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
)
func
(
t
*
txdata
)
MarshalJSON
()
([]
byte
,
error
)
{
func
(
t
txdata
)
MarshalJSON
()
([]
byte
,
error
)
{
type
txdataJSON
struct
{
AccountNonce
*
hexutil
.
Uint64
`json:"nonce"`
AccountNonce
hexutil
.
Uint64
`json:"nonce"`
Price
*
hexutil
.
Big
`json:"gasPrice"`
GasLimit
*
hexutil
.
Big
`json:"gasLimit"`
Recipient
*
common
.
Address
`json:"to" optional:"yes" rlp:"nil"`
...
...
@@ -25,7 +25,7 @@ func (t *txdata) MarshalJSON() ([]byte, error) {
Hash
*
common
.
Hash
`json:"hash" optional:"yes" rlp:"-"`
}
var
enc
txdataJSON
enc
.
AccountNonce
=
(
*
hexutil
.
Uint64
)(
&
t
.
AccountNonce
)
enc
.
AccountNonce
=
hexutil
.
Uint64
(
t
.
AccountNonce
)
enc
.
Price
=
(
*
hexutil
.
Big
)(
t
.
Price
)
enc
.
GasLimit
=
(
*
hexutil
.
Big
)(
t
.
GasLimit
)
enc
.
Recipient
=
t
.
Recipient
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment