Documentation ¶
Index ¶
- Constants
- func NewTree(name, storageDir string) (censustree.Tree, error)
- type Proof
- type Tree
- func (t *Tree) Add(index, value []byte) error
- func (t *Tree) AddBatch(indexes, values [][]byte) ([]int, error)
- func (t *Tree) CheckProof(index, value, root, mproof []byte) (bool, error)
- func (t *Tree) Close() error
- func (t *Tree) Commit() error
- func (t *Tree) Dump(root []byte) ([]byte, error)
- func (t *Tree) DumpPlain(root []byte) ([][]byte, [][]byte, error)
- func (t *Tree) GenProof(index, value []byte) ([]byte, error)
- func (t *Tree) Get(key []byte) []byte
- func (t *Tree) HashExists(hash []byte) (bool, error)
- func (t *Tree) ImportDump(data []byte) error
- func (t *Tree) Init(name, storageDir string) error
- func (t *Tree) IsPublic() bool
- func (t *Tree) LastAccess() int64
- func (t *Tree) MaxKeySize() int
- func (t *Tree) Publish()
- func (t *Tree) Root() []byte
- func (t *Tree) Size(root []byte) (int64, error)
- func (t *Tree) Snapshot(root []byte) (censustree.Tree, error)
- func (t *Tree) String() string
- func (t *Tree) UnPublish()
Constants ¶
const ( MaxKeySize = 32 MaxValueSize = 64 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Tree ¶
func (*Tree) Add ¶
Add adds a new claim to the merkle tree A claim is composed of two parts: index and value
1.index is mandatory, the data will be used for indexing the claim into to merkle tree 2.value is optional, the data will not affect the indexing
func (*Tree) AddBatch ¶
AddBatch adds a list of indexes and values. The commit to disk is executed only once. The values slince could be empty or as long as indexes.
func (*Tree) CheckProof ¶
CheckProof validates a merkle proof and its data.
func (*Tree) Dump ¶
Dump returns the whole merkle tree serialized in a format that can be used on Import. Byte seralization is performed using bare message protocol, it is a 40% size win over JSON.
func (*Tree) DumpPlain ¶
DumpPlain returns the entire list of added claims for a specific root hash. First return parametre are the indexes and second the values. If root is not specified, the last one is used.
func (*Tree) GenProof ¶
GenProof generates a merkle tree proof that can be later used on CheckProof() to validate it.
func (*Tree) HashExists ¶
HashExists checks if a hash exists as a node in the merkle tree
func (*Tree) ImportDump ¶
ImportDump imports a partial or whole tree previously exported with Dump()
func (*Tree) LastAccess ¶
LastAccess returns the last time the Tree was accessed, in the form of a unix timestamp.
func (*Tree) MaxKeySize ¶
func (*Tree) Publish ¶
func (t *Tree) Publish()
Publish makes a merkle tree available for queries. Application layer should check IsPublish() before considering the Tree available.
func (*Tree) Size ¶
Size returns the number of leaf nodes on the merkle tree. TO-DO: root is currently ignored
func (*Tree) Snapshot ¶
func (t *Tree) Snapshot(root []byte) (censustree.Tree, error)
Snapshot returns a Tree instance of a exiting merkle root. A Snapshot cannot be modified.