Documentation
¶
Overview ¶
Package merkle provides deterministic state digests for anti-entropy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidState = errors.New("merkle: invalid canonical state frame")
Functions ¶
Types ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree stores key-to-value digests. Insert values should be canonical CRDT state bytes. Tree is safe for concurrent use, but is not a transport protocol or an authority on state validity.
func (*Tree) InsertState ¶
InsertState validates state as a complete CRDT frame envelope before hashing it. Prefer this method when roots are exchanged for anti-entropy; callers must have decoded any type-specific payload before accepting it.
func (*Tree) Root ¶
Root returns a deterministic binary Merkle root over sorted key/value digests. It caches the result for the current immutable tree generation, so repeated anti-entropy checks do not re-copy, sort, and hash unchanged state. Leaf and inner-node domain separators prevent structural ambiguity; an odd node is paired with a zero digest at that level.