Skip to content

Commit

Permalink
revert to just jasons patch
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin committed Apr 12, 2023
1 parent d010f80 commit a71ed3e
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 221 deletions.
6 changes: 0 additions & 6 deletions daemon/algod/api/algod.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1423,12 +1423,6 @@
},
{
"$ref": "#/parameters/format"
},
{
"type": "integer",
"description": "Max number of rounds to look back in case the transaction is not in pending pool.",
"name": "lookback",
"in": "query"
}
],
"responses": {
Expand Down
8 changes: 0 additions & 8 deletions daemon/algod/api/algod.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5643,14 +5643,6 @@
],
"type": "string"
}
},
{
"description": "Max number of rounds to look back in case the transaction is not in pending pool.",
"in": "query",
"name": "lookback",
"schema": {
"type": "integer"
}
}
],
"responses": {
Expand Down
3 changes: 0 additions & 3 deletions daemon/algod/api/server/v2/generated/model/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

363 changes: 178 additions & 185 deletions daemon/algod/api/server/v2/generated/participating/public/routes.go

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions daemon/algod/api/server/v2/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type NodeInterface interface {
GenesisHash() crypto.Digest
BroadcastSignedTxGroup(txgroup []transactions.SignedTxn) error
Simulate(txgroup []transactions.SignedTxn) (result simulation.Result, err error)
GetPendingTransaction(txID transactions.Txid, lookbackRounds uint64) (res node.TxnWithStatus, found bool)
GetPendingTransaction(txID transactions.Txid) (res node.TxnWithStatus, found bool)
GetPendingTxnsFromPool() ([]transactions.SignedTxn, error)
SuggestedFee() basics.MicroAlgos
StartCatchup(catchpoint string) error
Expand Down Expand Up @@ -1177,12 +1177,7 @@ func (v2 *Handlers) PendingTransactionInformation(ctx echo.Context, txid string,
return badRequest(ctx, err, errNoValidTxnSpecified, v2.Log)
}

lookbackRounds := uint64(0)
if params.Lookback != nil {
lookbackRounds = *params.Lookback
}

txn, ok := v2.Node.GetPendingTransaction(txID, lookbackRounds)
txn, ok := v2.Node.GetPendingTransaction(txID)

// We didn't find it, return a failure
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion daemon/algod/api/server/v2/test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (m *mockNode) Simulate(txgroup []transactions.SignedTxn) (simulation.Result
return simulator.Simulate(txgroup)
}

func (m *mockNode) GetPendingTransaction(txID transactions.Txid, lookbackRounds uint64) (res node.TxnWithStatus, found bool) {
func (m *mockNode) GetPendingTransaction(txID transactions.Txid) (res node.TxnWithStatus, found bool) {
res = node.TxnWithStatus{}
found = true
return
Expand Down
2 changes: 1 addition & 1 deletion node/follower_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (node *AlgorandFollowerNode) Simulate(_ []transactions.SignedTxn) (result s
}

// GetPendingTransaction no-ops in follower mode
func (node *AlgorandFollowerNode) GetPendingTransaction(_ transactions.Txid, _ uint64) (res TxnWithStatus, found bool) {
func (node *AlgorandFollowerNode) GetPendingTransaction(_ transactions.Txid) (res TxnWithStatus, found bool) {
return
}

Expand Down
25 changes: 15 additions & 10 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ func (node *AlgorandFullNode) GetTransaction(addr basics.Address, txID transacti
// 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
// transaction was found.
func (node *AlgorandFullNode) GetPendingTransaction(txID transactions.Txid, lookbackRounds uint64) (res TxnWithStatus, found bool) {
func (node *AlgorandFullNode) GetPendingTransaction(txID transactions.Txid) (res TxnWithStatus, found bool) {
// We need to check both the pool and the ledger's blocks.
// If the transaction is found in a committed block, that
// takes precedence. But we check the pool first, because
Expand All @@ -631,19 +631,24 @@ func (node *AlgorandFullNode) GetPendingTransaction(txID transactions.Txid, look
// Keep looking in the ledger.
}

var maxLife basics.Round
latest := node.ledger.Latest()
// Backwards compat with in case old clients don't specify
if lookbackRounds == 0 {
proto, err := node.ledger.ConsensusParams(latest)
if err == nil {
lookbackRounds = proto.MaxTxnLife
} else {
node.log.Errorf("node.GetPendingTransaction: cannot get consensus params for latest round %v", latest)
}
proto, err := node.ledger.ConsensusParams(latest)
if err == nil {
maxLife = basics.Round(proto.MaxTxnLife)
} else {
node.log.Errorf("node.GetPendingTransaction: cannot get consensus params for latest round %v", latest)
}

// Search from newest to oldest round up to the max life of a transaction.
maxRound := latest
minRound := maxRound.SubSaturate(basics.Round(lookbackRounds))
minRound := maxRound.SubSaturate(maxLife)

// If we did find the transaction, we know there is no point
// checking rounds earlier than its first valid round
if found && tx.Txn.FirstValid > minRound {
minRound = tx.Txn.FirstValid
}

// Since we're using uint64, if the minRound is 0, we need to check for an underflow.
if minRound == 0 {
Expand Down

0 comments on commit a71ed3e

Please sign in to comment.