utils

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Copyright (c) 2018 Clearmatics Technologies Ltd

Copyright (c) 2018 Clearmatics Technologies Ltd

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockNumberByTransactionHash

func BlockNumberByTransactionHash(ctx context.Context, c *rpc.Client, txHash common.Hash) (*string, *types.Transaction, error)

BlockNumberByTransactionHash gets a block number by a transaction hash in that block

func Client

func Client(url string) *ethclient.Client

Client gets client or fails if no connection

func ClientRPC

func ClientRPC(url string) *rpc.Client

ClientRPC RPC Client gets an RPC client (useful to get the block number out of a transaction)

func ConvertAndAppend

func ConvertAndAppend(c *ishell.Context, input string, argument *abi.Argument, output []interface{}) ([]interface{}, error)

func ConvertToBool

func ConvertToBool(value string) (bool, error)

MUST CHECK RETURNED ERROR ELSE WILL RETURN FALSE FOR ANY ERRONEOUS INPUT

func ConvertToInt

func ConvertToInt(signed bool, size int, value string) (interface{}, error)

func ConvertToType

func ConvertToType(str string, typ *abi.Type) (interface{}, error)

func EncodeBlock

func EncodeBlock(blockInterface interface{}) (h []byte)

Encodes a block

func EncodeExtraData

func EncodeExtraData(blockHeader Header) (prefix []byte)

EncodeExtraData calculate prefix of the extraData with the signature

func EncodePrefix

func EncodePrefix(blockHeader Header) (prefix []byte)

EncodePrefix calculate prefix of the entire signed block

func GenerateInterface

func GenerateInterface(blockHeader Header) (rest interface{})

GenerateInterface Creates an interface for a block

func GenerateProof

func GenerateProof(ctx context.Context, client *rpc.Client, txHash common.Hash) (txTriggerPath []byte, txTriggerRLP []byte, txTriggerProofArr []byte, receiptTrigger []byte, receiptTriggerProofArr []byte)

func GetBlockTxReceipts

func GetBlockTxReceipts(ec *ethclient.Client, block *types.Block) []*types.Receipt

GetBlockTxReceipts get the receipts for all the transactions in a block

func GetNonce

func GetNonce(client *ethclient.Client, auth *bind.TransactOpts)

func Proof

func Proof(trie *trie.Trie, path []byte) []byte

Proof creates an array of the proof pathj ordered

func ReceiptTrie

func ReceiptTrie(receipts []*types.Receipt) *trie.Trie

ReceiptTrie generate trie for receipts TODO: the argument should be of type interface so that this is a generic function

func StringToBytes32

func StringToBytes32(input string) (output [32]byte, err error)

Needed to convert transaction strings into the correct format

func TxTrie

func TxTrie(transactions []*types.Transaction) *trie.Trie

TxTrie generated Trie out of transaction array TODO: the argument should be of type interface so that this is a generic function

Types

type Header struct {
	ParentHash  string `json:"parentHash"`
	UncleHash   string `json:"sha3Uncles"`
	Coinbase    string `json:"miner"`
	Root        string `json:"stateRoot"`
	TxHash      string `json:"transactionsRoot"`
	ReceiptHash string `json:"receiptsRoot"`
	Bloom       string `json:"logsBloom"`
	Difficulty  string `json:"difficulty"`
	Number      string `json:"number"`
	GasLimit    string `json:"gasLimit"`
	GasUsed     string `json:"gasUsed"`
	Time        string `json:"timestamp"`
	Extra       string `json:"extraData"`
	MixDigest   string `json:"mixHash"`
	Nonce       string `json:"nonce"`
}

Header used to marshall blocks into a string based struct

Jump to

Keyboard shortcuts

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