From e697129aa06972542cd4e88e89ceb4cfae19c211 Mon Sep 17 00:00:00 2001 From: Christopher Tarry Date: Fri, 19 Apr 2024 14:24:25 -0400 Subject: [PATCH] linter fixes --- explorer/update.go | 7 ++++++- persist/sqlite/consensus.go | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/explorer/update.go b/explorer/update.go index dc0d9ffb..4abaa17b 100644 --- a/explorer/update.go +++ b/explorer/update.go @@ -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 diff --git a/persist/sqlite/consensus.go b/persist/sqlite/consensus.go index d982c28c..fc148203 100644 --- a/persist/sqlite/consensus.go +++ b/persist/sqlite/consensus.go @@ -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") } @@ -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") } @@ -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 }