本文整理汇总了C++中BinaryArray::data方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryArray::data方法的具体用法?C++ BinaryArray::data怎么用?C++ BinaryArray::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryArray
的用法示例。
在下文中一共展示了BinaryArray::data方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepareAndSubmitBlock
bool BaseFunctionalTests::prepareAndSubmitBlock(TestNode& node, CryptoNote::Block&& blockTemplate) {
blockTemplate.timestamp = m_nextTimestamp;
m_nextTimestamp += 2 * m_currency.difficultyTarget();
BinaryArray blockBlob = CryptoNote::toBinaryArray(blockTemplate);
return node.submitBlock(::Common::toHex(blockBlob.data(), blockBlob.size()));
}
示例2: on_get_transactions
bool RpcServer::on_get_transactions(const COMMAND_RPC_GET_TRANSACTIONS::request& req, COMMAND_RPC_GET_TRANSACTIONS::response& res) {
std::vector<Hash> vh;
for (const auto& tx_hex_str : req.txs_hashes) {
BinaryArray b;
if (!fromHex(tx_hex_str, b))
{
res.status = "Failed to parse hex representation of transaction hash";
return true;
}
if (b.size() != sizeof(Hash))
{
res.status = "Failed, size of data mismatch";
}
vh.push_back(*reinterpret_cast<const Hash*>(b.data()));
}
std::list<Hash> missed_txs;
std::list<Transaction> txs;
m_core.getTransactions(vh, txs, missed_txs);
for (auto& tx : txs) {
res.txs_as_hex.push_back(toHex(toBinaryArray(tx)));
}
for (const auto& miss_tx : missed_txs) {
res.missed_tx.push_back(Common::podToHex(miss_tx));
}
res.status = CORE_RPC_STATUS_OK;
return true;
}
示例3: parseAndValidateTransactionFromBinaryArray
bool parseAndValidateTransactionFromBinaryArray(const BinaryArray& tx_blob, Transaction& tx, Hash& tx_hash, Hash& tx_prefix_hash) {
if (!fromBinaryArray(tx, tx_blob)) {
return false;
}
//TODO: validate tx
cn_fast_hash(tx_blob.data(), tx_blob.size(), tx_hash);
getObjectHash(*static_cast<TransactionPrefix*>(&tx), tx_prefix_hash);
return true;
}
示例4: sendReply
void LevinProtocol::sendReply(uint32_t command, const BinaryArray& out, int32_t returnCode) {
bucket_head2 head = { 0 };
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = out.size();
head.m_have_to_return_data = false;
head.m_command = command;
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
head.m_flags = LEVIN_PACKET_RESPONSE;
head.m_return_code = returnCode;
BinaryArray writeBuffer;
writeBuffer.reserve(sizeof(head) + out.size());
Common::VectorOutputStream stream(writeBuffer);
stream.writeSome(&head, sizeof(head));
stream.writeSome(out.data(), out.size());
writeStrict(writeBuffer.data(), writeBuffer.size());
}
示例5: sendMessage
void LevinProtocol::sendMessage(uint32_t command, const BinaryArray& out, bool needResponse) {
bucket_head2 head = { 0 };
head.m_signature = LEVIN_SIGNATURE;
head.m_cb = out.size();
head.m_have_to_return_data = needResponse;
head.m_command = command;
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
head.m_flags = LEVIN_PACKET_REQUEST;
// write header and body in one operation
BinaryArray writeBuffer;
writeBuffer.reserve(sizeof(head) + out.size());
Common::VectorOutputStream stream(writeBuffer);
stream.writeSome(&head, sizeof(head));
stream.writeSome(out.data(), out.size());
writeStrict(writeBuffer.data(), writeBuffer.size());
}
示例6: appendMergeMiningTagToExtra
bool appendMergeMiningTagToExtra(std::vector<uint8_t>& tx_extra, const TransactionExtraMergeMiningTag& mm_tag) {
BinaryArray blob;
if (!toBinaryArray(mm_tag, blob)) {
return false;
}
tx_extra.push_back(TX_EXTRA_MERGE_MINING_TAG);
std::copy(reinterpret_cast<const uint8_t*>(blob.data()), reinterpret_cast<const uint8_t*>(blob.data() + blob.size()), std::back_inserter(tx_extra));
return true;
}
示例7: append_message_to_extra
bool append_message_to_extra(std::vector<uint8_t>& tx_extra, const tx_extra_message& message) {
BinaryArray blob;
if (!toBinaryArray(message, blob)) {
return false;
}
tx_extra.reserve(tx_extra.size() + 1 + blob.size());
tx_extra.push_back(TX_EXTRA_MESSAGE_TAG);
std::copy(reinterpret_cast<const uint8_t*>(blob.data()), reinterpret_cast<const uint8_t*>(blob.data() + blob.size()), std::back_inserter(tx_extra));
return true;
}
示例8: get_block_longhash
bool get_block_longhash(cn_context &context, const Block& b, Hash& res) {
BinaryArray bd;
if (b.majorVersion == BLOCK_MAJOR_VERSION_1 || b.majorVersion >= BLOCK_MAJOR_VERSION_4) {
if (!get_block_hashing_blob(b, bd)) {
return false;
}
} else if (b.majorVersion == BLOCK_MAJOR_VERSION_2 || b.majorVersion == BLOCK_MAJOR_VERSION_3) {
if (!get_parent_block_hashing_blob(b, bd)) {
return false;
}
} else {
return false;
}
cn_slow_hash(context, bd.data(), bd.size(), res);
return true;
}
示例9: addExtraNonceToTransactionExtra
bool addExtraNonceToTransactionExtra(std::vector<uint8_t>& tx_extra, const BinaryArray& extra_nonce) {
if (extra_nonce.size() > TX_EXTRA_NONCE_MAX_COUNT) {
return false;
}
size_t start_pos = tx_extra.size();
tx_extra.resize(tx_extra.size() + 2 + extra_nonce.size());
//write tag
tx_extra[start_pos] = TX_EXTRA_NONCE;
//write len
++start_pos;
tx_extra[start_pos] = static_cast<uint8_t>(extra_nonce.size());
//write data
++start_pos;
memcpy(&tx_extra[start_pos], extra_nonce.data(), extra_nonce.size());
return true;
}
示例10: prepareAndSubmitBlock
bool BaseFunctionalTests::prepareAndSubmitBlock(TestNode& node, CryptoNote::Block&& blockTemplate) {
blockTemplate.timestamp = m_nextTimestamp;
m_nextTimestamp += 2 * m_currency.difficultyTarget();
if (blockTemplate.majorVersion >= BLOCK_MAJOR_VERSION_2) {
blockTemplate.parentBlock.majorVersion = BLOCK_MAJOR_VERSION_1;
blockTemplate.parentBlock.minorVersion = BLOCK_MINOR_VERSION_0;
blockTemplate.parentBlock.transactionCount = 1;
CryptoNote::TransactionExtraMergeMiningTag mmTag;
mmTag.depth = 0;
if (!CryptoNote::get_aux_block_header_hash(blockTemplate, mmTag.merkleRoot)) {
return false;
}
blockTemplate.parentBlock.baseTransaction.extra.clear();
if (!CryptoNote::appendMergeMiningTagToExtra(blockTemplate.parentBlock.baseTransaction.extra, mmTag)) {
return false;
}
}
BinaryArray blockBlob = CryptoNote::toBinaryArray(blockTemplate);
return node.submitBlock(::Common::toHex(blockBlob.data(), blockBlob.size()));
}
示例11: getBinaryArrayHash
void getBinaryArrayHash(const BinaryArray& binaryArray, Crypto::Hash& hash) {
cn_fast_hash(binaryArray.data(), binaryArray.size(), hash);
}