eth

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2020 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GETBLOCK        = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\": [\"0x%x\", false],\"id\":1}\n"
	GETBLOCK_BYHASH = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByHash\",\"params\": [\"%s\", false],\"id\":1}\n"
	// uncle block
	GET_UNCLE_BLOCK = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleByBlockNumberAndIndex\",\"params\": [\"0x%x\", \"0x0\"],\"id\":1}\n"
)

The post api of fetching eth header

View Source
const ETHASHPROOF_CACHE = ".ethashproof"

Constants

Variables

This section is empty.

Functions

func EncodeProof

func EncodeProof(dnmp DoubleNodeWithMerkleProof) string

Encode proof to hex with exist hex

func EncodeProofArray

func EncodeProofArray(arr []DoubleNodeWithMerkleProof) string

Pack encode proof

func Epoch added in v0.2.5

func Epoch(block uint64, config *shadow.Config) (*ethashproof.DatasetMerkleTreeCache, error)

func GetReceiptRlpEncode

func GetReceiptRlpEncode(api string, tx string) (*types.Receipt, error)
func Header(api string, block uint64) (types.Header, error)

Get ethereum header by block number

func LenToHex

func LenToHex(len int) string

func RPC

func RPC(api string, method string, params interface{}) (*dto.RequestResult, error)

func RlpEncode

func RlpEncode(hexStr string) string

func UncleBlock

func UncleBlock(number uint64, api string) (types.Header, error)

Get uncle block by number

Types

type BlockResult

type BlockResult struct {
	Difficulty       string        `json:"difficulty"`
	ExtraData        string        `json:"extraData"`
	GasLimit         string        `json:"gasLimit"`
	GasUsed          string        `json:"gasUsed"`
	Hash             string        `json:"hash"`
	LogsBloom        string        `json:"logs_bloom"`
	Miner            string        `json:"miner"`
	MixHash          string        `json:"mixHash"`
	Nonce            string        `json:"nonce"`
	Number           string        `json:"number"`
	ParentHash       string        `json:"parentHash"`
	ReceiptsRoot     string        `json:"receiptsRoot"`
	Sha3Uncles       string        `json:"sha3Uncles"`
	StateRoot        string        `json:"stateRoot"`
	Timestamp        string        `json:"timestamp"`
	TotalDifficulty  string        `json:"totalDifficulty"`
	Transactions     []Transaction `json:"transactions"`
	TransactionsRoot string        `json:"transactionsRoot"`
}

func GetChainBlockInfo

func GetChainBlockInfo(api string, blockNum int64) (*BlockResult, error)

type DarwiniaEthHeader

type DarwiniaEthHeader struct {
	ParentHash       string   `json:"parent_hash"`
	TimeStamp        uint64   `json:"timestamp"`
	Number           uint64   `json:"number"`
	Author           string   `json:"author"`
	TransactionsRoot string   `json:"transactions_root"`
	UnclesHash       string   `json:"uncles_hash"`
	ExtraData        string   `json:"extra_data"`
	StateRoot        string   `json:"state_root"`
	ReceiptsRoot     string   `json:"receipts_root"`
	LogBloom         string   `json:"log_bloom"`
	GasUsed          uint64   `json:"gas_used"`
	GasLimited       uint64   `json:"gas_limit"`
	Difficulty       uint64   `json:"difficulty"`
	Seal             []string `json:"seal"`
	Hash             string   `json:"hash"`
}

Darwinia block

func IntoDarwiniaEthHeader

func IntoDarwiniaEthHeader(e *types.Header) (DarwiniaEthHeader, error)

Convert EthHeader to Darwinia Eth Block

func (*DarwiniaEthHeader) HexFormat

func (*DarwiniaEthHeader) ToString

func (d *DarwiniaEthHeader) ToString() (string, error)

type DarwiniaEthHeaderHexFormat

type DarwiniaEthHeaderHexFormat struct {
	ParentHash       string   `json:"parent_hash"`
	TimeStamp        string   `json:"timestamp"`
	Number           string   `json:"number"`
	Author           string   `json:"author"`
	TransactionsRoot string   `json:"transactions_root"`
	UnclesHash       string   `json:"uncles_hash"`
	ExtraData        string   `json:"extra_data"`
	StateRoot        string   `json:"state_root"`
	ReceiptsRoot     string   `json:"receipts_root"`
	LogBloom         string   `json:"log_bloom"`
	GasUsed          string   `json:"gas_used"`
	GasLimited       string   `json:"gas_limit"`
	Difficulty       string   `json:"difficulty"`
	Seal             []string `json:"seal"`
	Hash             string   `json:"hash"`
}

type DoubleNodeWithMerkleProof

type DoubleNodeWithMerkleProof struct {
	DagNodes []string `json:"dag_nodes"`
	Proof    []string `json:"proof"`
}

Final outputs of ethashproof

type EthHeader

type EthHeader struct {
	ParentHash      string   `json:"parent_hash"`
	Timestamp       int64    `json:"timestamp"`
	Number          int64    `json:"number"`
	Auth            string   `json:"auth"`
	TransactionRoot string   `json:"transaction_root"`
	UnclesHash      string   `json:"uncles_hash"`
	ExtraData       string   `json:"extra_data"`
	StateRoot       string   `json:"state_root"`
	ReceiptsRoot    string   `json:"receipts_root"`
	LogBloom        string   `json:"log_bloom"`
	GasUsed         string   `json:"gas_used"`
	GasLimit        string   `json:"gas_limit"`
	Difficulty      string   `json:"difficulty"`
	Seal            []string `json:"seal"`
	Hash            string   `json:"hash"`
}

type EthReceipt

type EthReceipt struct {
	GasUsed  int64           `json:"gas_used"`
	LogBloom string          `json:"log_bloom"`
	Logs     []EthReceiptLog `json:"logs"`
	Outcome  int             `json:"outcome"`
}

type EthReceiptLog

type EthReceiptLog struct {
	Address string   `json:"address"`
	Topics  []string `json:"topics"`
	Data    []byte   `json:"data"`
}

type Geth added in v0.2.1

type Geth struct {
	// contains filtered or unexported fields
}

func NewGeth added in v0.2.1

func NewGeth(datadir string) (Geth, error)

func (*Geth) HashToNumber added in v0.2.1

func (g *Geth) HashToNumber(h string) uint64

func (*Geth) Header added in v0.2.1

func (g *Geth) Header(block interface{}) *types.Header

type InfuraResponse

type InfuraResponse struct {
	JsonRPC string       `json:"jsonrpc"`
	Id      uint32       `json:"id"`
	Result  types.Header `json:"result"`
}

The response of etherscan api

type Log

type Log struct {
	Topics  []string `json:"topics"`
	Data    string   `json:"data"`
	Address string   `json:"address"`
}

type ProofOutput

type ProofOutput struct {
	HeaderRLP    string   `json:"header_rlp"`
	MerkleRoot   string   `json:"merkle_root"`
	Elements     []string `json:"elements"`
	MerkleProofs []string `json:"merkle_proofs"`
	ProofLength  uint64   `json:"proof_length"`
}

This struct is used for process interaction

func Proof

func Proof(header *types.Header, config *shadow.Config) (ProofOutput, error)

Proof eth blockheader

func (*ProofOutput) Format

func (o *ProofOutput) Format() []DoubleNodeWithMerkleProof

Format ProofOutput to double node with merkle proofs

type ProofRecord

type ProofRecord struct {
	Index      string `json:"index"`
	Proof      string `json:"proof"`
	HeaderHash string `json:"header_hash"`
}

func BuildProofRecord

func BuildProofRecord(api string, r *Receipts) (ProofRecord, string, error)

func GetReceipt

func GetReceipt(api string, tx string) (ProofRecord, string, error)

type Receipts

type Receipts struct {
	BlockNumber      string `json:"block_number"`
	Logs             []Log  `json:"logs"`
	Status           string `json:"status"`
	ChainSource      string `json:"chainSource"`
	GasUsed          string `json:"gasUsed"`
	LogsBloom        string `json:"logsBloom"`
	Solidity         bool   `json:"solidity"`
	TransactionIndex string `json:"transactionIndex"`
	BlockHash        string `json:"blockHash"`
}

func GetReceiptLog

func GetReceiptLog(tx string, api string) (*Receipts, error)

type RedeemFor

type RedeemFor struct {
	Ring    *ProofRecord `json:"ring,omitempty"`
	Kton    *ProofRecord `json:"kton,omitempty"`
	Deposit *ProofRecord `json:"deposit,omitempty"`
}

type Transaction

type Transaction struct {
	Hash  string `json:"hash"`
	From  string `json:"from"`
	Input string `json:"input"`
	To    string `json:"to"`
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL