Browse Source

skip processed transactions

main
ghost 10 months ago
parent
commit
0e2a088b20
  1. 14
      src/index.php

14
src/index.php

@ -191,6 +191,9 @@ for ($block = $state + 1; $block <= $blocks; $block++)
); );
} }
// Reset memory pool of processed transactions for each new block
$transactions = [];
// Process each transaction in block // Process each transaction in block
foreach ((array) $data['tx'] as $transaction) foreach ((array) $data['tx'] as $transaction)
{ {
@ -313,9 +316,13 @@ for ($block = $state + 1; $block <= $blocks; $block++)
$namespace $namespace
) as $record) ) as $record)
{ {
if (
// Get current block transactions only // Get current block transactions only
if ($record['height'] === $block) $record['height'] === $block
{ &&
// Skip processed transactions for this namespace
!in_array($raw['txid'], $transactions)
) {
// Register new transaction // Register new transaction
$index->add( $index->add(
$raw['time'], $raw['time'],
@ -327,6 +334,9 @@ for ($block = $state + 1; $block <= $blocks; $block++)
$record['key'], $record['key'],
$record['value'] $record['value']
); );
// Register processed transaction
$transactions[] = $raw['txid'];
} }
} }

Loading…
Cancel
Save