Documentation ¶
Index ¶
- Variables
- func Hash(node Node) []byte
- func IsEmptyNode(node Node) bool
- func IsNibble(nibble byte) bool
- func Keccak256(data ...[]byte) []byte
- func PrefixMatchedLen(node1 []Nibble, node2 []Nibble) int
- func Serialize(node Node) []byte
- func ToBytes(ns []Nibble) []byte
- func VerifyProof(rootHash []byte, key []byte, proof Proof) (value []byte, err error)
- type BranchNode
- func (b BranchNode) HasValue() bool
- func (b BranchNode) Hash() []byte
- func (b BranchNode) Raw() []interface{}
- func (b *BranchNode) RemoveBranch(nibble Nibble)
- func (b *BranchNode) RemoveValue()
- func (b BranchNode) Serialize() []byte
- func (b *BranchNode) SetBranch(nibble Nibble, node Node)
- func (b *BranchNode) SetValue(value []byte)
- type ExtensionNode
- type LeafNode
- type Nibble
- type Node
- type Proof
- type ProofDB
- type Transaction
- type Trie
Constants ¶
This section is empty.
Variables ¶
var ( EmptyNodeRaw = []byte{} EmptyNodeHash, _ = hex.DecodeString("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") )
Functions ¶
func IsEmptyNode ¶
func PrefixMatchedLen ¶
[0,1,2,3], [0,1,2] => 3 [0,1,2,3], [0,1,2,3] => 4 [0,1,2,3], [0,1,2,3,4] => 4
func ToBytes ¶
ToBytes converts a slice of nibbles to a byte slice assuming the nibble slice has even number of nibbles.
func VerifyProof ¶
VerifyProof verify the proof for the given key under the given root hash using go-ethereum's VerifyProof implementation. It returns the value for the key if the proof is valid, otherwise error will be returned
Types ¶
type BranchNode ¶
func NewBranchNode ¶
func NewBranchNode() *BranchNode
func (BranchNode) HasValue ¶
func (b BranchNode) HasValue() bool
func (BranchNode) Hash ¶
func (b BranchNode) Hash() []byte
func (BranchNode) Raw ¶
func (b BranchNode) Raw() []interface{}
func (*BranchNode) RemoveBranch ¶
func (b *BranchNode) RemoveBranch(nibble Nibble)
func (*BranchNode) RemoveValue ¶
func (b *BranchNode) RemoveValue()
func (BranchNode) Serialize ¶
func (b BranchNode) Serialize() []byte
func (*BranchNode) SetBranch ¶
func (b *BranchNode) SetBranch(nibble Nibble, node Node)
func (*BranchNode) SetValue ¶
func (b *BranchNode) SetValue(value []byte)
type ExtensionNode ¶
func NewExtensionNode ¶
func NewExtensionNode(nibbles []Nibble, next Node) *ExtensionNode
func (ExtensionNode) Hash ¶
func (e ExtensionNode) Hash() []byte
func (ExtensionNode) Raw ¶
func (e ExtensionNode) Raw() []interface{}
func (ExtensionNode) Serialize ¶
func (e ExtensionNode) Serialize() []byte
type LeafNode ¶
func NewLeafNodeFromBytes ¶
func NewLeafNodeFromKeyValue ¶
func NewLeafNodeFromNibbles ¶
type Nibble ¶
type Nibble byte
func FromNibbleByte ¶
func FromNibbleBytes ¶
nibbles contain one nibble per byte
func FromString ¶
func ToPrefixed ¶
ToPrefixed add nibble prefix to a slice of nibbles to make its length even the prefix indicts whether a node is a leaf node.
type Proof ¶
type Proof interface { // Put inserts the given value into the key-value data store. Put(key []byte, value []byte) error // Delete removes the key from the key-value data store. Delete(key []byte) error // Has retrieves if a key is present in the key-value data store. Has(key []byte) (bool, error) // Get retrieves the given key if it's present in the key-value data store. Get(key []byte) ([]byte, error) Encode() [][]byte }
type ProofDB ¶
type ProofDB struct {
// contains filtered or unexported fields
}
func NewProofDB ¶
func NewProofDB() *ProofDB
type Transaction ¶
type Transaction struct { AccountNonce uint64 `json:"nonce" ` Price *big.Int `json:"gasPrice" ` GasLimit uint64 `json:"gas" ` Recipient *common.Address `json:"to" ` Amount *big.Int `json:"value" ` Payload []byte `json:"input" ` // Signature values V *big.Int `json:"v" ` R *big.Int `json:"r" ` S *big.Int `json:"s" ` }
func (Transaction) GetRLP ¶
func (t Transaction) GetRLP() ([]byte, error)
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
func (*Trie) Put ¶
Put adds a key value pair to the trie In general, the rule is: - When stopped at an EmptyNode, replace it with a new LeafNode with the remaining path. - When stopped at a LeafNode, convert it to an ExtensionNode and add a new branch and a new LeafNode. - When stopped at an ExtensionNode, convert it to another ExtensionNode with shorter path and create a new BranchNode points to the ExtensionNode.