@@ -29,10 +29,12 @@ type Subtree struct {
2929 ConflictingNodes []chainhash.Hash // conflicting nodes need to be checked when doing block assembly
3030
3131 // temporary (calculated) variables
32- rootHash * chainhash.Hash
33- treeSize int
34- feeBytes []byte
35- feeHashBytes []byte
32+ rootHash * chainhash.Hash
33+ treeSize int
34+
35+ //feeBytes []byte // unused, but kept for reference
36+
37+ //feeHashBytes []byte // unused, but kept for reference
3638
3739 mu sync.RWMutex // protects Nodes slice
3840 nodeIndex map [chainhash.Hash ]int // maps txid to index in Nodes slice
@@ -48,7 +50,7 @@ type TxMap interface {
4850
4951// NewTree creates a new Subtree with a fixed height
5052//
51- // height is the number if levels in a merkle tree of the subtree
53+ // is the number if levels in a merkle tree of the subtree
5254func NewTree (height int ) (* Subtree , error ) {
5355 if height < 0 {
5456 return nil , fmt .Errorf ("height must be at least 0" )
@@ -129,7 +131,7 @@ func DeserializeNodesFromReader(reader io.Reader) (subtreeBytes []byte, err erro
129131 }
130132
131133 numLeaves := binary .LittleEndian .Uint64 (byteBuffer [chainhash .HashSize + 16 : chainhash .HashSize + 24 ])
132- subtreeBytes = make ([]byte , chainhash .HashSize * int (numLeaves ))
134+ subtreeBytes = make ([]byte , chainhash .HashSize * int (numLeaves )) //nolint:gosec // G115: integer overflow conversion
133135
134136 byteBuffer = byteBuffer [8 :] // reduce read byteBuffer size by 8
135137 for i := uint64 (0 ); i < numLeaves ; i ++ {
@@ -413,7 +415,7 @@ func (st *Subtree) GetMap() (TxMap, error) {
413415
414416 m := txmap .NewSwissMapUint64 (lengthUint32 )
415417 for idx , node := range st .Nodes {
416- _ = m .Put (node .Hash , uint64 (idx ))
418+ _ = m .Put (node .Hash , uint64 (idx )) //nolint:gosec // G115: integer overflow conversion int -> uint32
417419 }
418420
419421 return m , nil
@@ -679,7 +681,7 @@ func (st *Subtree) deserializeNodes(buf *bufio.Reader) error {
679681
680682 numLeaves := binary .LittleEndian .Uint64 (bytes8 )
681683
682- st .treeSize = int (numLeaves )
684+ st .treeSize = int (numLeaves ) //nolint:gosec // G115: integer overflow conversion int -> uint32
683685 // the height of a subtree is always a power of two
684686 st .Height = int (math .Ceil (math .Log2 (float64 (numLeaves ))))
685687
@@ -705,7 +707,7 @@ func (st *Subtree) deserializeNodes(buf *bufio.Reader) error {
705707func (st * Subtree ) deserializeConflictingNodes (buf * bufio.Reader ) error {
706708 bytes8 := make ([]byte , 8 )
707709
708- // read number of conflicting nodes
710+ // read the number of conflicting nodes
709711 if n , err := buf .Read (bytes8 ); err != nil || n != 8 {
710712 // if _, err = io.ReadFull(buf, bytes8); err != nil {
711713 return fmt .Errorf ("unable to read number of conflicting nodes: %w" , err )
@@ -771,7 +773,7 @@ func DeserializeSubtreeConflictingFromReader(reader io.Reader) (conflictingNodes
771773
772774 _ , _ = buf .Discard (48 * numLeavesInt )
773775
774- // read number of conflicting nodes
776+ // read the number of conflicting nodes
775777 if _ , err = io .ReadFull (buf , bytes8 ); err != nil {
776778 return nil , fmt .Errorf ("unable to read number of conflicting nodes: %w" , err )
777779 }
0 commit comments