From 470b190c143f2075120edde61a912941f8392be4 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Mon, 1 Apr 2024 10:02:05 -0700 Subject: [PATCH 01/16] cleanup reparse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - start using `—block=#` instead of `—reparse=#` --- indexer/indexer.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/indexer/indexer.php b/indexer/indexer.php index 7217cc8..68fb8e2 100755 --- a/indexer/indexer.php +++ b/indexer/indexer.php @@ -24,8 +24,7 @@ * --testnet Load data from testnet * --block=# Load data for given block * --rollback=# Rollback data to a given block - * --reparse Reparse ALL data - * --reparse=# Reparse data from a given block + * --reparse Reparse transaction data * --single Load single block ********************************************************************/ @@ -35,8 +34,8 @@ // Parse in any command line args and set basic runtime flags $args = getopt("", array("testnet::", "block::", "single::", "rollback::", "reparse::")); $testnet = (isset($args['testnet'])) ? true : false; -$single = (isset($args['single'])) ? true : false; -$reparse = (isset($args['reparse'])) ? ((is_numeric($args['reparse'])) ? $args['reparse'] : true) : false; +$single = (isset($args['single'])) ? true : false; +$reparse = (isset($args['reparse'])) ? true : false; $block = (is_numeric($args['block'])) ? intval($args['block']) : false; $network = ($testnet) ? 'testnet' : 'mainnet'; $rollback = (is_numeric($args['rollback'])) ? intval($args['rollback']) : false; @@ -94,7 +93,7 @@ // Handle reparses if($reparse) - btnsReparse($current, $reparse); + btnsReparse($current, $block); // Loop through the blocks until we are current while($block <= $current){ From f6434776999fcc499c8a1b3fcfd5b4d5d15dbbd0 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Thu, 4 Apr 2024 18:05:45 -0700 Subject: [PATCH 02/16] cleanup - updated `createTxIndex()` to call on `createAction()` instead of `createTxType()` - updated `transactions` table to change `type_id` to `action_id` - removed `index_tx_types` table (duplicated via `index_actions`) - removed `createTxType()` function --- indexer/includes/functions.php | 28 +++------------------------- indexer/sql/index_tx_types.sql | 7 ------- indexer/sql/transactions.sql | 6 +++--- 3 files changed, 6 insertions(+), 35 deletions(-) delete mode 100644 indexer/sql/index_tx_types.sql diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index acc4452..e2b873e 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -1437,28 +1437,6 @@ function btnsAction($action=null, $params=null, $data=null, $error=null){ if($action=='SWEEP') btnsSweep($params, $data, $error); } -// Create records in the 'tx_index_types' table and return record id -function createTxType( $type=null ){ - global $mysqli; - $type = $mysqli->real_escape_string($type); - $results = $mysqli->query("SELECT id FROM index_tx_types WHERE type='{$type}' LIMIT 1"); - if($results){ - if($results->num_rows){ - $row = $results->fetch_assoc(); - return $row['id']; - } else { - $results = $mysqli->query("INSERT INTO index_tx_types (type) values ('{$type}')"); - if($results){ - return $mysqli->insert_id; - } else { - byeLog('Error while trying to create record in index_tx_types table'); - } - } - } else { - byeLog('Error while trying to lookup record in index_tx_types table'); - } -} - // Handles returning the highest tx_index from transactions table function getNextTxIndex(){ global $mysqli; @@ -1493,12 +1471,12 @@ function createTxIndex( $data=null ){ // Get highest tx_index $block_index = $data->BLOCK_INDEX; $tx_hash_id = createTransaction($data->TX_HASH); - $type_id = createTxType($data->ACTION); + $action_id = createAction($data->ACTION); $tx_index = getNextTxIndex(); - $results = $mysqli->query("SELECT type_id FROM transactions WHERE tx_hash_id='{$tx_hash_id}' LIMIT 1"); + $results = $mysqli->query("SELECT action_id FROM transactions WHERE tx_hash_id='{$tx_hash_id}' LIMIT 1"); if($results){ if($results->num_rows==0){ - $results = $mysqli->query("INSERT INTO transactions (tx_index, block_index, tx_hash_id, type_id) values ('{$tx_index}','{$block_index}','{$tx_hash_id}', '{$type_id}')"); + $results = $mysqli->query("INSERT INTO transactions (tx_index, block_index, tx_hash_id, action_id) values ('{$tx_index}','{$block_index}','{$tx_hash_id}', '{$action_id}')"); if(!$results) byeLog('Error while trying to create record in transactions table'); } diff --git a/indexer/sql/index_tx_types.sql b/indexer/sql/index_tx_types.sql deleted file mode 100644 index 0c0d4a7..0000000 --- a/indexer/sql/index_tx_types.sql +++ /dev/null @@ -1,7 +0,0 @@ -DROP TABLE IF EXISTS index_tx_types; -CREATE TABLE index_tx_types ( - id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, - type VARCHAR(100) NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - -CREATE INDEX type on index_tx_types (type); diff --git a/indexer/sql/transactions.sql b/indexer/sql/transactions.sql index fe215ec..604021d 100644 --- a/indexer/sql/transactions.sql +++ b/indexer/sql/transactions.sql @@ -2,11 +2,11 @@ DROP TABLE IF EXISTS transactions; CREATE TABLE transactions ( tx_index INTEGER UNSIGNED NOT NULL, block_index INTEGER, - tx_hash_id INTEGER UNSIGNED NOT NULL, - type_id INTEGER UNSIGNED NOT NULL -- id of record in index_tx_types table + tx_hash_id INTEGER UNSIGNED NOT NULL, -- id of record in index_transactions table + action_id INTEGER UNSIGNED NOT NULL -- id of record in index_actions table ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; CREATE UNIQUE INDEX tx_index on transactions (tx_index); CREATE INDEX block_index on transactions (block_index); CREATE INDEX tx_hash_id on transactions (tx_hash_id); -CREATE INDEX type_id on transactions (type_id); +CREATE INDEX action_id on transactions (action_id); From b9d85c32657ab582cec39e4aa5f88421c1a65b51 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Fri, 5 Apr 2024 09:23:56 -0700 Subject: [PATCH 03/16] update to use `printRuntime()` --- indexer/includes/rollback.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/indexer/includes/rollback.php b/indexer/includes/rollback.php index 5245e3f..f9ddf6c 100644 --- a/indexer/includes/rollback.php +++ b/indexer/includes/rollback.php @@ -152,9 +152,8 @@ function btnsRollback($block_index=null){ // Delete items from list_{items,edits} tables deleteLists($transactions, true); - // Report time to process block - $time = $timer->finish(); - print " Done [{$time}sec]\n"; + // Print out information on the total runtime + printRuntime($runtime->finish()); // Notify user rollback is complete byeLog("Rollback to block {$block_index} complete."); From b4121fd5c33344b0820b7576200134550cd87d7c Mon Sep 17 00:00:00 2001 From: J-Dog Date: Tue, 9 Apr 2024 18:32:17 -0700 Subject: [PATCH 04/16] `isvalidLock()` and `getTokenInfo()` cleanup - update `isValidLock()` so unset lock values are valid - update `getTokenInfo()` so empty values are ignored --- indexer/includes/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index e2b873e..20a8f63 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -954,8 +954,8 @@ function getTokenInfo($tick=null, $tick_id=null, $block_index=null, $tx_index=nu if(substr($key,0,5)=='LOCK_') if($data[$key]==1) continue; - // Skip setting value if value is null - if(in_array($key,array('MAX_SUPPLY','MAX_MINT')) && !isset($value)) + // Skip setting value if value is null or empty + if(in_array($key,array('MAX_SUPPLY','MAX_MINT')) && (!isset($value) || $value=='')) continue; $data[$key] = $value; } @@ -1584,6 +1584,9 @@ function isValidLock($btInfo=null, $data=null, $lock=null){ // If we dont have any info on the token, it hasn't been created yet, so all flags are valid if(!isset($btInfo)) return true; + // If token exists and lock value does not exist yet, its valid + if($btInfo->{$lock}=="") + return true; // If lock value is not changing, its valid if(isset($value) && $btInfo->{$lock}==$value) return true; From c53628fa5e0ec2a754aab07c492f200bff35ff94 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Fri, 12 Apr 2024 10:09:20 -0700 Subject: [PATCH 05/16] add runtime global var --- indexer/includes/rollback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indexer/includes/rollback.php b/indexer/includes/rollback.php index f9ddf6c..a83654e 100644 --- a/indexer/includes/rollback.php +++ b/indexer/includes/rollback.php @@ -3,7 +3,7 @@ * rollback.php - Handles rolling back database updates safely ********************************************************************/ function btnsRollback($block_index=null){ - global $mysqli, $addresses, $tickers; + global $mysqli, $runtime, $addresses, $tickers; $block_index = (int) $block_index; From d6124529043d8696171f8e5453f1c3b34a09b2c7 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Fri, 12 Apr 2024 10:15:32 -0700 Subject: [PATCH 06/16] =?UTF-8?q?add=20support=20for=20`=E2=80=94compare?= =?UTF-8?q?=3DDB`=20option=20to=20compare=20ledgers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- indexer/includes/compare.php | 187 +++++++++++++++++++++++++++++++++++ indexer/indexer.php | 7 +- 2 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 indexer/includes/compare.php diff --git a/indexer/includes/compare.php b/indexer/includes/compare.php new file mode 100644 index 0000000..a0f41f6 --- /dev/null +++ b/indexer/includes/compare.php @@ -0,0 +1,187 @@ + DB_DATA, + 'compare' => $database + ); + + // Setup placeholders for ledger transactions + $data = array(); + foreach($ledgers as $name => $db) + $data[$name] = array(); + + // Verify database exists + try { + $database = $mysqli->real_escape_string($database); + $results = $mysqli->query("USE {$database}"); + } catch (Exception $e){ + $error = "database {$database} not found"; + } + + // Build out SQL query based on runtime flags + $whereSql = ''; + $limitSql = ($single) ? 'LIMIT 1' : ''; + if($block){ + $op = ($single) ? '=' : '>='; + $whereSql = " AND block_index {$op} {$block}"; + } + + // Get list of transactions from each ledger + foreach($ledgers as $name => $db){ + if(!$error){ + $data[$name]['transactions'] = array(); + print "Getting data for {$name} ledger from {$db} database...\n"; + $sql = "SELECT + t1.tx_index, + t2.hash as tx_hash, + a.action + FROM + {$db}.transactions t1, + {$db}.index_transactions t2, + {$db}.index_actions a + WHERE + a.id=t1.action_id AND + t2.id=t1.tx_hash_id + {$whereSql} + ORDER BY tx_index ASC + {$limitSql}"; + // Support OLD style database with index_tx_types instead of index_actions + // TODO: Remove + if(in_array($db,array('BTNS_Counterparty_Old','BTNS_Counterparty_Testnet_Old'))){ + $sql = "SELECT + t1.tx_index, + t2.hash as tx_hash, + a.type as action + FROM + {$db}.transactions t1, + {$db}.index_transactions t2, + {$db}.index_tx_types a + WHERE + a.id=t1.type_id AND + t2.id=t1.tx_hash_id + {$whereSql} + ORDER BY tx_index ASC + {$limitSql}"; + } + + $results = $mysqli->query($sql); + if($results){ + if($results->num_rows){ + while($row = $results->fetch_assoc()) + $data[$name]['transactions'][$row['tx_index']] = $row; + } + } else { + $error = "Error while looking up transactions in the {$db} database"; + } + } + if(!$error) + print "Found " . number_format(count($data[$name]['transactions'])) . " transactions\n"; + } + + // Loop through ledger transactions + foreach($data['current']['transactions'] as $tx_index => $info){ + + // debug: force mismatches + // $data['compare']['transactions'][1]['tx_hash'] = 'test'; + // $data['compare']['transactions'][1]['action'] = 'test'; + + // Compare basic transaction data (tx_index, tx_hash, action) + foreach(array_keys($info) as $field) + if(!$error && $data['compare']['transactions'][$tx_index][$field]!=$info[$field]) + $error = "ERROR: Found ledger {$field} difference at tx_index {$tx_index}! ({$info[$field]} != {$data['compare']['transactions'][$tx_index][$field]})"; + + // Lookup transaction statuses for records related to this transaction + if(!$error){ + $action = strtolower($info['action']); + $append = (in_array($action,array('address','batch'))) ? 'es' : 's'; + $table = $action . $append; + if(in_array($table, $tables)){ + + // Handle batches by looping through all tables looking for data + $arr = ($table=='batch') ? $tables : [$table]; + + // Loop through tables with transaction data + foreach($arr as $table){ + foreach($ledgers as $name => $db){ + if(!$error){ + $data[$name]['txinfo'] = array(); + $sql = "SELECT + a.address as source, + s.status + FROM + {$db}.{$table} m, + {$db}.index_statuses s, + {$db}.index_addresses a + WHERE + s.id=m.status_id AND + a.id=m.source_id AND + m.tx_index='{$tx_index}'"; + // print $sql; + $results = $mysqli->query($sql); + if($results){ + if($results->num_rows) + while($row = $results->fetch_assoc()) + array_push($data[$name]['txinfo'], $row); + } else { + $error = "Error while looking up {$table} data in the {$db} database"; + } + } + } + + // debug: force mismatches + // $data['compare']['txinfo'][0]['source'] = 'test'; + // $data['compare']['txinfo'][0]['status'] = 'test'; + + // Compare transaction data (source, status) + if(!$error){ + foreach($data['current']['txinfo'] as $idx => $nfo){ + foreach(array_keys($nfo) as $field) + if(!$error && $data['compare']['txinfo'][$idx][$field]!=$nfo[$field]) + $error = "ERROR: Found ledger {$field} difference at tx_index {$tx_index}! ({$nfo[$field]} != {$data['compare']['txinfo'][$idx][$field]})"; + } + } + } + } else { + // Throw error if table is not found + // $error = "Error table {$table} not found\n"; + } + } + + // Bail out on any error + if($error) + break; + } + + // Display any errors and exit + if($error) + byeLog($error); + + // Print out information on the total runtime + printRuntime($runtime->finish()); + + // Notify user comparison is complete + byeLog("Compare complete."); +} + +?> diff --git a/indexer/indexer.php b/indexer/indexer.php index 68fb8e2..4a09204 100755 --- a/indexer/indexer.php +++ b/indexer/indexer.php @@ -32,10 +32,11 @@ error_reporting(E_ERROR|E_PARSE); // Parse in any command line args and set basic runtime flags -$args = getopt("", array("testnet::", "block::", "single::", "rollback::", "reparse::")); +$args = getopt("", array("testnet::", "block::", "single::", "rollback::", "reparse::", "compare::")); $testnet = (isset($args['testnet'])) ? true : false; $single = (isset($args['single'])) ? true : false; $reparse = (isset($args['reparse'])) ? true : false; +$compare = (isset($args['compare'])) ? $args['compare'] : false; $block = (is_numeric($args['block'])) ? intval($args['block']) : false; $network = ($testnet) ? 'testnet' : 'mainnet'; $rollback = (is_numeric($args['rollback'])) ? intval($args['rollback']) : false; @@ -69,6 +70,10 @@ if($rollback) btnsRollback($rollback); +// Handle compares +if($compare) + btnsCompare($compare); + // If no block given, load last block from state file, or use first block with BTNX tx if(!$block){ $last = file_get_contents(LASTFILE); From b2c9640d8e149f7dbff746482c999828f2a64bda Mon Sep 17 00:00:00 2001 From: J-Dog Date: Wed, 17 Apr 2024 12:40:34 -0700 Subject: [PATCH 07/16] lookup balances using either block_index OR tx_index --- indexer/includes/functions.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index 20a8f63..e400f36 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -1102,10 +1102,12 @@ function getAddressCreditDebit($table=null, $address=null, $action=null, $block= $whereSql = ""; if(isset($action)) $whereSql .= " AND t1.action_id={$action_id}"; - if(isset($block) && is_numeric($block)) - $whereSql .= " AND t1.block_index < {$block}"; - if(isset($tx_index) && is_numeric($tx_index)) + // Query using either block_index OR tx_index + if(isset($tx_index) && is_numeric($tx_index)){ $whereSql .= " AND t3.tx_index < {$tx_index}"; + } else if(isset($block) && is_numeric($block)){ + $whereSql .= " AND t1.block_index < {$block}"; + } if(in_array($table,array('credits','debits'))){ // Get data from the table $sql = "SELECT @@ -1135,8 +1137,7 @@ function getAddressCreditDebit($table=null, $address=null, $action=null, $block= byeLog("Error while trying to lookup address {$table} for : {$address}"); } } - return $data; - + return $data; } // Get address balances using credits/debits table data From f19004200fe8c1b06be2b3cfaafee3c79d011c52 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Wed, 17 Apr 2024 18:15:23 -0700 Subject: [PATCH 08/16] version bump to 0.13.0 --- indexer/CHANGELOG.md | 11 +++++++++++ indexer/includes/config.php | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/indexer/CHANGELOG.md b/indexer/CHANGELOG.md index b1cc352..e781d58 100644 --- a/indexer/CHANGELOG.md +++ b/indexer/CHANGELOG.md @@ -1,5 +1,16 @@ CHANGELOG --- +0.13.0 +- Added support for `--compare=DB` +- start using `—block=#` instead of `—reparse=#` +- Updated `createTxIndex()` to call on `createAction()` instead of `createTxType()` +- Updated `transactions` table to change `type_id` to `action_id` +- Updated `isValidLock()` so unset lock values are valid +- Updated `getTokenInfo()` so empty values are ignored +- Removed `index_tx_types` table (duplicated via `index_actions`) +- Removed `createTxType()` function +- Updated `getAddressCreditDebit()` to lookup balances using `block_index` or `tx_index` + 0.12.0 - Added support for `--reparse` - Optimized ledger hashing diff --git a/indexer/includes/config.php b/indexer/includes/config.php index 104393e..2326191 100644 --- a/indexer/includes/config.php +++ b/indexer/includes/config.php @@ -9,7 +9,7 @@ // BTNS Indexer Version define("VERSION_MAJOR", 0); -define("VERSION_MINOR", 12); +define("VERSION_MINOR", 13); define("VERSION_REVISION",0); define("VERSION_STRING", VERSION_MAJOR . '.' . VERSION_MINOR . '.' . VERSION_REVISION); @@ -69,11 +69,10 @@ // Tracks Execution Time require_once('profiler.php'); -// Rollback code +// Ledger Management / Maintenance require_once('rollback.php'); - -// Reparse code require_once('reparse.php'); +require_once('compare.php'); // Protocol Changes / Activation blocks require_once('protocol_changes.php'); From 2bf7db5635c4f2a73a149dee7909e3a829677e3e Mon Sep 17 00:00:00 2001 From: J-Dog Date: Wed, 17 Apr 2024 18:35:09 -0700 Subject: [PATCH 09/16] start reparses at first block if no block given --- indexer/indexer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indexer/indexer.php b/indexer/indexer.php index 4a09204..93186a6 100755 --- a/indexer/indexer.php +++ b/indexer/indexer.php @@ -79,6 +79,9 @@ $last = file_get_contents(LASTFILE); $first = FIRST_BLOCK; // First block a BTNS transaction is seen $block = (isset($last) && $last>=$first) ? (intval($last) + 1) : $first; + // If not reparse block is given, start reparse at first block + if($reparse) + $block = $first; } // Get the current block index from status info From 652ad87a051c718fdd175ab4bdb96d541c3e04a7 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Thu, 18 Apr 2024 10:57:32 -0700 Subject: [PATCH 10/16] remove duplicate `OWNER` array item --- indexer/includes/functions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index e400f36..b36efd3 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -929,7 +929,6 @@ function getTokenInfo($tick=null, $tick_id=null, $block_index=null, $tx_index=nu 'MAX_MINT' => $row->max_mint, 'DECIMALS' => (isset($row->decimals)) ? intval($row->decimals) : 0, 'DESCRIPTION' => $row->description, - 'OWNER' => $row->owner, 'LOCK_MAX_SUPPLY' => $row->lock_max_supply, 'LOCK_MINT_SUPPLY' => $row->lock_mint_supply, 'LOCK_MINT' => $row->lock_mint, From c2f53e6702a5b561112e3ccd69e70b372e990a1e Mon Sep 17 00:00:00 2001 From: J-Dog Date: Thu, 18 Apr 2024 11:00:21 -0700 Subject: [PATCH 11/16] changelog update --- indexer/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/indexer/CHANGELOG.md b/indexer/CHANGELOG.md index e781d58..5d83ee3 100644 --- a/indexer/CHANGELOG.md +++ b/indexer/CHANGELOG.md @@ -10,6 +10,7 @@ CHANGELOG - Removed `index_tx_types` table (duplicated via `index_actions`) - Removed `createTxType()` function - Updated `getAddressCreditDebit()` to lookup balances using `block_index` or `tx_index` +- Updated `getTokenInfo()` to removed duplicated `OWNER` array item 0.12.0 - Added support for `--reparse` From 28e75730967d1ed38267a5a4baecf244e930639b Mon Sep 17 00:00:00 2001 From: J-Dog Date: Thu, 18 Apr 2024 20:41:38 -0700 Subject: [PATCH 12/16] cleanup `getTokenInfo()` to stop setting null/empty values --- indexer/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indexer/includes/functions.php b/indexer/includes/functions.php index b36efd3..52bc348 100644 --- a/indexer/includes/functions.php +++ b/indexer/includes/functions.php @@ -953,8 +953,8 @@ function getTokenInfo($tick=null, $tick_id=null, $block_index=null, $tx_index=nu if(substr($key,0,5)=='LOCK_') if($data[$key]==1) continue; - // Skip setting value if value is null or empty - if(in_array($key,array('MAX_SUPPLY','MAX_MINT')) && (!isset($value) || $value=='')) + // Skip setting value if value is null or empty (use last explicit value) + if(!isset($value) || $value=='') continue; $data[$key] = $value; } From f45c051de1921c95eee9e6997eb3f205a10f690e Mon Sep 17 00:00:00 2001 From: J-Dog Date: Thu, 18 Apr 2024 20:42:57 -0700 Subject: [PATCH 13/16] cleanup `MINT_START/STOP_BLOCK` logic --- indexer/includes/actions/issue.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indexer/includes/actions/issue.php b/indexer/includes/actions/issue.php index 92d01b1..d2392de 100644 --- a/indexer/includes/actions/issue.php +++ b/indexer/includes/actions/issue.php @@ -268,15 +268,15 @@ function btnsIssue( $params=null, $data=null, $error=null){ $error = 'invalid: BLOCK_LIST (bad list)'; // Verify MINT_START_BLOCK is greater than or equal to current block - if(!$error && isset($data->MINT_START_BLOCK) && $data->MINT_START_BLOCK > 0 && $data->MINT_START_BLOCK < $data->BLOCK_INDEX) + if(!$error && isset($issue->MINT_START_BLOCK) && $issue->MINT_START_BLOCK > 0 && $issue->MINT_START_BLOCK < $issue->BLOCK_INDEX) $error = 'invalid: MINT_START_BLOCK < BLOCK_INDEX'; // Verify MINT_STOP_BLOCK is greater than or equal to current block - if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_STOP_BLOCK > 0 && $data->MINT_STOP_BLOCK < $data->BLOCK_INDEX) + if(!$error && isset($issue->MINT_STOP_BLOCK) && $issue->MINT_STOP_BLOCK > 0 && $issue->MINT_STOP_BLOCK < $issue->BLOCK_INDEX) $error = 'invalid: MINT_STOP_BLOCK < BLOCK_INDEX'; // Verify MINT_STOP_BLOCK is greater than or equal to MINT_START_BLOCK - if(!$error && isset($data->MINT_STOP_BLOCK) && $data->MINT_START_BLOCK > 0 && $data->MINT_STOP_BLOCK > 0 && $data->MINT_STOP_BLOCK < $data->MINT_START_BLOCK) + if(!$error && isset($issue->MINT_STOP_BLOCK) && $issue->MINT_START_BLOCK > 0 && $issue->MINT_STOP_BLOCK > 0 && $issue->MINT_STOP_BLOCK < $issue->MINT_START_BLOCK) $error = 'invalid: MINT_STOP_BLOCK < MINT_START_BLOCK'; // Determine final status From f2de9fd784f4f04d854a77deb6b5b4d5098ffea1 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Thu, 18 Apr 2024 20:44:00 -0700 Subject: [PATCH 14/16] add support for old style dogeparty database with index_tx_types --- indexer/includes/compare.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indexer/includes/compare.php b/indexer/includes/compare.php index a0f41f6..8c5c8b1 100644 --- a/indexer/includes/compare.php +++ b/indexer/includes/compare.php @@ -68,7 +68,7 @@ function btnsCompare($database=null){ {$limitSql}"; // Support OLD style database with index_tx_types instead of index_actions // TODO: Remove - if(in_array($db,array('BTNS_Counterparty_Old','BTNS_Counterparty_Testnet_Old'))){ + if(in_array($db,array('BTNS_Counterparty_Old','BTNS_Counterparty_Testnet_Old','BTNS_Dogeparty_Old','BTNS_Dogeparty_Testnet_Old'))){ $sql = "SELECT t1.tx_index, t2.hash as tx_hash, From 2b8f68e063dcb0723507dd12f4231c5827a6afe1 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Thu, 18 Apr 2024 22:31:29 -0700 Subject: [PATCH 15/16] ignore missing txs in compare ledger --- indexer/includes/compare.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indexer/includes/compare.php b/indexer/includes/compare.php index 8c5c8b1..a3b0454 100644 --- a/indexer/includes/compare.php +++ b/indexer/includes/compare.php @@ -108,7 +108,7 @@ function btnsCompare($database=null){ // Compare basic transaction data (tx_index, tx_hash, action) foreach(array_keys($info) as $field) - if(!$error && $data['compare']['transactions'][$tx_index][$field]!=$info[$field]) + if(!$error && isset($data['compare']['transactions'][$tx_index]) && $data['compare']['transactions'][$tx_index][$field]!=$info[$field]) $error = "ERROR: Found ledger {$field} difference at tx_index {$tx_index}! ({$info[$field]} != {$data['compare']['transactions'][$tx_index][$field]})"; // Lookup transaction statuses for records related to this transaction @@ -157,7 +157,7 @@ function btnsCompare($database=null){ if(!$error){ foreach($data['current']['txinfo'] as $idx => $nfo){ foreach(array_keys($nfo) as $field) - if(!$error && $data['compare']['txinfo'][$idx][$field]!=$nfo[$field]) + if(!$error && isset($data['compare']['txinfo'][$idx]) && $data['compare']['txinfo'][$idx][$field]!=$nfo[$field]) $error = "ERROR: Found ledger {$field} difference at tx_index {$tx_index}! ({$nfo[$field]} != {$data['compare']['txinfo'][$idx][$field]})"; } } From 3ce4e7873de03dba82dc7465f97c3fbe4819e7a6 Mon Sep 17 00:00:00 2001 From: J-Dog Date: Thu, 18 Apr 2024 22:35:20 -0700 Subject: [PATCH 16/16] changelog update --- indexer/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indexer/CHANGELOG.md b/indexer/CHANGELOG.md index 5d83ee3..a48f59b 100644 --- a/indexer/CHANGELOG.md +++ b/indexer/CHANGELOG.md @@ -11,6 +11,8 @@ CHANGELOG - Removed `createTxType()` function - Updated `getAddressCreditDebit()` to lookup balances using `block_index` or `tx_index` - Updated `getTokenInfo()` to removed duplicated `OWNER` array item +- Cleanup `MINT_START/STOP_BLOCK` logic +- Updated `--compare=DB` to ignore missing txs in compare ledger 0.12.0 - Added support for `--reparse`