github.com/ethersphere/bee/v2@v2.2.0/pkg/bmtpool/bmtpool.go (about) 1 // Copyright 2020 The Swarm Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package bmtpool provides easy access to binary 6 // merkle tree hashers managed in as a resource pool. 7 package bmtpool 8 9 import ( 10 "github.com/ethersphere/bee/v2/pkg/bmt" 11 "github.com/ethersphere/bee/v2/pkg/swarm" 12 ) 13 14 const Capacity = 32 15 16 var instance *bmt.Pool 17 18 // nolint:gochecknoinits 19 func init() { 20 instance = bmt.NewPool(bmt.NewConf(swarm.NewHasher, swarm.BmtBranches, Capacity)) 21 } 22 23 // Get a bmt Hasher instance. 24 // Instances are reset before being returned to the caller. 25 func Get() *bmt.Hasher { 26 return instance.Get() 27 } 28 29 // Put a bmt Hasher back into the pool 30 func Put(h *bmt.Hasher) { 31 instance.Put(h) 32 }