Browse Source

Merge pull request #654 from hermeznetwork/feature/api-pending-l1s

Add pending L1 txs to API
fix/mockserer
Eduard S 3 years ago
committed by GitHub
parent
commit
f6765f82bf
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions
  1. +4
    -0
      api/swagger.yml
  2. +1
    -0
      db/historydb/nodeinfo.go
  3. +6
    -0
      stateapiupdater/stateapiupdater.go

+ 4
- 0
api/swagger.yml

@ -2634,6 +2634,10 @@ components:
- example: 2334
nextForgers:
$ref: '#/components/schemas/NextForgers'
pendingL1Transactions:
type: number
description: Number of pending L1 transactions (added in the smart contract queue but not forged).
example: 22
additionalProperties: false
required:
- lastEthereumBlock

+ 1
- 0
db/historydb/nodeinfo.go

@ -32,6 +32,7 @@ type NetworkAPI struct {
LastBatch *BatchAPI `json:"lastBatch"`
CurrentSlot int64 `json:"currentSlot"`
NextForgers []NextForgerAPI `json:"nextForgers"`
PendingL1Txs int `json:"pendingL1Transactions"`
}
// NodePublicConfig is the configuration of the node that is exposed via API

+ 6
- 0
stateapiupdater/stateapiupdater.go

@ -145,11 +145,17 @@ func (u *Updater) UpdateNetworkInfo(
}
}
}
// Update pending L1s
pendingL1s, err := u.hdb.GetUnforgedL1UserTxsCount()
if err != nil {
return tracerr.Wrap(err)
}
u.state.Network.LastSyncBlock = lastSyncBlock.Num
u.state.Network.LastEthBlock = lastEthBlock.Num
u.state.Network.LastBatch = lastBatch
u.state.Network.CurrentSlot = currentSlot
u.state.Network.NextForgers = nextForgers
u.state.Network.PendingL1Txs = pendingL1s
u.rw.Unlock()
return nil
}

Loading…
Cancel
Save