arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Add pending L1 txs to API
arnaubennassar arnaubennassar5@gmail.com
Mon, 22 Mar 2021 11:50:37 +0100
commit

3fcec947b404aa8102972a339feeb6ec6aca6d4b

parent

334eecc99e0dd20ff14c2963dce75f41468d1c8c

3 files changed, 11 insertions(+), 0 deletions(-)

jump to
M api/swagger.yml → api/swagger.yml

@@ -2634,6 +2634,10 @@ - description: Slot where batches are currently being forged.

- 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
M db/historydb/nodeinfo.go → db/historydb/nodeinfo.go

@@ -32,6 +32,7 @@ LastSyncBlock int64 `json:"lastSynchedBlock"`

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
M stateapiupdater/stateapiupdater.go → stateapiupdater/stateapiupdater.go

@@ -145,11 +145,17 @@ break

} } } + // 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 }