Skip to content

Add non-coinbase txs count in the history endpoint#609

Open
tdroxler wants to merge 1 commit intomasterfrom
some-monthly-stat
Open

Add non-coinbase txs count in the history endpoint#609
tdroxler wants to merge 1 commit intomasterfrom
some-monthly-stat

Conversation

@tdroxler
Copy link
Member

Those values are nice to have in order to see the real sent transactions over the coinbase ones.

Not really sure about the all nonCoinbase naming, but it's at least very explicit.

No extra queries are needed and we keep the same performance of the previous optimization.

We'll just need to decide if we want to reset the past month of history to re trigger the computation and have the non-coinbase count.

image

Those values are nice to have in order to see the real sent transactions
over the coinbase one.
@tdroxler tdroxler requested a review from h0ngcha0 March 11, 2025 14:21
"type": "array",
"items": {
"$ref": "#/components/schemas/TimedCount"
"$ref": "#/components/schemas/TimedTxCount"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimedCount was originally meant to be a general case class that could be reused for any history data. But now that we introduce two count (total and non-coinbase), it's better to be explicit that it's for transactions count. It was only use there.

"type": "array",
"items": {
"$ref": "#/components/schemas/PerChainTimedCount"
"$ref": "#/components/schemas/PerChainTimedTxCount"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""
.asAS[(TimeStamp, Int, Int, Long)]
.map(_.map { case (ts, from, to, value) =>
(ts, from, to, value, Some(value - 1))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's were we get the txsCount for each block, as a block as only 1 coinbase tx, we can simply remove 1.

}
.foldLeft((0L, 0L)) {
case ((currentCount, currentNonCoinbaseCount), (_, _, _, count, nonCoinbaseCount)) =>
(currentCount + count, currentNonCoinbaseCount + nonCoinbaseCount.getOrElse(0L))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use nonCoinbaseCount.getOrElse(0L) as the DB type is Optional, as we introduce it later with a migration.
But during the processing here, we are guarantee to have a value, as four hourly the txsCount is fetch from the blocks table here.
For daily we use the data stored in hourly so it will always have the freshly inserted data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant