Adding support for block finder bonus
* Added new configuration option `block_bonus`, see `global.inc.dist.php`, default 0 * Added new transaction types: `Bonus` and `Orphan_Bonus` * Changes transaction table structure, added upgrade SQL * Changed findblock cron to credit bonus to finder * Modified transactions class to reflect changes Fixes #148
This commit is contained in:
parent
bc485ec213
commit
4e284895a8
@ -102,6 +102,9 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
|
|||||||
$strStatus = "Finder Failed";
|
$strStatus = "Finder Failed";
|
||||||
if (!$block->setShares($aBlock['id'], $iRoundShares))
|
if (!$block->setShares($aBlock['id'], $iRoundShares))
|
||||||
$strStatus = "Shares Failed";
|
$strStatus = "Shares Failed";
|
||||||
|
if ($config['block_bonus'] > 0 && !$transaction->addTransaction($iAccountId, $config['block_bonus'], 'Bonus', $aBlock['id'])) {
|
||||||
|
$strStatus = "Bonus Failed";
|
||||||
|
}
|
||||||
|
|
||||||
verbose(
|
verbose(
|
||||||
$aBlock['id'] . "\t\t"
|
$aBlock['id'] . "\t\t"
|
||||||
@ -115,13 +118,16 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
|
|||||||
|
|
||||||
// Notify users
|
// Notify users
|
||||||
$aAccounts = $notification->getNotificationAccountIdByType('new_block');
|
$aAccounts = $notification->getNotificationAccountIdByType('new_block');
|
||||||
foreach ($aAccounts as $account_id) {
|
if (is_array($aAccounts)) {
|
||||||
$aMailData['height'] = $aBlock['height'];
|
foreach ($aAccounts as $account_id) {
|
||||||
$aMailData['subject'] = 'New Block';
|
$aMailData['height'] = $aBlock['height'];
|
||||||
$aMailData['email'] = $user->getUserEmail($user->getUserName($account_id));
|
$aMailData['subject'] = 'New Block';
|
||||||
$aMailData['shares'] = $iRoundShares;
|
$aMailData['email'] = $user->getUserEmail($user->getUserName($account_id));
|
||||||
$notification->sendNotification($account_id, 'new_block', $aMailData);
|
$aMailData['shares'] = $iRoundShares;
|
||||||
|
$notification->sendNotification($account_id, 'new_block', $aMailData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -55,35 +55,23 @@ class Transaction {
|
|||||||
**/
|
**/
|
||||||
public function setOrphan($block_id) {
|
public function setOrphan($block_id) {
|
||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$this->debug->append("STA " . __METHOD__, 4);
|
||||||
$stmt = $this->mysqli->prepare("
|
$aOrphans = array(
|
||||||
UPDATE $this->table
|
'Credit' => 'Orphan_Credit',
|
||||||
SET type = 'Orphan_Credit'
|
'Fee' => 'Orphan_Fee',
|
||||||
WHERE type = 'Credit'
|
'Donation' => 'Orphan_Donation',
|
||||||
AND block_id = ?
|
'Bonus' => 'Orphan_Bonus'
|
||||||
");
|
);
|
||||||
if (!($this->checkStmt($stmt) && $stmt->bind_param('i', $block_id) && $stmt->execute())) {
|
foreach ($aOrphans as $from => $to) {
|
||||||
$this->debug->append("Failed to set orphan credit transactions for $block_id");
|
$stmt = $this->mysqli->prepare("
|
||||||
return false;
|
UPDATE $this->table
|
||||||
}
|
SET type = '$to'
|
||||||
$stmt = $this->mysqli->prepare("
|
WHERE type = '$from'
|
||||||
UPDATE $this->table
|
AND block_id = ?
|
||||||
SET type = 'Orphan_Fee'
|
");
|
||||||
WHERE type = 'Fee'
|
if (!($this->checkStmt($stmt) && $stmt->bind_param('i', $block_id) && $stmt->execute())) {
|
||||||
AND block_id = ?
|
$this->debug->append("Failed to set orphan $from => $to transactions for $block_id");
|
||||||
");
|
return false;
|
||||||
if (!($this->checkStmt($stmt) && $stmt->bind_param('i', $block_id) && $stmt->execute())) {
|
}
|
||||||
$this->debug->append("Failed to set orphan fee transactions for $block_id");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$stmt = $this->mysqli->prepare("
|
|
||||||
UPDATE $this->table
|
|
||||||
SET type = 'Orphan_Donation'
|
|
||||||
WHERE type = 'Donation'
|
|
||||||
AND block_id = ?
|
|
||||||
");
|
|
||||||
if (!($this->checkStmt($stmt) && $stmt->bind_param('i', $block_id) && $stmt->execute())) {
|
|
||||||
$this->debug->append("Failed to set orphan donation transactions for $block_id");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -143,7 +131,7 @@ class Transaction {
|
|||||||
SELECT sum(t.amount) AS credit
|
SELECT sum(t.amount) AS credit
|
||||||
FROM $this->table AS t
|
FROM $this->table AS t
|
||||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||||
WHERE t.type = 'Credit'
|
WHERE t.type IN ('Credit','Bonus')
|
||||||
AND b.confirmations >= " . $this->config['confirmations'] . "
|
AND b.confirmations >= " . $this->config['confirmations'] . "
|
||||||
) AS t1,
|
) AS t1,
|
||||||
(
|
(
|
||||||
@ -180,7 +168,7 @@ class Transaction {
|
|||||||
SELECT sum(t.amount) AS credit
|
SELECT sum(t.amount) AS credit
|
||||||
FROM $this->table AS t
|
FROM $this->table AS t
|
||||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||||
WHERE t.type = 'Credit'
|
WHERE t.type IN ('Credit','Bonus')
|
||||||
AND b.confirmations >= ?
|
AND b.confirmations >= ?
|
||||||
AND t.account_id = ?
|
AND t.account_id = ?
|
||||||
) AS t1,
|
) AS t1,
|
||||||
|
|||||||
@ -34,6 +34,7 @@ $config = array(
|
|||||||
'slogan' => 'Resistance is futile',
|
'slogan' => 'Resistance is futile',
|
||||||
'email' => 'test@example.com', // Mail address used for notifications
|
'email' => 'test@example.com', // Mail address used for notifications
|
||||||
),
|
),
|
||||||
|
'block_bonus' => 0,
|
||||||
'archive_shares' => true, // Store accounted shares in archive table?
|
'archive_shares' => true, // Store accounted shares in archive table?
|
||||||
'blockexplorer' => 'http://explorer.litecoin.net/search?q=', // URL for block searches, prefixed to each block number
|
'blockexplorer' => 'http://explorer.litecoin.net/search?q=', // URL for block searches, prefixed to each block number
|
||||||
'chaininfo' => 'http://allchains.info', // Link to Allchains for Difficulty information
|
'chaininfo' => 'http://allchains.info', // Link to Allchains for Difficulty information
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
<tbody style="font-size:12px;">
|
<tbody style="font-size:12px;">
|
||||||
{section transaction $TRANSACTIONS}
|
{section transaction $TRANSACTIONS}
|
||||||
{if (
|
{if (
|
||||||
($TRANSACTIONS[transaction].type == 'Credit' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
(($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus')and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
||||||
or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
||||||
or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
||||||
or $TRANSACTIONS[transaction].type == 'Debit_AP'
|
or $TRANSACTIONS[transaction].type == 'Debit_AP'
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||||
<td><font color="{if $TRANSACTIONS[transaction].type == Credit}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/if}
|
{/if}
|
||||||
{/section}
|
{/section}
|
||||||
@ -58,7 +58,7 @@
|
|||||||
<tbody style="font-size:12px;">
|
<tbody style="font-size:12px;">
|
||||||
{section transaction $TRANSACTIONS}
|
{section transaction $TRANSACTIONS}
|
||||||
{if (
|
{if (
|
||||||
$TRANSACTIONS[transaction].type == 'Credit' && $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations
|
($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations
|
||||||
or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations)
|
or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations)
|
||||||
or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations)
|
or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations)
|
||||||
)}
|
)}
|
||||||
@ -68,9 +68,9 @@
|
|||||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||||
<td><font color="{if $TRANSACTIONS[transaction].type == Credit}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{if $TRANSACTIONS[transaction].type == Credit}
|
{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}
|
||||||
{assign var="credits" value="`$credits+$TRANSACTIONS[transaction].amount`"}
|
{assign var="credits" value="`$credits+$TRANSACTIONS[transaction].amount`"}
|
||||||
{else}
|
{else}
|
||||||
{assign var="debits" value="`$debits+$TRANSACTIONS[transaction].amount`"}
|
{assign var="debits" value="`$debits+$TRANSACTIONS[transaction].amount`"}
|
||||||
@ -106,6 +106,7 @@
|
|||||||
$TRANSACTIONS[transaction].type == 'Orphan_Credit'
|
$TRANSACTIONS[transaction].type == 'Orphan_Credit'
|
||||||
or $TRANSACTIONS[transaction].type == 'Orphan_Donation'
|
or $TRANSACTIONS[transaction].type == 'Orphan_Donation'
|
||||||
or $TRANSACTIONS[transaction].type == 'Orphan_Fee'
|
or $TRANSACTIONS[transaction].type == 'Orphan_Fee'
|
||||||
|
or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'
|
||||||
)}
|
)}
|
||||||
<tr class="{cycle values="odd,even"}">
|
<tr class="{cycle values="odd,even"}">
|
||||||
<td>{$TRANSACTIONS[transaction].id}</td>
|
<td>{$TRANSACTIONS[transaction].id}</td>
|
||||||
@ -113,9 +114,9 @@
|
|||||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||||
<td><font color="{if $TRANSACTIONS[transaction].type == Orphan_Credit}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
<td><font color="{if $TRANSACTIONS[transaction].type == 'Orphan_Credit' or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{if $TRANSACTIONS[transaction].type == Orphan_Credit}
|
{if $TRANSACTIONS[transaction].type == 'Orphan_Credit' or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'}
|
||||||
{assign var="orphan_credits" value="`$orphan_credits+$TRANSACTIONS[transaction].amount`"}
|
{assign var="orphan_credits" value="`$orphan_credits+$TRANSACTIONS[transaction].amount`"}
|
||||||
{else}
|
{else}
|
||||||
{assign var="orphan_debits" value="`$orphan_debits+$TRANSACTIONS[transaction].amount`"}
|
{assign var="orphan_debits" value="`$orphan_debits+$TRANSACTIONS[transaction].amount`"}
|
||||||
|
|||||||
1
sql/issue_148_transactions_upgrade.sql
Normal file
1
sql/issue_148_transactions_upgrade.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `transactions` CHANGE `type` `type` ENUM( 'Credit', 'Debit_MP', 'Debit_AP', 'Donation', 'Fee', 'Orphan_Credit', 'Orphan_Fee', 'Orphan_Donation', 'Bonus', 'Orphan_Bonus' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
|
||||||
Loading…
Reference in New Issue
Block a user