commit
68d874b15a
@ -39,9 +39,8 @@ if ( $bitcoin->can_connect() === true ){
|
|||||||
|
|
||||||
// Nothing to do so bail out
|
// Nothing to do so bail out
|
||||||
if (empty($aTransactions['transactions'])) {
|
if (empty($aTransactions['transactions'])) {
|
||||||
verbose("No new transactions since last block\n");
|
verbose("No new RPC transactions since last block\n");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Table header
|
// Table header
|
||||||
verbose("Blockhash\t\tHeight\tAmount\tConfirmations\tDiff\t\tTime\t\t\tStatus\n");
|
verbose("Blockhash\t\tHeight\tAmount\tConfirmations\tDiff\t\tTime\t\t\tStatus\n");
|
||||||
|
|
||||||
@ -66,65 +65,65 @@ if (empty($aTransactions['transactions'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verbose("\n\n");
|
verbose("\n");
|
||||||
// Now with our blocks added we can scan for their upstream shares
|
// Now with our blocks added we can scan for their upstream shares
|
||||||
$aAllBlocks = $block->getAllUnaccounted('ASC');
|
$aAllBlocks = $block->getAllUnaccounted('ASC');
|
||||||
if (empty($aAllBlocks)) {
|
if (empty($aAllBlocks)) {
|
||||||
verbose("No new unaccounted blocks found\n");
|
verbose("No new unaccounted blocks found\n");
|
||||||
}
|
} else {
|
||||||
|
// Loop through our unaccounted blocks
|
||||||
|
verbose("\nBlock ID\tBlock Height\tShare ID\tShares\tFinder\t\t\tStatus\n");
|
||||||
|
foreach ($aAllBlocks as $iIndex => $aBlock) {
|
||||||
|
if (empty($aBlock['share_id'])) {
|
||||||
|
// Fetch this blocks upstream ID
|
||||||
|
if ($share->setUpstream($block->getLastUpstreamId())) {
|
||||||
|
$iCurrentUpstreamId = $share->getUpstreamId();
|
||||||
|
$iAccountId = $user->getUserId($share->getUpstreamFinder());
|
||||||
|
} else {
|
||||||
|
verbose("\nUnable to fetch blocks upstream share. Aborting!\n");
|
||||||
|
verbose($share->getError() . "\n");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
// Fetch share information
|
||||||
|
if (!$iPreviousShareId = $block->getLastShareId()) {
|
||||||
|
$iPreviousShareId = 0;
|
||||||
|
verbose("\nUnable to find highest share ID found so far\n");
|
||||||
|
verbose("If this is your first block, this is normal\n\n");
|
||||||
|
}
|
||||||
|
$iRoundShares = $share->getRoundShares($iPreviousShareId, $iCurrentUpstreamId);
|
||||||
|
|
||||||
// Loop through our unaccounted blocks
|
// Store new information
|
||||||
verbose("Block ID\tBlock Height\tShare ID\tShares\tFinder\t\t\tStatus\n");
|
$strStatus = "OK";
|
||||||
foreach ($aAllBlocks as $iIndex => $aBlock) {
|
if (!$block->setShareId($aBlock['id'], $iCurrentUpstreamId))
|
||||||
if (empty($aBlock['share_id'])) {
|
$strStatus = "Share ID Failed";
|
||||||
// Fetch this blocks upstream ID
|
if (!$block->setFinder($aBlock['id'], $iAccountId))
|
||||||
if ($share->setUpstream($block->getLastUpstreamId())) {
|
$strStatus = "Finder Failed";
|
||||||
$iCurrentUpstreamId = $share->getUpstreamId();
|
if (!$block->setShares($aBlock['id'], $iRoundShares))
|
||||||
$iAccountId = $user->getUserId($share->getUpstreamFinder());
|
$strStatus = "Shares Failed";
|
||||||
} else {
|
if ($config['block_bonus'] > 0 && !$transaction->addTransaction($iAccountId, $config['block_bonus'], 'Bonus', $aBlock['id'])) {
|
||||||
verbose("Unable to fetch blocks upstream share\n");
|
$strStatus = "Bonus Failed";
|
||||||
verbose($share->getError() . "\n");
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Fetch share information
|
|
||||||
if (!$iPreviousShareId = $block->getLastShareId()) {
|
|
||||||
$iPreviousShareId = 0;
|
|
||||||
verbose("\nUnable to find highest share ID found so far\n");
|
|
||||||
verbose("If this is your first block, this is normal\n\n");
|
|
||||||
}
|
|
||||||
$iRoundShares = $share->getRoundShares($iPreviousShareId, $iCurrentUpstreamId);
|
|
||||||
|
|
||||||
// Store new information
|
verbose(
|
||||||
$strStatus = "OK";
|
$aBlock['id'] . "\t\t"
|
||||||
if (!$block->setShareId($aBlock['id'], $iCurrentUpstreamId))
|
. $aBlock['height'] . "\t\t"
|
||||||
$strStatus = "Share ID Failed";
|
. $iCurrentUpstreamId . "\t\t"
|
||||||
if (!$block->setFinder($aBlock['id'], $iAccountId))
|
. $iRoundShares . "\t"
|
||||||
$strStatus = "Finder Failed";
|
. "[$iAccountId] " . $user->getUserName($iAccountId) . "\t\t"
|
||||||
if (!$block->setShares($aBlock['id'], $iRoundShares))
|
. $strStatus
|
||||||
$strStatus = "Shares Failed";
|
. "\n"
|
||||||
if ($config['block_bonus'] > 0 && !$transaction->addTransaction($iAccountId, $config['block_bonus'], 'Bonus', $aBlock['id'])) {
|
);
|
||||||
$strStatus = "Bonus Failed";
|
|
||||||
}
|
|
||||||
|
|
||||||
verbose(
|
// Notify users
|
||||||
$aBlock['id'] . "\t\t"
|
$aAccounts = $notification->getNotificationAccountIdByType('new_block');
|
||||||
. $aBlock['height'] . "\t\t"
|
if (is_array($aAccounts)) {
|
||||||
. $iCurrentUpstreamId . "\t\t"
|
foreach ($aAccounts as $account_id) {
|
||||||
. $iRoundShares . "\t"
|
$aMailData['height'] = $aBlock['height'];
|
||||||
. "[$iAccountId] " . $user->getUserName($iAccountId) . "\t\t"
|
$aMailData['subject'] = 'New Block';
|
||||||
. $strStatus
|
$aMailData['email'] = $user->getUserEmail($user->getUserName($account_id));
|
||||||
. "\n"
|
$aMailData['shares'] = $iRoundShares;
|
||||||
);
|
$notification->sendNotification($account_id, 'new_block', $aMailData);
|
||||||
|
}
|
||||||
// Notify users
|
|
||||||
$aAccounts = $notification->getNotificationAccountIdByType('new_block');
|
|
||||||
if (is_array($aAccounts)) {
|
|
||||||
foreach ($aAccounts as $account_id) {
|
|
||||||
$aMailData['height'] = $aBlock['height'];
|
|
||||||
$aMailData['subject'] = 'New Block';
|
|
||||||
$aMailData['email'] = $user->getUserEmail($user->getUserName($account_id));
|
|
||||||
$aMailData['shares'] = $iRoundShares;
|
|
||||||
$notification->sendNotification($account_id, 'new_block', $aMailData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -187,7 +187,8 @@ class Share {
|
|||||||
ORDER BY id ASC LIMIT 1");
|
ORDER BY id ASC LIMIT 1");
|
||||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $last) && $stmt->execute() && $result = $stmt->get_result()) {
|
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $last) && $stmt->execute() && $result = $stmt->get_result()) {
|
||||||
$this->oUpstream = $result->fetch_object();
|
$this->oUpstream = $result->fetch_object();
|
||||||
return true;
|
if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
// Catchall
|
// Catchall
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user