main_unlock();
        exit;
    }
    debug_print($max_other_currencies_votes, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    $total_count_currencies = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT count(`id`)\n\t\t\tFROM `" . DB_PREFIX . "currency`\n\t\t\t", 'fetch_one');
    foreach ($max_other_currencies_votes as $currency_id => $count_and_votes) {
        $new_max_other_currencies[$currency_id] = get_max_vote($count_and_votes, 0, $total_count_currencies, 10);
    }
    if (get_community_users($db)) {
        $my_prefix = $testBlock->user_id . '_';
    } else {
        $my_prefix = '';
    }
    $node_private_key = get_node_private_key($db, $my_prefix);
    $json_data = json_encode($new_max_other_currencies);
    // подписываем нашим нод-ключем данные транзакции
    $data_for_sign = ParseData::findType('new_max_other_currencies') . ",{$time},{$my_user_id},{$json_data}";
    $rsa = new Crypt_RSA();
    $rsa->loadKey($node_private_key);
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $signature = $rsa->sign($data_for_sign);
    debug_print('$data_for_sign=' . $data_for_sign . "\n", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    // создаем тр-ию. пишем $block_id, на момент которого были актуальны голоса в табле 'pct'
    $data = dec_binary(ParseData::findType('new_max_other_currencies'), 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($json_data) . ParseData::encode_length_plus_data($signature);
    $hash = ParseData::dsha256($data);
    insert_tx($data, $db);
    $new_tx_data['data'] = $data;
    $new_tx_data['hash'] = hextobin(md5($data));
    tx_parser($new_tx_data, true);
}
main_unlock();
Example #2
0
//print $reduction_pct."\n";
//print $reduction_type."\n";
//print $reduction_currency_id."\n";
if (isset($reduction_currency_id) && isset($reduction_pct)) {
    if (get_community_users($db)) {
        $my_prefix = $testBlock->user_id . '_';
    } else {
        $my_prefix = '';
    }
    $node_private_key = get_node_private_key($db, $my_prefix);
    print $my_prefix . "\n";
    // подписываем нашим нод-ключем данные транзакции
    $data_for_sign = ParseData::findType('new_reduction') . ",{$time},{$my_user_id},{$reduction_currency_id},{$reduction_pct},{$reduction_type}";
    $rsa = new Crypt_RSA();
    $rsa->loadKey($node_private_key);
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $signature = $rsa->sign($data_for_sign);
    debug_print('$data_for_sign=' . $data_for_sign . "\n", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    print $data_for_sign;
    print $node_private_key;
    // создаем тр-ию. пишем $block_id, на момент которого были актуальны голоса и статусы банкнот
    $reduction_tx_data = dec_binary(ParseData::findType('new_reduction'), 1) . dec_binary($time, 4) . ParseData::encode_length_plus_data($my_user_id) . ParseData::encode_length_plus_data($reduction_currency_id) . ParseData::encode_length_plus_data($reduction_pct) . ParseData::encode_length_plus_data($reduction_type) . ParseData::encode_length_plus_data($signature);
    insert_tx($reduction_tx_data, $db);
    // и не закрывая main_lock переводим нашу тр-ию в verified=1, откатив все несовместимые тр-ии
    // таким образом у нас будут в блоке только актуальные голоса.
    // а если придет другой блок и станет verified=0, то эта тр-ия просто удалится.
    $new_tx_data['data'] = $reduction_tx_data;
    $new_tx_data['hash'] = hextobin(md5($reduction_tx_data));
    tx_parser($new_tx_data, true);
}
main_unlock();