-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
056ff26
commit 7890fce
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/********************************************************************* | ||
* fix_asset_type.php | ||
* | ||
* Handles correctly setting asset type | ||
* 1=Named, 2=Numeric, 3=Subasset, 4=Failed issuance, 5=Numeric Subasset | ||
* --testnet Load data from testnet | ||
********************************************************************/ | ||
|
||
// Hide all but errors | ||
error_reporting(E_ERROR); | ||
|
||
$args = getopt("", array("testnet::")); | ||
$testnet = (isset($args['testnet'])) ? true : false; | ||
$runtype = ($testnet) ? 'testnet' : 'mainnet'; | ||
$block = (isset($args['block'])) ? $args['block'] : false; | ||
|
||
require_once(__DIR__ . '/../includes/config.php'); | ||
|
||
// Initialize the database and counterparty API connections | ||
initDB(DB_HOST, DB_USER, DB_PASS, DB_DATA, true); | ||
|
||
|
||
// Get list of all assets | ||
print "Getting list of assets...\n"; | ||
// Get highest block_index | ||
$sql = "SELECT | ||
type, | ||
asset, | ||
asset_longname | ||
FROM | ||
assets"; | ||
print $sql; | ||
$results = $mysqli->query($sql); | ||
if($results){ | ||
$count = 0; | ||
$fixed = 0; | ||
$total = $results->num_rows; | ||
while($row = $results->fetch_assoc()){ | ||
$count++; | ||
// Determine asset type | ||
$asset = $row['asset']; | ||
$asset_longname = $row['asset_longname']; | ||
$type = (substr($asset,0,1)=='A') ? 2 : 1; | ||
if(isset($asset_longname) && $asset_longname!='') | ||
$type = (substr($asset_longname,0,1)=='A') ? 5 : 3; | ||
if($type!=$row['type']){ | ||
$fixed++; | ||
$sql = "UPDATE assets SET type='{$type}' WHERE asset='{$asset}'"; | ||
$results2 = $mysqli->query($sql); | ||
} | ||
print "[{$count} / {$fixed} / {$total}] Processing asset {$asset} - {$asset_longname}...\n"; | ||
} | ||
} else { | ||
bye('Error looking up asset list'); | ||
} | ||
|