Skip to content

Commit

Permalink
node: remove unused node GetTransaction and ListTxns methods (#5983)
Browse files Browse the repository at this point in the history
  • Loading branch information
cce authored Apr 26, 2024
1 parent 82f4cde commit adf39d2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 113 deletions.
42 changes: 0 additions & 42 deletions daemon/algod/api/server/v2/test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
Expand Down
71 changes: 0 additions & 71 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit adf39d2

Please sign in to comment.