From 6ebbe31a632c0fbc19af95c7e136c88c2cb29f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Levente=20T=C3=B3th?= Date: Mon, 18 Sep 2023 17:12:38 +0200 Subject: [PATCH] fix: bmt --- pkg/bmt/bmt.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/bmt/bmt.go b/pkg/bmt/bmt.go index e13aa3ec1cb..38c0e8bff5f 100644 --- a/pkg/bmt/bmt.go +++ b/pkg/bmt/bmt.go @@ -40,6 +40,19 @@ type Hasher struct { span []byte // The span of the data subsumed under the chunk } +// facade +func NewHasher(hasherFact func() hash.Hash) *Hasher { + conf := NewConf(hasherFact, swarm.BmtBranches, 32) + + return &Hasher{ + Conf: conf, + result: make(chan []byte), + errc: make(chan error, 1), + span: make([]byte, SpanSize), + bmt: newTree(conf.segmentSize, conf.maxSize, conf.depth, conf.hasher), + } +} + // Capacity returns the maximum amount of bytes that will be processed by this hasher implementation. // since BMT assumes a balanced binary tree, capacity it is always a power of 2 func (h *Hasher) Capacity() int {