Browse Source

Merge pull request #644 from hermeznetwork/feature/external-delete-not-count

Not count txs marked as external_delete to reach MaxTxsPool
feature/update-smart-contracts
Eduard S 3 years ago
committed by GitHub
parent
commit
4ebe285912
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 4 deletions
  1. +1
    -1
      api/txspool.go
  2. +0
    -1
      db/historydb/apiqueries.go
  3. +1
    -1
      db/l2db/apiqueries.go
  4. +1
    -1
      db/l2db/l2db.go

+ 1
- 1
api/txspool.go

@ -179,7 +179,7 @@ func (a *API) verifyPoolL2TxWrite(txw *l2db.PoolL2TxWrite) error {
// Get public key // Get public key
account, err := a.h.GetCommonAccountAPI(poolTx.FromIdx) account, err := a.h.GetCommonAccountAPI(poolTx.FromIdx)
if err != nil { if err != nil {
return tracerr.Wrap(err)
return tracerr.Wrap(fmt.Errorf("Error getting from account: %w", err))
} }
// Validate TokenID // Validate TokenID
if poolTx.TokenID != account.TokenID { if poolTx.TokenID != account.TokenID {

+ 0
- 1
db/historydb/apiqueries.go

@ -1129,7 +1129,6 @@ func (hdb *HistoryDB) GetMetricsInternalAPI(lastBatchNum common.BatchNum) (*Metr
nBatches++ nBatches++
} }
if (p.ToBatchNum - p.FromBatchNum) > 0 { if (p.ToBatchNum - p.FromBatchNum) > 0 {
fmt.Printf("DBG ntxs: %v, nBatches: %v\n", nTxs, nBatches)
metrics.TransactionsPerBatch = float64(nTxs) / metrics.TransactionsPerBatch = float64(nTxs) /
float64(nBatches) float64(nBatches)
} else { } else {

+ 1
- 1
db/l2db/apiqueries.go

@ -80,7 +80,7 @@ func (l2db *L2DB) AddTxAPI(tx *PoolL2TxWrite) error {
q := fmt.Sprintf( q := fmt.Sprintf(
`INSERT INTO tx_pool (%s) `INSERT INTO tx_pool (%s)
SELECT %s SELECT %s
WHERE (SELECT COUNT(*) FROM tx_pool WHERE state = $%v) < $%v;`,
WHERE (SELECT COUNT(*) FROM tx_pool WHERE state = $%v AND NOT external_delete) < $%v;`,
namesPart, valuesPart, namesPart, valuesPart,
len(values)+1, len(values)+2) //nolint:gomnd len(values)+1, len(values)+2) //nolint:gomnd
values = append(values, common.PoolL2TxStatePending, l2db.maxTxs) values = append(values, common.PoolL2TxStatePending, l2db.maxTxs)

+ 1
- 1
db/l2db/l2db.go

@ -204,7 +204,7 @@ func (l2db *L2DB) GetPendingTxs() ([]common.PoolL2Tx, error) {
var txs []*common.PoolL2Tx var txs []*common.PoolL2Tx
err := meddler.QueryAll( err := meddler.QueryAll(
l2db.dbRead, &txs, l2db.dbRead, &txs,
selectPoolTxCommon+"WHERE state = $1",
selectPoolTxCommon+"WHERE state = $1 AND NOT external_delete;",
common.PoolL2TxStatePending, common.PoolL2TxStatePending,
) )
return db.SlicePtrsToSlice(txs).([]common.PoolL2Tx), tracerr.Wrap(err) return db.SlicePtrsToSlice(txs).([]common.PoolL2Tx), tracerr.Wrap(err)

Loading…
Cancel
Save