From c7a11d5508a60c0a40242ea9f7c49adde65a8efe Mon Sep 17 00:00:00 2001 From: Cedric Fung Date: Tue, 5 Nov 2024 14:24:38 +0000 Subject: [PATCH] fix some lint warnings --- common/custodian.go | 2 +- common/encoding.go | 6 +++--- common/validation.go | 4 ++-- kernel/final.go | 16 ---------------- kernel/self.go | 11 +++++++++++ 5 files changed, 17 insertions(+), 22 deletions(-) delete mode 100644 kernel/final.go diff --git a/common/custodian.go b/common/custodian.go index 3df845a6c..37fca85c2 100644 --- a/common/custodian.go +++ b/common/custodian.go @@ -214,6 +214,6 @@ func (tx *Transaction) validateCustodianUpdateNodes(store CustodianReader, now u return nil } -func (tx *Transaction) validateCustodianSlashNodes(store DataStore) error { +func (tx *Transaction) validateCustodianSlashNodes(_ DataStore) error { return fmt.Errorf("not implemented %v", tx) } diff --git a/common/encoding.go b/common/encoding.go index 84d810705..04e20856e 100644 --- a/common/encoding.go +++ b/common/encoding.go @@ -311,7 +311,7 @@ func (enc *Encoder) EncodeAggregatedSignature(js *AggregatedSignature) { enc.WriteInt(AggregatedSignaturePrefix) enc.Write(js.Signature[:]) if len(js.Signers) == 0 { - enc.WriteByte(AggregatedSignatureOrdinaryMask) + _ = enc.WriteByte(AggregatedSignatureOrdinaryMask) enc.WriteInt(0) return } @@ -326,7 +326,7 @@ func (enc *Encoder) EncodeAggregatedSignature(js *AggregatedSignature) { max := js.Signers[len(js.Signers)-1] if max/8+1 > len(js.Signers)*2 { - enc.WriteByte(AggregatedSignatureSparseMask) + _ = enc.WriteByte(AggregatedSignatureSparseMask) enc.WriteInt(len(js.Signers)) for _, m := range js.Signers { enc.WriteInt(m) @@ -338,7 +338,7 @@ func (enc *Encoder) EncodeAggregatedSignature(js *AggregatedSignature) { for _, m := range js.Signers { masks[m/8] = masks[m/8] ^ (1 << (m % 8)) } - enc.WriteByte(AggregatedSignatureOrdinaryMask) + _ = enc.WriteByte(AggregatedSignatureOrdinaryMask) enc.WriteInt(len(masks)) enc.Write(masks) } diff --git a/common/validation.go b/common/validation.go index ffdcc692e..2f3aebdf6 100644 --- a/common/validation.go +++ b/common/validation.go @@ -208,7 +208,7 @@ func (tx *SignedTransaction) validateInputs(store UTXOLockReader, hash crypto.Ha } } - err = validateUTXO(i, &utxo.UTXO, tx.SignaturesMap, tx.AggregatedSignature, hash, txType, keySigs, len(allKeys)) + err = validateUTXO(i, &utxo.UTXO, tx.SignaturesMap, tx.AggregatedSignature, txType, keySigs, len(allKeys)) if err != nil { return inputsFilter, inputAmount, err } @@ -314,7 +314,7 @@ func (tx *Transaction) validateOutputs(store GhostLocker, hash crypto.Hash, inpu return nil } -func validateUTXO(index int, utxo *UTXO, sigs []map[uint16]*crypto.Signature, as *AggregatedSignature, msg crypto.Hash, txType uint8, keySigs map[*crypto.Key]*crypto.Signature, offset int) error { +func validateUTXO(index int, utxo *UTXO, sigs []map[uint16]*crypto.Signature, as *AggregatedSignature, txType uint8, keySigs map[*crypto.Key]*crypto.Signature, offset int) error { switch utxo.Type { case OutputTypeScript, OutputTypeNodeRemove: if as != nil { diff --git a/kernel/final.go b/kernel/final.go deleted file mode 100644 index 3091bf850..000000000 --- a/kernel/final.go +++ /dev/null @@ -1,16 +0,0 @@ -package kernel - -import ( - "github.com/MixinNetwork/mixin/common" - "github.com/MixinNetwork/mixin/crypto" -) - -func (node *Node) checkTxInStorage(id crypto.Hash) (*common.VersionedTransaction, string, error) { - tx, snap, err := node.persistStore.ReadTransaction(id) - if err != nil || tx != nil { - return tx, snap, err - } - - tx, err = node.persistStore.CacheGetTransaction(id) - return tx, "", err -} diff --git a/kernel/self.go b/kernel/self.go index ce7588eda..3f6eeb1ae 100644 --- a/kernel/self.go +++ b/kernel/self.go @@ -8,10 +8,21 @@ import ( "github.com/MixinNetwork/mixin/common" "github.com/MixinNetwork/mixin/config" + "github.com/MixinNetwork/mixin/crypto" "github.com/MixinNetwork/mixin/logger" "github.com/dgraph-io/badger/v4" ) +func (node *Node) checkTxInStorage(id crypto.Hash) (*common.VersionedTransaction, string, error) { + tx, snap, err := node.persistStore.ReadTransaction(id) + if err != nil || tx != nil { + return tx, snap, err + } + + tx, err = node.persistStore.CacheGetTransaction(id) + return tx, "", err +} + func (node *Node) validateSnapshotTransaction(s *common.Snapshot, finalized bool) (*common.VersionedTransaction, bool, error) { tx, snap, err := node.persistStore.ReadTransaction(s.SoleTransaction()) if err == nil && tx != nil {