func (m *CPPMerkleTree) LeafHash(leaf uint64) ([]byte, error) { hash := make([]byte, m.nodeSize) success := C.LeafHash(m.peer, C.BYTE_SLICE(&hash), C.size_t(leaf)) if !success { return nil, fmt.Errorf("failed to get leafhash of leaf %d", leaf) } return hash, nil }
// LeafHash returns the leaf hash for the leaf at the requested index. func (m *CPPMerkleTree) LeafHash(leaf uint64) ([]byte, error) { hash := make([]byte, m.nodeSize) size := C.LeafHash(m.peer, C.size_t(leaf), unsafe.Pointer(&hash[0]), C.size_t(len(hash))) if got, want := size, m.nodeSize; got != want { return nil, fmt.Errorf("failed to get leafhash of leaf %d, got %d bytes expected %d", leaf, got, want) } return hash, nil }