util

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const EPOCH_LOCK = "epoch.lock"

Constants

View Source
const ETHASHPROOF_CACHE = ".ethashproof"
View Source
const GETBLOCK = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\": [\"0x%x\", false],\"id\":1}\n"

The post api of fetching eth header

View Source
const GETBLOCK_BYHASH = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByHash\",\"params\": [\"%s\", false],\"id\":1}\n"

Variables

This section is empty.

Functions

func Assert

func Assert(err error)

Assert error and exit process

func Filter added in v0.1.1

func Filter(vs []string, f func(int, string) bool) []string

Filter string array

func Header(block interface{}, api string) (types.Header, error)

Get ethereum header by block number

func Map added in v0.1.1

func Map(vs []string, f func(int, string) string) []string

Map string array

func RootDir added in v0.1.2

func RootDir() (string, error)

Get darwinia config root directory

Types

type Config

type Config struct {
	Api     string `json:"api"`
	Genesis uint64 `json:"genesis"`
	Root    string `json:"root"`
}

func (*Config) CheckLock added in v0.1.2

func (c *Config) CheckLock(filename string) bool

Common load config

func (*Config) CreateLock added in v0.1.2

func (c *Config) CreateLock(filename string, ctx []byte) error

Common load config

func (*Config) Load added in v0.1.2

func (c *Config) Load() error

Common load config

func (*Config) RemoveLock added in v0.1.2

func (c *Config) RemoveLock(filename string) error

Common load config

type DarwiniaEthHeader added in v0.1.1

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 added in v0.1.1

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

Convert EthHeader to Darwinia Eth Block

func (*DarwiniaEthHeader) HexFormat added in v0.1.1

type DarwiniaEthHeaderHexFormat added in v0.1.1

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 added in v0.1.1

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

Final outputs of ethashproof

type InfuraResponse

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

The response of etherscan api

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 Config) (ProofOutput, error)

Proof eth blockheader

func (*ProofOutput) Format added in v0.1.1

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

Format ProofOutput to double node with merkle proofs

type RawConfig

type RawConfig struct {
	Eth Config `json:"eth"`
}

Jump to

Keyboard shortcuts

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