@@ -46,6 +46,7 @@ import {
4646 CoreNodeMsgBlockData ,
4747 parseMicroblocksFromTxs ,
4848 isPoxPrintEvent ,
49+ newCoreNoreBlockEventCounts ,
4950} from './reader' ;
5051import {
5152 decodeTransaction ,
@@ -230,6 +231,7 @@ async function handleBlockMessage(
230231 db : PgWriteStore
231232) : Promise < void > {
232233 const ingestionTimer = stopwatch ( ) ;
234+ const counts = newCoreNoreBlockEventCounts ( ) ;
233235 const parsedTxs : CoreNodeParsedTxMessage [ ] = [ ] ;
234236 const blockData : CoreNodeMsgBlockData = {
235237 ...msg ,
@@ -238,8 +240,42 @@ async function handleBlockMessage(
238240 const parsedTx = parseMessageTransaction ( chainId , item , blockData , msg . events ) ;
239241 if ( parsedTx ) {
240242 parsedTxs . push ( parsedTx ) ;
243+ counts . tx_total += 1 ;
244+ switch ( parsedTx . parsed_tx . payload . type_id ) {
245+ case TxPayloadTypeID . Coinbase :
246+ counts . txs . coinbase += 1 ;
247+ break ;
248+ case TxPayloadTypeID . CoinbaseToAltRecipient :
249+ counts . txs . coinbase_to_alt_recipient += 1 ;
250+ break ;
251+ case TxPayloadTypeID . ContractCall :
252+ counts . txs . contract_call += 1 ;
253+ break ;
254+ case TxPayloadTypeID . NakamotoCoinbase :
255+ counts . txs . nakamoto_coinbase += 1 ;
256+ break ;
257+ case TxPayloadTypeID . PoisonMicroblock :
258+ counts . txs . poison_microblock += 1 ;
259+ break ;
260+ case TxPayloadTypeID . SmartContract :
261+ counts . txs . smart_contract += 1 ;
262+ break ;
263+ case TxPayloadTypeID . TenureChange :
264+ counts . txs . tenure_change += 1 ;
265+ break ;
266+ case TxPayloadTypeID . TokenTransfer :
267+ counts . txs . token_transfer += 1 ;
268+ break ;
269+ case TxPayloadTypeID . VersionedSmartContract :
270+ counts . txs . versioned_smart_contract += 1 ;
271+ break ;
272+ }
241273 }
242274 } ) ;
275+ for ( const event of msg . events ) {
276+ counts . event_total += 1 ;
277+ counts . events [ event . type ] += 1 ;
278+ }
243279
244280 const dbBlock : DbBlock = {
245281 canonical : true ,
@@ -281,6 +317,7 @@ async function handleBlockMessage(
281317 tx_fees_streamed_produced : BigInt ( minerReward . tx_fees_streamed_produced ) ,
282318 } ;
283319 dbMinerRewards . push ( dbMinerReward ) ;
320+ counts . miner_rewards += 1 ;
284321 }
285322
286323 logger . debug ( `Received ${ dbMinerRewards . length } matured miner rewards` ) ;
@@ -304,18 +341,10 @@ async function handleBlockMessage(
304341 index_block_hash : msg . index_block_hash ,
305342 block_hash : msg . block_hash ,
306343 } ;
344+ counts . microblocks += 1 ;
307345 return microblock ;
308346 } ) ;
309347
310- parsedTxs . forEach ( tx => {
311- logger . debug ( `Received anchor block mined tx: ${ tx . core_tx . txid } ` ) ;
312- logger . info ( 'Transaction confirmed' , {
313- txid : tx . core_tx . txid ,
314- in_microblock : tx . microblock_hash != '' ,
315- stacks_height : dbBlock . block_height ,
316- } ) ;
317- } ) ;
318-
319348 const dbData : DataStoreBlockUpdateData = {
320349 block : dbBlock ,
321350 microblocks : dbMicroblocks ,
@@ -328,7 +357,10 @@ async function handleBlockMessage(
328357
329358 await db . update ( dbData ) ;
330359 const ingestionTime = ingestionTimer . getElapsed ( ) ;
331- logger . info ( `Ingested block ${ msg . block_height } (${ msg . block_hash } ) in ${ ingestionTime } ms` ) ;
360+ logger . info (
361+ counts ,
362+ `Ingested block ${ msg . block_height } (${ msg . block_hash } ) in ${ ingestionTime } ms`
363+ ) ;
332364}
333365
334366function parseDataStoreTxEventData (
0 commit comments