Documentation ¶
Index ¶
Constants ¶
const ( // MaxBlockSize reasonable max byte size for blocks that are checksummed for // a Node MaxBlockSize = 1024 * 16 )
Variables ¶
var ( // DefaultHashMaker is for checksum of blocks and nodes DefaultHashMaker = func() hash.Hash { return sha1.New() } )
Functions ¶
func DetermineBlockSize ¶
DetermineBlockSize returns a reasonable block size to use, based on the provided size
Types ¶
type ErrNoChecksumAvailable ¶
type ErrNoChecksumAvailable struct {
// contains filtered or unexported fields
}
ErrNoChecksumAvailable is for nodes that do not have the means to provide their checksum
func (ErrNoChecksumAvailable) Error ¶
func (err ErrNoChecksumAvailable) Error() string
Error shows the message with information on the node
type HashTreeer ¶
HashTreeer can be used as a hash.Hash but also provide access to the Merkle tree internals
func NewHash ¶
func NewHash(hm HashMaker, merkleBlockLength int) HashTreeer
NewHash provides a hash.Hash to generate a merkle.Tree checksum, given a HashMaker for the checksums of the blocks written and the blockSize of each block per node in the tree.
type Node ¶
type Node struct {
Parent, Left, Right *Node
// contains filtered or unexported fields
}
Node is a fundamental part of the tree.
func NewNode ¶
func NewNode() *Node
NewNode returns a new Node with the DefaultHashMaker for checksums
func NewNodeHash ¶
NewNodeHash returns a new Node using the provided crypto.Hash for checksums
func NewNodeHashBlock ¶
NewNodeHashBlock returns a new Node using the provided crypto.Hash, and calculates the block's checksum