Documentation
¶
Overview ¶
Copyright (C) 2018 go-cloudcard authors
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-cloudcard authors ¶
This file is part of the go-cloudcard library.
the go-cloudcard library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
the go-cloudcard library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-cloudcard library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Variables
- func HashDomains(domains ...string) []byte
- func HashDomainsPrefix(domains ...string) []byte
- type Action
- type Entry
- type Iterator
- type IteratorState
- type MerkleProof
- type Trie
- func (t *Trie) Clone() (*Trie, error)
- func (t *Trie) CopyTo(storage cdb.Storage, needChangelog bool) (*Trie, error)
- func (t *Trie) Del(key []byte) ([]byte, error)
- func (t *Trie) Empty() bool
- func (t *Trie) Get(key []byte) ([]byte, error)
- func (t *Trie) Iterator(prefix []byte) (*Iterator, error)
- func (t *Trie) Prove(key []byte) (MerkleProof, error)
- func (t *Trie) Put(key []byte, val []byte) ([]byte, error)
- func (t *Trie) Replay(ft *Trie) ([]byte, error)
- func (t *Trie) RootHash() []byte
- func (t *Trie) Verify(rootHash []byte, key []byte, proof MerkleProof) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = cdb.ErrKeyNotFound ErrInvalidProtoToNode = errors.New("Pb Message cannot be converted into Trie Node") )
Errors
var (
ErrNotIterable = errors.New("leaf node is not iterable")
)
errors constants
Functions ¶
func HashDomains ¶
HashDomains for each variable in contract each domain will represented as 6 bytes, support 4 level domain at most such as, 4a56b7 000000 000000 000000, 4a56b8 1c9812 000000 000000, 4a56b8 3a1289 000000 000000, support iterator with same prefix
func HashDomainsPrefix ¶
HashDomainsPrefix is same as HashDomains, but without tail zeros
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry in log, [key, old value, new value]
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator to traverse leaf node in a trie
type IteratorState ¶
type IteratorState struct {
// contains filtered or unexported fields
}
IteratorState represents the intermediate statue in iterator
type MerkleProof ¶
type MerkleProof [][][]byte
MerkleProof is a path from root to the proved node every element in path is the value of a node
type Trie ¶
type Trie struct {
// contains filtered or unexported fields
}
Trie is a Merkle Patricia Trie, consists of three kinds of nodes, Branch Node: 16-elements array, value is [hash_0, hash_1, ..., hash_f, hash] Extension Node: 3-elements array, value is [ext flag, prefix path, next hash] Leaf Node: 3-elements array, value is [leaf flag, suffix path, value]
func (*Trie) Del ¶
Del the node's value in trie
ext(ext->leaf-->leaf,ext->ext--->ext)
branch(branch->leaf-->leaf,branch->branch-->ext->branch,branch->ext-->ext)
ext ext | | branch --> leaf --> leaf / \
[leaf] leaf
branch ext / \ |
[leaf] ext --> branch
| branch branch ext / \ |
[leaf] branch --> branch
/ \ / \ leaf leaf leaf leaf
func (*Trie) Prove ¶
func (t *Trie) Prove(key []byte) (MerkleProof, error)
Prove the associated node to the key exists in trie if exists, MerkleProof is a complete path from root to the node otherwise, MerkleProof is nil