-
Notifications
You must be signed in to change notification settings - Fork 9
/
eth.go
61 lines (54 loc) · 2.15 KB
/
eth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package types
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
clienttypes "github.com/bianjieai/tibc-go/modules/tibc/core/02-client/types"
)
//EthHeader represents a block header in the Ethereum blockchain.
type EthHeader 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 types.Bloom `json:"logsBloom" gencodec:"required"`
Difficulty *big.Int `json:"difficulty" gencodec:"required"`
Number *big.Int `json:"number" gencodec:"required"`
GasLimit uint64 `json:"gasLimit" gencodec:"required"`
GasUsed uint64 `json:"gasUsed" gencodec:"required"`
Time uint64 `json:"timestamp" gencodec:"required"`
Extra []byte `json:"extraData" gencodec:"required"`
MixDigest common.Hash `json:"mixHash"`
Nonce types.BlockNonce `json:"nonce"`
// BaseFee was added by EIP-1559 and is ignored in legacy headers.
BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"`
}
func (h EthHeader) ToHeader() Header {
return Header{
ParentHash: h.ParentHash[:],
UncleHash: h.UncleHash[:],
Coinbase: h.Coinbase[:],
Root: h.Root[:],
TxHash: h.TxHash[:],
ReceiptHash: h.ReceiptHash[:],
Bloom: h.Bloom[:],
Difficulty: h.Difficulty.String(),
Height: clienttypes.NewHeight(0, h.Number.Uint64()),
GasLimit: h.GasLimit,
GasUsed: h.GasUsed,
Time: h.Time,
Extra: h.Extra,
MixDigest: h.MixDigest[:],
Nonce: h.Nonce.Uint64(),
BaseFee: h.BaseFee.String(),
}
}
// ProofAccount ...
type ProofAccount struct {
Nonce *big.Int
Balance *big.Int
Storage common.Hash
Codehash common.Hash
}