Skip to content

Commit

Permalink
fix some lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricfung committed Nov 5, 2024
1 parent fba5024 commit c7a11d5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion common/custodian.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions common/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions common/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 0 additions & 16 deletions kernel/final.go

This file was deleted.

11 changes: 11 additions & 0 deletions kernel/self.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c7a11d5

Please sign in to comment.