cryptonote::Transaction convertTx(ITransactionReader& tx) { auto blob = tx.getTransactionData(); cryptonote::blobdata data(reinterpret_cast<const char*>(blob.data()), blob.size()); cryptonote::Transaction oldTx; cryptonote::parse_and_validate_tx_from_blob(data, oldTx); // ignore return code return oldTx; }
std::error_code submitTransaction(ITransactionReader& tx) { auto data = tx.getTransactionData(); cryptonote::blobdata txblob(data.data(), data.data() + data.size()); cryptonote::Transaction outTx; cryptonote::parse_and_validate_tx_from_blob(txblob, outTx); std::promise<std::error_code> result; m_node.relayTransaction(outTx, [&result](std::error_code ec) { std::promise<std::error_code> detachedPromise = std::move(result); detachedPromise.set_value(ec); }); return result.get_future().get(); }
std::error_code submitTransaction(INode& node, ITransactionReader& tx) { auto data = tx.getTransactionData(); CryptoNote::Transaction outTx; fromBinaryArray(outTx, data); LOG_DEBUG("Submitting transaction " + Common::toHex(tx.getTransactionHash().data, 32)); std::promise<std::error_code> result; node.relayTransaction(outTx, [&result](std::error_code ec) { result.set_value(ec); }); auto err = result.get_future().get(); if (err) { LOG_DEBUG("Error: " + err.message()); } else { LOG_DEBUG("Submitted successfully"); } return err; }
std::error_code submitTransaction(INode& node, ITransactionReader& tx) { auto data = tx.getTransactionData(); cryptonote::blobdata txblob(data.data(), data.data() + data.size()); cryptonote::Transaction outTx; cryptonote::parse_and_validate_tx_from_blob(txblob, outTx); LOG_DEBUG("Submitting transaction " + bin2str(tx.getTransactionHash())); std::promise<std::error_code> result; node.relayTransaction(outTx, [&result](std::error_code ec) { result.set_value(ec); }); auto err = result.get_future().get(); if (err) { LOG_DEBUG("Error: " + err.message()); } else { LOG_DEBUG("Submitted successfully"); } return err; }