eth

package
v0.0.0-...-4c59aa4 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: GPL-3.0 Imports: 37 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

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 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 AncientReader

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

func NewAncientReader

func NewAncientReader(path string, name string, compression bool) *AncientReader

func (*AncientReader) Read

func (ar *AncientReader) Read(item uint64) (blob []byte, err error)

type BlockHashReader

type BlockHashReader struct {
	Head uint64
	// contains filtered or unexported fields
}

func NewBlockHashReader

func NewBlockHashReader(ar *AncientReader, dbpath string) *BlockHashReader

func (*BlockHashReader) CheckGenesis

func (bhr *BlockHashReader) CheckGenesis(genesis string) error

func (*BlockHashReader) Read

func (bhr *BlockHashReader) Read(number uint64) (blob []byte, err error)

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"`
	BaseFee          string        `json:"baseFeePerGas" rlp:"optional"`
}

func GetChainBlockInfo

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

type DoubleNodeWithMerkleProof

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

type EthashProof

type EthashProof struct {
	Epoching uint64
	// epoch=>timestamp
	SavedEpochs map[uint64]int64
	// contains filtered or unexported fields
}

func NewEthashProof

func NewEthashProof(conf *config.EthProof) *EthashProof

func (*EthashProof) GenerateEpoch

func (proof *EthashProof) GenerateEpoch(epoch uint64) error

func (*EthashProof) NotifyEpoch

func (proof *EthashProof) NotifyEpoch(blockno uint64) bool

func (*EthashProof) NotifyEpochWait

func (proof *EthashProof) NotifyEpochWait(epoch uint64) error

func (*EthashProof) Proof

func (proof *EthashProof) Proof(header *types.Header, wait bool) (*Output, []DoubleNodeWithMerkleProof, error)

func (*EthashProof) Start

func (proof *EthashProof) Start(currentEpoch uint64)

find existense of the epoch files

func (*EthashProof) Stop

func (proof *EthashProof) Stop()

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 NotifyWaitInfo

type NotifyWaitInfo struct {
	Epoch uint64
	Error chan error
}

type Output

type Output 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"`
}

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 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