From 471c04cb50ac24c9347d260fdfc5af28746b545f Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Tue, 14 Feb 2023 08:15:14 +0100 Subject: [PATCH] fix: stateless PoA stem insertion in TreeFromProof --- hashednode.go | 4 +++- stateless.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hashednode.go b/hashednode.go index 3851197a..062bb577 100644 --- a/hashednode.go +++ b/hashednode.go @@ -30,6 +30,8 @@ import ( "fmt" ) +var ErrReadFromHashedNode = errors.New("can not read from a hash node") + type HashedNode struct { commitment []byte cachedPoint *Point @@ -48,7 +50,7 @@ func (*HashedNode) Delete([]byte, NodeResolverFn) error { } func (*HashedNode) Get([]byte, NodeResolverFn) ([]byte, error) { - return nil, errors.New("can not read from a hash node") + return nil, ErrReadFromHashedNode } func (n *HashedNode) Commit() *Point { diff --git a/stateless.go b/stateless.go index d99fe873..29a78f4b 100644 --- a/stateless.go +++ b/stateless.go @@ -340,6 +340,9 @@ func (n *StatelessNode) insertStem(path []byte, stemInfo stemInfo, comms []*Poin // nothing to do case extStatusAbsentOther: // insert poa stem + serialized := comms[0].Bytes() + n.children[path[0]] = &HashedNode{commitment: serialized[:], cachedPoint: comms[0]} + comms = comms[1:] case extStatusPresent: // insert stem newchild := NewStatelessWithCommitment(comms[0])