// AddLeaf ads a new leaf to the hash tree. Stores the hash of the leaf data in // the tree structure, does not store the data itself. // Returns the position of the leaf in the tree. func (m *CPPMerkleTree) AddLeaf(leaf []byte) uint64 { var leafPtr unsafe.Pointer // Don't flake out if we're passed an empty leaf slice. // We'll end up passing nullptr to the C++ code, but that's fine since we'll // also be passing a size of 0. if len(leaf) > 0 { leafPtr = unsafe.Pointer(&leaf[0]) } return uint64(C.AddLeaf(m.peer, leafPtr, C.size_t(len(leaf)))) }
func (m *CPPMerkleTree) AddLeaf(leaf []byte) uint64 { return uint64(C.AddLeaf(m.peer, C.BYTE_SLICE(&leaf))) }