debug_print($urls, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $rez = m_curl($urls, $to_be_sent, $db, 'data', 20, true); debug_print($rez, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); } } else { // если просто юзер или работаю в защищенном режиме, то шлю тр-ии целиком. слать блоки не имею права. if ($my_config['local_gate_ip']) { $gate = 'protected_gate_tx.php'; // Чтобы protected_gate_tx.php мог понять, какому ноду слать эту тр-ию, пишем в первые 100 байт host $remote_node_host = $node_data['host']; } else { $gate = 'gate_tx.php'; $remote_node_host = ''; } for ($i = 0; $i < sizeof($hosts); $i++) { $urls[$i] = array('url' => $hosts[$i]['host'] . $gate, 'node_public_key' => $hosts[$i]['node_public_key'], 'user_id' => $hosts[$i]['user_id']); } debug_print($urls, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); // возьмем хэши и сами тр-ии $tx_data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `hash`, `data`\n\t\t\t\tFROM `" . DB_PREFIX . "transactions`\n\t\t\t\tWHERE `sent` = 0\n\t\t\t\t", 'fetch_array'); debug_print('$tx_data: ' . print_r_hex($tx_data), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); if ($tx_data['hash']) { $hex_hash = bin2hex($tx_data['hash']); $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tUPDATE `" . DB_PREFIX . "transactions`\n\t\t\t\t\tSET `sent` = 1\n\t\t\t\t\tWHERE `hash` = 0x{$hex_hash}\n\t\t\t\t\t"); // в первые 5 байт tx_data['data'] m_curl допишет user_id получателя, если вдруг там пул $rez = m_curl($urls, $tx_data['data'], $db, 'data', 20, true, true, $remote_node_host); debug_print($rez, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); } } sleep(1); }
// наш последний блок-1 $block_id = get_block_id($db) - 1; if ($block_id < 1) { exit; } $hash = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `hash`\n\t\tFROM `" . DB_PREFIX . "block_chain`\n\t\tWHERE `id`= {$block_id}\n\t\t", 'fetch_one'); $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `host`,\n\t\t\t\t\t `user_id`\n\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\tWHERE `miner_id`> 0\n\t\tGROUP BY `host`\n\t\tORDER BY RAND()\n\t\tLIMIT " . COUNT_CONFIRMED_NODES . "\n\t\t"); $i = 0; $urls = array(); while ($row = $db->fetchArray($res)) { $urls[$i]['url'] = $row['host'] . 'tools/check_node.php?block_id=' . $block_id; $urls[$i]['user_id'] = $row['user_id']; $i++; } if (empty($urls)) { exit; } print_R($urls); $result = m_curl($urls, '', '', '', 10, true, false); debug_print("result=" . print_r_hex($result), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); print_R($result); $status[0] = 0; $status[1] = 0; foreach ($result as $user_id => $answer) { if ($answer != $hash) { $status[0]++; } else { $status[1]++; } } $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tINSERT INTO `" . DB_PREFIX . "confirmations` (\n\t\t\t`block_id`,\n\t\t\t`good`,\n\t\t\t`bad`,\n\t\t\t`time`\n\t\t)\n\t\tVALUES (\n\t\t\t{$block_id},\n\t\t\t" . intval($status[1]) . ",\n\t\t\t" . intval($status[0]) . ",\n\t\t\t" . time() . "\n\t\t)\n\t\tON DUPLICATE KEY UPDATE `good` = {$status[1]}, `bad` = {$status[0]}, `time` = " . time() . "\n\t\t");
/** * Get some information about the instance * * fancy urls, bookmark plugin, api root */ function poke($username, $domain) { global $err; $instanceInfo = array(); // Get HTML $html = m_curl($domain); if ($html === false) { // $err set by m_curl return false; } // Build DOM $doc = new DOMDocument(); $doc->loadHTML($html, LIBXML_NOWARNING); // Get RSD uri $xpath = new DOMXpath($doc); $nodes = $xpath->query('//html/head/link[@rel="EditURI"]/@href'); if ($nodes === false || $nodes->length === 0) { $err = 'Unable to find EditURI value for RSD'; return false; } $editURI = $nodes->item(0)->nodeValue; // Fetch RSD xml $rsd = m_curl($editURI); if ($rsd === false) { // $err set by m_curl return false; } // Get API root $xml = simplexml_load_string($rsd); $xml->registerXPathNamespace('rsd', 'http://archipelago.phrasewise.com/rsd'); $elems = $xml->xpath('//rsd:apis/rsd:api[@name="Twitter"]/@apiLink'); if ($elems === false || count($elems) === 0) { $err = 'Unable to find API root'; return false; } $apiRoot = (string) $elems[0]; $instanceInfo['apiRoot'] = $apiRoot; // Get instance configs $json = m_curl($apiRoot . 'statusnet/config.json'); if ($json === false) { // $err set by m_curl return false; } $json = json_decode($json); // Are fancy URLs enabled? if ($json->site->fancy === null) { // Assume they're enabled if we couldn't verify $instanceInfo['fancy'] = true; } else { $instanceInfo['fancy'] = (bool) $json->site->fancy; } // TODO: don't check this if m_get('bookmark') is null // this means the JS will need to include 'bookmark' param when querying // Is the bookmark plugin enabled? $json = m_curl($apiRoot . 'bookmarks/' . $username . '.json', true); if ($json === false) { // Assume it's not enabled if we couldn't verify $instanceInfo['bookmarks'] = false; } else { $instanceInfo['bookmarks'] = true; } return $instanceInfo; }
continue; } //print "id майнеров, которые на нашем уровне\n"; debug_print($nodes_ids, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); $add_sql = ''; for ($i = 0; $i < sizeof($nodes_ids); $i++) { $add_sql .= "{$nodes_ids[$i]},"; } $add_sql = substr($add_sql, 0, strlen($add_sql) - 1); if (!$add_sql) { debug_print("continue", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); sleep(1); continue; } // получим хосты майнеров, которые на нашем уровне $res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tSELECT `host`\n\t\t\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\t\t\tWHERE `user_id` IN ({$add_sql})\n\t\t\t\t\t"); while ($row = $db->fetchArray($res)) { $urls[]['url'] = $row['host'] . 'gate_testblock.php'; } // шлем block_id, user_id, mrkl_root, signature $data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT `block_id`, `time`, `user_id`, `mrkl_root`, `signature`\n\t\t\tFROM `" . DB_PREFIX . "testblock`\n\t\t\tWHERE `status` = 'active'\n\t\t\t", 'fetch_array'); //print_r($data); //print_R($urls); if ($data) { $data_binary = dec_binary($data['block_id'], 4) . dec_binary($data['time'], 4) . dec_binary($data['user_id'], 5) . $data['mrkl_root'] . ParseData::encode_length_plus_data($data['signature']); m_curl($urls, $data_binary, '', 'data', 30); } //else debug_print("END", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__); sleep(1); } while (true);