Skip to content

Commit 53192d9

Browse files
committed
fix: linter issues
1 parent 27539aa commit 53192d9

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

coinbase_placeholder.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func generateCoinbasePlaceholderTx() *bt.Tx {
3232
tx := bt.NewTx()
3333
tx.Version = 0xFFFFFFFF
3434
tx.LockTime = 0xFFFFFFFF
35+
3536
return tx
3637
}
3738

@@ -40,5 +41,6 @@ func IsCoinbasePlaceHolderTx(tx *bt.Tx) bool {
4041
coinbasePlaceholderTx := generateCoinbasePlaceholderTx()
4142

4243
coinbasePlaceholderTxHash := coinbasePlaceholderTx.TxIDChainHash()
44+
4345
return tx.TxIDChainHash().IsEqual(coinbasePlaceholderTxHash)
4446
}

inpoints.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ func (p *TxInpoints) String() string {
7676

7777
func (p *TxInpoints) addTx(tx *bt.Tx) {
7878
// Do not error out for transactions without inputs, seeded Teranodes will have txs without inputs
79-
8079
for _, input := range tx.Inputs {
8180
hash := *input.PreviousTxIDChainHash()
8281

merkle_tree.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func BuildMerkleTreeStoreFromBytes(nodes []SubtreeNode) (*[]chainhash.Hash, erro
7575

7676
go func(i int) {
7777
defer wg.Done()
78+
7879
calcMerkles(nodes, i, Min(i+routineSplitSize, merkleTo), nextPoT, length, merkles)
7980
}(i)
8081
}

subtree.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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
5254
func 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 {
705707
func (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
}

subtree_benchmark_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func BenchmarkSubtree_Serialize(b *testing.B) {
4141
// int to bytes
4242
var bb [32]byte
4343

44-
binary.LittleEndian.PutUint32(bb[:], uint32(i))
44+
binary.LittleEndian.PutUint32(bb[:], uint32(i)) //nolint:gosec // G115: integer overflow conversion int -> uint32
4545
_ = st.AddNode(*(*chainhash.Hash)(&bb), 111, 234)
4646
}
4747

@@ -60,7 +60,7 @@ func BenchmarkSubtree_SerializeNodes(b *testing.B) {
6060
// int to bytes
6161
var bb [32]byte
6262

63-
binary.LittleEndian.PutUint32(bb[:], uint32(i))
63+
binary.LittleEndian.PutUint32(bb[:], uint32(i)) //nolint:gosec // G115: integer overflow conversion int -> uint32
6464
_ = st.AddNode(*(*chainhash.Hash)(&bb), 111, 234)
6565
}
6666

0 commit comments

Comments
 (0)