Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chris124567 committed Apr 19, 2024
1 parent 54c843f commit e697129
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion explorer/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@ import (
"go.sia.tech/coreutils/chain"
)

// A ConsensusUpdate is a chain apply or revert update.
type ConsensusUpdate interface {
ForEachSiacoinElement(fn func(sce types.SiacoinElement, spent bool))
ForEachSiafundElement(fn func(sfe types.SiafundElement, spent bool))
ForEachFileContractElement(fn func(fce types.FileContractElement, rev *types.FileContractElement, resolved, valid bool))
}

// A DBFileContract represents a file contract element in the DB.
type DBFileContract struct {
ID types.FileContractID
RevisionNumber uint64
}

// An UpdateTx atomically updates the state of a store.
type UpdateTx interface {
UpdateMaturedBalances(revert bool, height uint64) error
AddSiacoinElements(bid types.BlockID, update ConsensusUpdate, spentElements, newElements []types.SiacoinElement) (map[types.SiacoinOutputID]int64, error)
AddSiafundElements(bid types.BlockID, spentElements, newElements []types.SiafundElement) (map[types.SiafundOutputID]int64, error)
AddFileContractElements(bid types.BlockID, update ConsensusUpdate) (map[DBFileContract]int64, error)

UpdateBalances(height uint64, spentSiacoinElements, newSiacoinElements []types.SiacoinElement, spentSiafundElements, newSiafundElements []types.SiafundElement) error
UpdateMaturedBalances(revert bool, height uint64) error

AddBlock(b types.Block, height uint64) error
AddMinerPayouts(bid types.BlockID, height uint64, scos []types.SiacoinOutput, dbIDs map[types.SiacoinOutputID]int64) error
AddTransactions(bid types.BlockID, txns []types.Transaction, scDBIds map[types.SiacoinOutputID]int64, sfDBIds map[types.SiafundOutputID]int64, fcDBIds map[DBFileContract]int64) error
Expand Down
6 changes: 3 additions & 3 deletions persist/sqlite/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (ut *updateTx) AddFileContracts(id int64, txn types.Transaction, fcDBIds ma
defer missedOutputsStmt.Close()

for i := range txn.FileContracts {
dbID, ok := fcDBIds[explorer.DBFileContract{txn.FileContractID(i), 0}]
dbID, ok := fcDBIds[explorer.DBFileContract{ID: txn.FileContractID(i), RevisionNumber: 0}]
if !ok {
return errors.New("addFileContracts: fcDbID not in map")
}
Expand Down Expand Up @@ -192,7 +192,7 @@ func (ut *updateTx) AddFileContractRevisions(id int64, txn types.Transaction, db

for i := range txn.FileContractRevisions {
fcr := &txn.FileContractRevisions[i]
dbID, ok := dbIDs[explorer.DBFileContract{fcr.ParentID, fcr.FileContract.RevisionNumber}]
dbID, ok := dbIDs[explorer.DBFileContract{ID: fcr.ParentID, RevisionNumber: fcr.FileContract.RevisionNumber}]
if !ok {
return errors.New("addFileContractRevisions: dbID not in map")
}
Expand Down Expand Up @@ -581,7 +581,7 @@ func (ut *updateTx) AddFileContractElements(bid types.BlockID, update explorer.C
return
}

fcDBIds[explorer.DBFileContract{types.FileContractID(fce.StateElement.ID), fc.RevisionNumber}] = dbID
fcDBIds[explorer.DBFileContract{ID: types.FileContractID(fce.StateElement.ID), RevisionNumber: fc.RevisionNumber}] = dbID
})
return fcDBIds, updateErr
}
Expand Down

0 comments on commit e697129

Please sign in to comment.