From adf39d24c322e915809adc0567f3c3c2e4100f6a Mon Sep 17 00:00:00 2001 From: cce <51567+cce@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:40:27 -0400 Subject: [PATCH] node: remove unused node GetTransaction and ListTxns methods (#5983) --- daemon/algod/api/server/v2/test/helpers.go | 42 ------------- node/node.go | 71 ---------------------- 2 files changed, 113 deletions(-) diff --git a/daemon/algod/api/server/v2/test/helpers.go b/daemon/algod/api/server/v2/test/helpers.go index 400906d299..ad028fc8ae 100644 --- a/daemon/algod/api/server/v2/test/helpers.go +++ b/daemon/algod/api/server/v2/test/helpers.go @@ -24,7 +24,6 @@ import ( "github.com/stretchr/testify/mock" - "github.com/algorand/go-algorand/agreement" "github.com/algorand/go-algorand/config" "github.com/algorand/go-algorand/crypto" v2 "github.com/algorand/go-algorand/daemon/algod/api/server/v2" @@ -36,7 +35,6 @@ import ( "github.com/algorand/go-algorand/data/bookkeeping" "github.com/algorand/go-algorand/data/transactions" "github.com/algorand/go-algorand/data/transactions/logic" - "github.com/algorand/go-algorand/ledger/ledgercore" "github.com/algorand/go-algorand/ledger/simulation" "github.com/algorand/go-algorand/logging" "github.com/algorand/go-algorand/node" @@ -95,7 +93,6 @@ type mockNode struct { err error id account.ParticipationID keys account.StateProofKeys - usertxns map[basics.Address][]node.TxnWithStatus status node.StatusReport devmode bool timestampOffset *int64 @@ -148,7 +145,6 @@ func makeMockNodeWithConfig(ledger v2.LedgerForAPI, genesisID string, nodeError genesisID: genesisID, config: cfg, err: nodeError, - usertxns: map[basics.Address][]node.TxnWithStatus{}, status: status, devmode: devMode, } @@ -199,44 +195,6 @@ func (m *mockNode) SuggestedFee() basics.MicroAlgos { func (m *mockNode) Config() config.Local { return m.config } -func (m *mockNode) Start() {} - -func (m *mockNode) ListeningAddress() (string, bool) { - return "mock listening addresses not implemented", false -} - -func (m *mockNode) Stop() {} - -func (m *mockNode) ListTxns(addr basics.Address, minRound basics.Round, maxRound basics.Round) ([]node.TxnWithStatus, error) { - txns, ok := m.usertxns[addr] - if !ok { - return nil, fmt.Errorf("no txns for %s", addr) - } - - return txns, nil -} - -func (m *mockNode) GetTransaction(addr basics.Address, txID transactions.Txid, minRound basics.Round, maxRound basics.Round) (node.TxnWithStatus, bool) { - return node.TxnWithStatus{}, false -} - -func (m *mockNode) IsArchival() bool { - return false -} - -func (m *mockNode) OnNewBlock(block bookkeeping.Block, delta ledgercore.StateDelta) {} - -func (m *mockNode) Uint64() uint64 { - return 1 -} - -func (m *mockNode) GetTransactionByID(txid transactions.Txid, rnd basics.Round) (node.TxnWithStatus, error) { - return node.TxnWithStatus{}, fmt.Errorf("get transaction by id not implemented") -} - -func (m *mockNode) AssembleBlock(round basics.Round) (agreement.ValidatedBlock, error) { - return nil, fmt.Errorf("assemble block not implemented") -} func (m *mockNode) StartCatchup(catchpoint string) error { return m.err diff --git a/node/node.go b/node/node.go index 88766877dc..acf204facf 100644 --- a/node/node.go +++ b/node/node.go @@ -576,58 +576,6 @@ func (node *AlgorandFullNode) Simulate(request simulation.Request) (result simul return simulator.Simulate(request) } -// ListTxns returns SignedTxns associated with a specific account in a range of Rounds (inclusive). -// TxnWithStatus returns the round in which a particular transaction appeared, -// since that information is not part of the SignedTxn itself. -func (node *AlgorandFullNode) ListTxns(addr basics.Address, minRound basics.Round, maxRound basics.Round) ([]TxnWithStatus, error) { - result := make([]TxnWithStatus, 0) - for r := minRound; r <= maxRound; r++ { - h, err := node.ledger.AddressTxns(addr, r) - if err != nil { - return nil, err - } - for _, tx := range h { - result = append(result, TxnWithStatus{ - Txn: tx.SignedTxn, - ConfirmedRound: r, - ApplyData: tx.ApplyData, - }) - } - } - return result, nil -} - -// GetTransaction looks for the required txID within with a specific account within a range of rounds (inclusive) and -// returns the SignedTxn and true iff it finds the transaction. -func (node *AlgorandFullNode) GetTransaction(addr basics.Address, txID transactions.Txid, minRound basics.Round, maxRound basics.Round) (TxnWithStatus, bool) { - // start with the most recent round, and work backwards: - // this will abort early if it hits pruned rounds - if maxRound < minRound { - return TxnWithStatus{}, false - } - r := maxRound - for { - h, err := node.ledger.AddressTxns(addr, r) - if err != nil { - return TxnWithStatus{}, false - } - for _, tx := range h { - if tx.ID() == txID { - return TxnWithStatus{ - Txn: tx.SignedTxn, - ConfirmedRound: r, - ApplyData: tx.ApplyData, - }, true - } - } - if r == minRound { - break - } - r-- - } - return TxnWithStatus{}, false -} - // GetPendingTransaction looks for the required txID in the recent ledger // blocks, in the txpool, and in the txpool's status cache. It returns // the SignedTxn (with status information), and a bool to indicate if the @@ -1079,11 +1027,6 @@ func (node *AlgorandFullNode) txPoolGaugeThread(done <-chan struct{}) { } } -// IsArchival returns true the node is an archival node, false otherwise -func (node *AlgorandFullNode) IsArchival() bool { - return node.config.Archival -} - // OnNewBlock implements the BlockListener interface so we're notified after each block is written to the ledger func (node *AlgorandFullNode) OnNewBlock(block bookkeeping.Block, delta ledgercore.StateDelta) { if node.ledger.Latest() > block.Round() { @@ -1159,20 +1102,6 @@ func (node *AlgorandFullNode) Uint64() uint64 { return crypto.RandUint64() } -// GetTransactionByID gets transaction by ID -// this function is intended to be called externally via the REST api interface. -func (node *AlgorandFullNode) GetTransactionByID(txid transactions.Txid, rnd basics.Round) (TxnWithStatus, error) { - stx, _, err := node.ledger.LookupTxid(txid, rnd) - if err != nil { - return TxnWithStatus{}, err - } - return TxnWithStatus{ - Txn: stx.SignedTxn, - ConfirmedRound: rnd, - ApplyData: stx.ApplyData, - }, nil -} - // StartCatchup starts the catchpoint mode and attempt to get to the provided catchpoint // this function is intended to be called externally via the REST api interface. func (node *AlgorandFullNode) StartCatchup(catchpoint string) error {