Update files to use class constructor parentheses
This commit is contained in:
@@ -145,7 +145,7 @@ class Account
|
||||
public function get_transactions($id, $limit = 100)
|
||||
{
|
||||
global $db;
|
||||
$block = new Block;
|
||||
$block = new Block();
|
||||
$current = $block->current();
|
||||
$public_key = $this->public_key($id);
|
||||
$limit = intval($limit);
|
||||
|
||||
@@ -5,8 +5,8 @@ class Block
|
||||
public function add($height, $public_key, $nonce, $data, $date, $signature, $difficulty, $reward_signature, $argon)
|
||||
{
|
||||
global $db;
|
||||
$acc = new Account;
|
||||
$trx = new Transaction;
|
||||
$acc = new Account();
|
||||
$trx = new Transaction();
|
||||
|
||||
$generator = $acc->get_address($public_key);
|
||||
|
||||
@@ -232,7 +232,7 @@ class Block
|
||||
_log("Invalid block argon - $data[argon]");
|
||||
return false;
|
||||
}
|
||||
$acc = new Account;
|
||||
$acc = new Account();
|
||||
// generator's public key must be valid
|
||||
|
||||
if (!$acc->valid_key($data['public_key'])) {
|
||||
@@ -274,12 +274,12 @@ class Block
|
||||
}
|
||||
|
||||
// get the mempool transactions
|
||||
$txn = new Transaction;
|
||||
$txn = new Transaction();
|
||||
$data = $txn->mempool($this->max_transactions());
|
||||
|
||||
|
||||
$difficulty = $this->difficulty();
|
||||
$acc = new Account;
|
||||
$acc = new Account();
|
||||
$generator = $acc->get_address($public_key);
|
||||
|
||||
// always sort the transactions in the same way
|
||||
@@ -397,8 +397,8 @@ class Block
|
||||
if ($data === false) {
|
||||
return false;
|
||||
}
|
||||
$acc = new Account;
|
||||
$trx = new Transaction;
|
||||
$acc = new Account();
|
||||
$trx = new Transaction();
|
||||
// no transactions means all are valid
|
||||
if (count($data) == 0) {
|
||||
return true;
|
||||
@@ -503,7 +503,7 @@ class Block
|
||||
$height = 2;
|
||||
}
|
||||
global $db;
|
||||
$trx = new Transaction;
|
||||
$trx = new Transaction();
|
||||
|
||||
$r = $db->run("SELECT * FROM blocks WHERE height>=:height ORDER by height DESC", [":height" => $height]);
|
||||
|
||||
@@ -538,7 +538,7 @@ class Block
|
||||
{
|
||||
|
||||
global $db;
|
||||
$trx = new Transaction;
|
||||
$trx = new Transaction();
|
||||
|
||||
$x = $db->row("SELECT * FROM blocks WHERE id=:id", [":id" => $id]);
|
||||
|
||||
@@ -599,7 +599,7 @@ class Block
|
||||
}
|
||||
|
||||
global $db;
|
||||
$trx = new Transaction;
|
||||
$trx = new Transaction();
|
||||
if (!empty($height)) {
|
||||
$block = $db->row("SELECT * FROM blocks WHERE height=:height", [":height" => $height]);
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@ $_config['db_connect']="mysql:host=localhost;dbname=ENTER-DB-NAME";
|
||||
$_config['db_user']="ENTER-DB-USER";
|
||||
$_config['db_pass']="ENTER-DB-PASS";
|
||||
|
||||
// Maximum number of connected peers
|
||||
// Maximum number of connected peers
|
||||
$_config['max_peers']=30;
|
||||
// Testnet, used for development
|
||||
$_config['testnet']=false;
|
||||
@@ -36,5 +36,3 @@ $_config['sanity_rebroadcast_locals']=true;
|
||||
$_config['enable_logging']=false;
|
||||
// log file, should not be publicly viewable
|
||||
$_config['log_file']="/var/log/aro.log";
|
||||
|
||||
?>
|
||||
|
||||
@@ -6,7 +6,7 @@ class Transaction
|
||||
public function reverse($block)
|
||||
{
|
||||
global $db;
|
||||
$acc = new Account;
|
||||
$acc = new Account();
|
||||
$r = $db->run("SELECT * FROM transactions WHERE block=:block", [":block" => $block]);
|
||||
foreach ($r as $x) {
|
||||
if (empty($x['src'])) {
|
||||
@@ -40,7 +40,7 @@ class Transaction
|
||||
public function clean_mempool()
|
||||
{
|
||||
global $db;
|
||||
$block = new Block;
|
||||
$block = new Block();
|
||||
$current = $block->current();
|
||||
$height = $current['height'];
|
||||
$limit = $height - 1000;
|
||||
@@ -51,7 +51,7 @@ class Transaction
|
||||
public function mempool($max)
|
||||
{
|
||||
global $db;
|
||||
$block = new Block;
|
||||
$block = new Block();
|
||||
$current = $block->current();
|
||||
$height = $current['height'] + 1;
|
||||
// only get the transactions that are not locked with a future height
|
||||
@@ -64,15 +64,16 @@ class Transaction
|
||||
$i = 0;
|
||||
$balance = [];
|
||||
foreach ($r as $x) {
|
||||
$trans = ["id" => $x['id'],
|
||||
"dst" => $x['dst'],
|
||||
"val" => $x['val'],
|
||||
"fee" => $x['fee'],
|
||||
"signature" => $x['signature'],
|
||||
"message" => $x['message'],
|
||||
"version" => $x['version'],
|
||||
"date" => $x['date'],
|
||||
"public_key" => $x['public_key'],
|
||||
$trans = [
|
||||
"id" => $x['id'],
|
||||
"dst" => $x['dst'],
|
||||
"val" => $x['val'],
|
||||
"fee" => $x['fee'],
|
||||
"signature" => $x['signature'],
|
||||
"message" => $x['message'],
|
||||
"version" => $x['version'],
|
||||
"date" => $x['date'],
|
||||
"public_key" => $x['public_key'],
|
||||
];
|
||||
|
||||
if ($i >= $max) {
|
||||
@@ -122,22 +123,23 @@ class Transaction
|
||||
public function add_mempool($x, $peer = "")
|
||||
{
|
||||
global $db;
|
||||
$block = new Block;
|
||||
$block = new Block();
|
||||
$current = $block->current();
|
||||
$height = $current['height'];
|
||||
$x['id'] = san($x['id']);
|
||||
$bind = [":peer" => $peer,
|
||||
":id" => $x['id'],
|
||||
"public_key" => $x['public_key'],
|
||||
":height" => $height,
|
||||
":src" => $x['src'],
|
||||
":dst" => $x['dst'],
|
||||
":val" => $x['val'],
|
||||
":fee" => $x['fee'],
|
||||
":signature" => $x['signature'],
|
||||
":version" => $x['version'],
|
||||
":date" => $x['date'],
|
||||
":message" => $x['message'],
|
||||
$bind = [
|
||||
":peer" => $peer,
|
||||
":id" => $x['id'],
|
||||
"public_key" => $x['public_key'],
|
||||
":height" => $height,
|
||||
":src" => $x['src'],
|
||||
":dst" => $x['dst'],
|
||||
":val" => $x['val'],
|
||||
":fee" => $x['fee'],
|
||||
":signature" => $x['signature'],
|
||||
":version" => $x['version'],
|
||||
":date" => $x['date'],
|
||||
":message" => $x['message'],
|
||||
];
|
||||
$db->run(
|
||||
"INSERT into mempool SET peer=:peer, id=:id, public_key=:public_key, height=:height, src=:src, dst=:dst, val=:val, fee=:fee, signature=:signature, version=:version, message=:message, `date`=:date",
|
||||
@@ -150,21 +152,22 @@ class Transaction
|
||||
public function add($block, $height, $x)
|
||||
{
|
||||
global $db;
|
||||
$acc = new Account;
|
||||
$acc = new Account();
|
||||
$acc->add($x['public_key'], $block);
|
||||
$acc->add_id($x['dst'], $block);
|
||||
$x['id'] = san($x['id']);
|
||||
$bind = [":id" => $x['id'],
|
||||
":public_key" => $x['public_key'],
|
||||
":height" => $height,
|
||||
":block" => $block,
|
||||
":dst" => $x['dst'],
|
||||
":val" => $x['val'],
|
||||
":fee" => $x['fee'],
|
||||
":signature" => $x['signature'],
|
||||
":version" => $x['version'],
|
||||
":date" => $x['date'],
|
||||
":message" => $x['message'],
|
||||
$bind = [
|
||||
":id" => $x['id'],
|
||||
":public_key" => $x['public_key'],
|
||||
":height" => $height,
|
||||
":block" => $block,
|
||||
":dst" => $x['dst'],
|
||||
":val" => $x['val'],
|
||||
":fee" => $x['fee'],
|
||||
":signature" => $x['signature'],
|
||||
":version" => $x['version'],
|
||||
":date" => $x['date'],
|
||||
":message" => $x['message'],
|
||||
];
|
||||
$res = $db->run(
|
||||
"INSERT into transactions SET id=:id, public_key=:public_key, block=:block, height=:height, dst=:dst, val=:val, fee=:fee, signature=:signature, version=:version, message=:message, `date`=:date",
|
||||
@@ -198,11 +201,11 @@ class Transaction
|
||||
{
|
||||
// if no specific block, use current
|
||||
if ($height === 0) {
|
||||
$block = new Block;
|
||||
$block = new Block();
|
||||
$current = $block->current();
|
||||
$height = $current['height'];
|
||||
}
|
||||
$acc = new Account;
|
||||
$acc = new Account();
|
||||
$info = $x['val']."-".$x['fee']."-".$x['dst']."-".$x['message']."-".$x['version']."-".$x['public_key']."-".$x['date'];
|
||||
|
||||
// the value must be >=0
|
||||
@@ -309,8 +312,8 @@ class Transaction
|
||||
public function get_transaction($id)
|
||||
{
|
||||
global $db;
|
||||
$acc = new Account;
|
||||
$block = new Block;
|
||||
$acc = new Account();
|
||||
$block = new Block();
|
||||
$current = $block->current();
|
||||
|
||||
$x = $db->row("SELECT * FROM transactions WHERE id=:id", [":id" => $id]);
|
||||
@@ -318,17 +321,18 @@ class Transaction
|
||||
if (!$x) {
|
||||
return false;
|
||||
}
|
||||
$trans = ["block" => $x['block'],
|
||||
"height" => $x['height'],
|
||||
"id" => $x['id'],
|
||||
"dst" => $x['dst'],
|
||||
"val" => $x['val'],
|
||||
"fee" => $x['fee'],
|
||||
"signature" => $x['signature'],
|
||||
"message" => $x['message'],
|
||||
"version" => $x['version'],
|
||||
"date" => $x['date'],
|
||||
"public_key" => $x['public_key'],
|
||||
$trans = [
|
||||
"block" => $x['block'],
|
||||
"height" => $x['height'],
|
||||
"id" => $x['id'],
|
||||
"dst" => $x['dst'],
|
||||
"val" => $x['val'],
|
||||
"fee" => $x['fee'],
|
||||
"signature" => $x['signature'],
|
||||
"message" => $x['message'],
|
||||
"version" => $x['version'],
|
||||
"date" => $x['date'],
|
||||
"public_key" => $x['public_key'],
|
||||
];
|
||||
$trans['src'] = $acc->get_address($x['public_key']);
|
||||
$trans['confirmations'] = $current['height'] - $x['height'];
|
||||
@@ -352,9 +356,9 @@ class Transaction
|
||||
public function get_transactions($height = "", $id = "")
|
||||
{
|
||||
global $db;
|
||||
$block = new Block;
|
||||
$block = new Block();
|
||||
$current = $block->current();
|
||||
$acc = new Account;
|
||||
$acc = new Account();
|
||||
$height = san($height);
|
||||
$id = san($id);
|
||||
if (empty($id) && empty($height)) {
|
||||
@@ -367,17 +371,18 @@ class Transaction
|
||||
}
|
||||
$res = [];
|
||||
foreach ($r as $x) {
|
||||
$trans = ["block" => $x['block'],
|
||||
"height" => $x['height'],
|
||||
"id" => $x['id'],
|
||||
"dst" => $x['dst'],
|
||||
"val" => $x['val'],
|
||||
"fee" => $x['fee'],
|
||||
"signature" => $x['signature'],
|
||||
"message" => $x['message'],
|
||||
"version" => $x['version'],
|
||||
"date" => $x['date'],
|
||||
"public_key" => $x['public_key'],
|
||||
$trans = [
|
||||
"block" => $x['block'],
|
||||
"height" => $x['height'],
|
||||
"id" => $x['id'],
|
||||
"dst" => $x['dst'],
|
||||
"val" => $x['val'],
|
||||
"fee" => $x['fee'],
|
||||
"signature" => $x['signature'],
|
||||
"message" => $x['message'],
|
||||
"version" => $x['version'],
|
||||
"date" => $x['date'],
|
||||
"public_key" => $x['public_key'],
|
||||
];
|
||||
$trans['src'] = $acc->get_address($x['public_key']);
|
||||
$trans['confirmations'] = $current['height'] - $x['height'];
|
||||
@@ -407,17 +412,18 @@ class Transaction
|
||||
if (!$x) {
|
||||
return false;
|
||||
}
|
||||
$trans = ["block" => $x['block'],
|
||||
"height" => $x['height'],
|
||||
"id" => $x['id'],
|
||||
"dst" => $x['dst'],
|
||||
"val" => $x['val'],
|
||||
"fee" => $x['fee'],
|
||||
"signature" => $x['signature'],
|
||||
"message" => $x['message'],
|
||||
"version" => $x['version'],
|
||||
"date" => $x['date'],
|
||||
"public_key" => $x['public_key'],
|
||||
$trans = [
|
||||
"block" => $x['block'],
|
||||
"height" => $x['height'],
|
||||
"id" => $x['id'],
|
||||
"dst" => $x['dst'],
|
||||
"val" => $x['val'],
|
||||
"fee" => $x['fee'],
|
||||
"signature" => $x['signature'],
|
||||
"message" => $x['message'],
|
||||
"version" => $x['version'],
|
||||
"date" => $x['date'],
|
||||
"public_key" => $x['public_key'],
|
||||
];
|
||||
$trans['src'] = $x['src'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user