ipld

package
v0.7.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RawBinary           = 0x55
	MEthHeader          = 0x90
	MEthHeaderList      = 0x91
	MEthTxTrie          = 0x92
	MEthTx              = 0x93
	MEthTxReceiptTrie   = 0x94
	MEthTxReceipt       = 0x95
	MEthStateTrie       = 0x96
	MEthAccountSnapshot = 0x97
	MEthStorageTrie     = 0x98
)

IPLD Codecs for Ethereum See the authoritative document: https://github.com/multiformats/multicodec/blob/master/table.csv

Variables

This section is empty.

Functions

func FromBlockAndReceipts

func FromBlockAndReceipts(block *types.Block, receipts []*types.Receipt) (*EthHeader, []*EthHeader, []*EthTx, []*EthTxTrie, []*EthReceipt, []*EthRctTrie, error)

FromBlockAndReceipts takes a block and processes it to return it a set of IPLD nodes for further processing.

func RawdataToCid

func RawdataToCid(codec uint64, rawdata []byte, multiHash uint64) (cid.Cid, error)

RawdataToCid takes the desired codec and a slice of bytes and returns the proper cid of the object.

Types

type EthAccount

type EthAccount struct {
	Nonce    uint64
	Balance  *big.Int
	Root     []byte // This is the storage root trie
	CodeHash []byte // This is the hash of the EVM code
}

EthAccount is the building block of EthAccountSnapshot. Or, is the former stripped of its cid and rawdata components.

type EthAccountSnapshot

type EthAccountSnapshot struct {
	*EthAccount
	// contains filtered or unexported fields
}

EthAccountSnapshot (eth-account-snapshot codec 0x97) represents an ethereum account, i.e. a wallet address or a smart contract

func (*EthAccountSnapshot) Cid

func (as *EthAccountSnapshot) Cid() cid.Cid

Cid returns the cid of the transaction.

func (*EthAccountSnapshot) Copy

func (as *EthAccountSnapshot) Copy() node.Node

Copy will go away. It is here to comply with the interface.

func (as *EthAccountSnapshot) Links() []*node.Link

Links is a helper function that returns all links within this object

func (*EthAccountSnapshot) Loggable

func (as *EthAccountSnapshot) Loggable() map[string]interface{}

Loggable returns in a map the type of IPLD Link.

func (*EthAccountSnapshot) MarshalJSON

func (as *EthAccountSnapshot) MarshalJSON() ([]byte, error)

MarshalJSON processes the transaction into readable JSON format.

func (*EthAccountSnapshot) RawData

func (as *EthAccountSnapshot) RawData() []byte

RawData returns the binary of the RLP encode of the account snapshot.

func (*EthAccountSnapshot) Resolve

func (as *EthAccountSnapshot) Resolve(p []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (as *EthAccountSnapshot) ResolveLink(p []string) (*node.Link, []string, error)

ResolveLink is a helper function that calls resolve and asserts the output is a link

func (*EthAccountSnapshot) Size

func (as *EthAccountSnapshot) Size() (uint64, error)

Size will go away. It is here to comply with the interface.

func (*EthAccountSnapshot) Stat

func (as *EthAccountSnapshot) Stat() (*node.NodeStat, error)

Stat will go away. It is here to comply with the interface.

func (*EthAccountSnapshot) String

func (as *EthAccountSnapshot) String() string

String is a helper for output

func (*EthAccountSnapshot) Tree

func (as *EthAccountSnapshot) Tree(p string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

type EthHeader

type EthHeader struct {
	*types.Header
	// contains filtered or unexported fields
}

EthHeader (eth-block, codec 0x90), represents an ethereum block header

func DecodeEthHeader

func DecodeEthHeader(c cid.Cid, b []byte) (*EthHeader, error)

DecodeEthHeader takes a cid and its raw binary data from IPFS and returns an EthTx object for further processing.

func NewEthHeader

func NewEthHeader(header *types.Header) (*EthHeader, error)

NewEthHeader converts a *types.Header into an EthHeader IPLD node

func (*EthHeader) Cid

func (b *EthHeader) Cid() cid.Cid

Cid returns the cid of the block header.

func (*EthHeader) Copy

func (b *EthHeader) Copy() node.Node

Copy will go away. It is here to comply with the Node interface.

func (b *EthHeader) Links() []*node.Link

Links is a helper function that returns all links within this object HINT: Use `ipfs refs <cid>`

func (*EthHeader) Loggable

func (b *EthHeader) Loggable() map[string]interface{}

Loggable returns a map the type of IPLD Link.

func (*EthHeader) MarshalJSON

func (b *EthHeader) MarshalJSON() ([]byte, error)

MarshalJSON processes the block header into readable JSON format, converting the right links into their cids, and keeping the original hex hash, allowing the user to simplify external queries.

func (*EthHeader) RawData

func (b *EthHeader) RawData() []byte

RawData returns the binary of the RLP encode of the block header.

func (*EthHeader) Resolve

func (b *EthHeader) Resolve(p []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (b *EthHeader) ResolveLink(p []string) (*node.Link, []string, error)

ResolveLink is a helper function that allows easier traversal of links through blocks

func (*EthHeader) Size

func (b *EthHeader) Size() (uint64, error)

Size will go away. It is here to comply with the Node interface.

func (*EthHeader) Stat

func (b *EthHeader) Stat() (*node.NodeStat, error)

Stat will go away. It is here to comply with the Node interface.

func (*EthHeader) String

func (b *EthHeader) String() string

String is a helper for output

func (*EthHeader) Tree

func (b *EthHeader) Tree(p string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

type EthRctTrie

type EthRctTrie struct {
	*TrieNode
}

EthRctTrie (eth-tx-trie codec 0x92) represents a node from the transaction trie in ethereum.

func DecodeEthRctTrie

func DecodeEthRctTrie(c cid.Cid, b []byte) (*EthRctTrie, error)

DecodeEthRctTrie returns an EthRctTrie object from its cid and rawdata.

func (*EthRctTrie) Cid

func (t *EthRctTrie) Cid() cid.Cid

Cid returns the cid of the transaction.

func (*EthRctTrie) Loggable

func (t *EthRctTrie) Loggable() map[string]interface{}

Loggable returns in a map the type of IPLD Link.

func (*EthRctTrie) RawData

func (t *EthRctTrie) RawData() []byte

RawData returns the binary of the RLP encode of the transaction.

func (*EthRctTrie) String

func (t *EthRctTrie) String() string

String is a helper for output

type EthReceipt

type EthReceipt struct {
	*types.Receipt
	// contains filtered or unexported fields
}

func DecodeEthReceipt

func DecodeEthReceipt(c cid.Cid, b []byte) (*EthReceipt, error)

DecodeEthReceipt takes a cid and its raw binary data from IPFS and returns an EthTx object for further processing.

func NewReceipt

func NewReceipt(receipt *types.Receipt) (*EthReceipt, error)

NewReceipt converts a types.ReceiptForStorage to an EthReceipt IPLD node

func (*EthReceipt) Cid

func (node *EthReceipt) Cid() cid.Cid

func (*EthReceipt) Copy

func (*EthReceipt) Copy() node.Node

Copy will go away. It is here to comply with the Node interface.

func (*EthReceipt) Links() []*node.Link

Links is a helper function that returns all links within this object

func (*EthReceipt) Loggable

func (r *EthReceipt) Loggable() map[string]interface{}

Loggable returns in a map the type of IPLD Link.

func (*EthReceipt) MarshalJSON

func (r *EthReceipt) MarshalJSON() ([]byte, error)

MarshalJSON processes the receipt into readable JSON format.

func (*EthReceipt) RawData

func (node *EthReceipt) RawData() []byte

func (*EthReceipt) Resolve

func (r *EthReceipt) Resolve(p []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (r *EthReceipt) ResolveLink(p []string) (*node.Link, []string, error)

ResolveLink is a helper function that calls resolve and asserts the output is a link

func (*EthReceipt) Size

func (r *EthReceipt) Size() (uint64, error)

Size will go away. It is here to comply with the interface.

func (*EthReceipt) Stat

func (r *EthReceipt) Stat() (*node.NodeStat, error)

Stat will go away. It is here to comply with the interface.

func (*EthReceipt) String

func (r *EthReceipt) String() string

String is a helper for output

func (*EthReceipt) Tree

func (r *EthReceipt) Tree(p string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

type EthStateTrie

type EthStateTrie struct {
	*TrieNode
}

EthStateTrie (eth-state-trie, codec 0x96), represents a node from the satte trie in ethereum.

func DecodeEthStateTrie

func DecodeEthStateTrie(c cid.Cid, b []byte) (*EthStateTrie, error)

DecodeEthStateTrie returns an EthStateTrie object from its cid and rawdata.

func FromStateTrieRLP

func FromStateTrieRLP(raw []byte) (*EthStateTrie, error)

FromStateTrieRLP takes the RLP representation of an ethereum state trie node to return it as an IPLD node for further processing.

func (*EthStateTrie) Cid

func (st *EthStateTrie) Cid() cid.Cid

Cid returns the cid of the state trie node.

func (*EthStateTrie) Loggable

func (st *EthStateTrie) Loggable() map[string]interface{}

Loggable returns in a map the type of IPLD Link.

func (*EthStateTrie) RawData

func (st *EthStateTrie) RawData() []byte

RawData returns the binary of the RLP encode of the state trie node.

func (*EthStateTrie) String

func (st *EthStateTrie) String() string

String is a helper for output

type EthStorageTrie

type EthStorageTrie struct {
	*TrieNode
}

EthStorageTrie (eth-storage-trie, codec 0x98), represents a node from the storage trie in ethereum.

func DecodeEthStorageTrie

func DecodeEthStorageTrie(c cid.Cid, b []byte) (*EthStorageTrie, error)

DecodeEthStorageTrie returns an EthStorageTrie object from its cid and rawdata.

func FromStorageTrieRLP

func FromStorageTrieRLP(raw []byte) (*EthStorageTrie, error)

FromStorageTrieRLP takes the RLP representation of an ethereum storage trie node to return it as an IPLD node for further processing.

func (*EthStorageTrie) Cid

func (st *EthStorageTrie) Cid() cid.Cid

Cid returns the cid of the storage trie node.

func (*EthStorageTrie) Loggable

func (st *EthStorageTrie) Loggable() map[string]interface{}

Loggable returns in a map the type of IPLD Link.

func (*EthStorageTrie) RawData

func (st *EthStorageTrie) RawData() []byte

RawData returns the binary of the RLP encode of the storage trie node.

func (*EthStorageTrie) String

func (st *EthStorageTrie) String() string

String is a helper for output

type EthTx

type EthTx struct {
	*types.Transaction
	// contains filtered or unexported fields
}

EthTx (eth-tx codec 0x93) represents an ethereum transaction

func DecodeEthTx

func DecodeEthTx(c cid.Cid, b []byte) (*EthTx, error)

DecodeEthTx takes a cid and its raw binary data from IPFS and returns an EthTx object for further processing.

func NewEthTx

func NewEthTx(tx *types.Transaction) (*EthTx, error)

NewEthTx converts a *types.Transaction to an EthTx IPLD node

func (*EthTx) Cid

func (t *EthTx) Cid() cid.Cid

Cid returns the cid of the transaction.

func (*EthTx) Copy

func (t *EthTx) Copy() node.Node

Copy will go away. It is here to comply with the interface.

func (t *EthTx) Links() []*node.Link

Links is a helper function that returns all links within this object

func (*EthTx) Loggable

func (t *EthTx) Loggable() map[string]interface{}

Loggable returns in a map the type of IPLD Link.

func (*EthTx) MarshalJSON

func (t *EthTx) MarshalJSON() ([]byte, error)

MarshalJSON processes the transaction into readable JSON format.

func (*EthTx) RawData

func (t *EthTx) RawData() []byte

RawData returns the binary of the RLP encode of the transaction.

func (*EthTx) Resolve

func (t *EthTx) Resolve(p []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (t *EthTx) ResolveLink(p []string) (*node.Link, []string, error)

ResolveLink is a helper function that calls resolve and asserts the output is a link

func (*EthTx) Size

func (t *EthTx) Size() (uint64, error)

Size will go away. It is here to comply with the interface.

func (*EthTx) Stat

func (t *EthTx) Stat() (*node.NodeStat, error)

Stat will go away. It is here to comply with the interface.

func (*EthTx) String

func (t *EthTx) String() string

String is a helper for output

func (*EthTx) Tree

func (t *EthTx) Tree(p string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

type EthTxTrie

type EthTxTrie struct {
	*TrieNode
}

EthTxTrie (eth-tx-trie codec 0x92) represents a node from the transaction trie in ethereum.

func DecodeEthTxTrie

func DecodeEthTxTrie(c cid.Cid, b []byte) (*EthTxTrie, error)

DecodeEthTxTrie returns an EthTxTrie object from its cid and rawdata.

func (*EthTxTrie) Cid

func (t *EthTxTrie) Cid() cid.Cid

Cid returns the cid of the transaction.

func (*EthTxTrie) Loggable

func (t *EthTxTrie) Loggable() map[string]interface{}

Loggable returns in a map the type of IPLD Link.

func (*EthTxTrie) RawData

func (t *EthTxTrie) RawData() []byte

RawData returns the binary of the RLP encode of the transaction.

func (*EthTxTrie) String

func (t *EthTxTrie) String() string

String is a helper for output

type TrieNode

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

TrieNode is the general abstraction for ethereum IPLD trie nodes.

func (*TrieNode) Copy

func (t *TrieNode) Copy() node.Node

Copy will go away. It is here to comply with the interface.

func (t *TrieNode) Links() []*node.Link

Links is a helper function that returns all links within this object

func (*TrieNode) MarshalJSON

func (t *TrieNode) MarshalJSON() ([]byte, error)

MarshalJSON processes the transaction trie into readable JSON format.

func (*TrieNode) Resolve

func (t *TrieNode) Resolve(p []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (t *TrieNode) ResolveLink(p []string) (*node.Link, []string, error)

ResolveLink is a helper function that calls resolve and asserts the output is a link

func (*TrieNode) Size

func (t *TrieNode) Size() (uint64, error)

Size will go away. It is here to comply with the interface.

func (*TrieNode) Stat

func (t *TrieNode) Stat() (*node.NodeStat, error)

Stat will go away. It is here to comply with the interface.

func (*TrieNode) Tree

func (t *TrieNode) Tree(p string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

Jump to

Keyboard shortcuts

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