本文整理汇总了C++中BinaryRefReader类的典型用法代码示例。如果您正苦于以下问题:C++ BinaryRefReader类的具体用法?C++ BinaryRefReader怎么用?C++ BinaryRefReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BinaryRefReader类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unserialize
void OutPoint::unserialize(BinaryRefReader & brr)
{
if (brr.getSizeRemaining() < 32)
throw BlockDeserializingException();
brr.get_BinaryData(txHash_, 32);
txOutIndex_ = brr.get_uint32_t();
}
示例2: deserialize
IntType IntType::deserialize(BinaryRefReader& brr)
{
auto type_code = brr.get_uint8_t();
if (type_code != INTTYPE_CODE)
BtcUtils::throw_type_error(INTTYPE_CODE, type_code);
return IntType(brr.get_var_int());
}
示例3: deserialize
void BitcoinNetAddr::deserialize(BinaryRefReader brr)
{
if (brr.getSize() != NETADDR_NOTIME)
throw BitcoinMessageDeserError("invalid netaddr size");
services_ = brr.get_uint64_t();
auto ipv6bdr = brr.get_BinaryDataRef(16);
memcpy(&ipV6_, ipv6bdr.getPtr(), 16);
port_ = brr.get_uint16_t();
}
示例4: seekToOpCode
size_t ScriptParser::seekToOpCode(BinaryRefReader& brr, OPCODETYPE opcode) const
{
while (brr.getSizeRemaining() > 0)
{
auto&& oc = getNextOpcode(brr);
if (oc.opcode_ == opcode)
return brr.getPosition() - 1 - oc.dataRef_.getSize();
}
return brr.getPosition();
}
示例5: checkPrefixByte
bool DBUtils::checkPrefixByte(BinaryRefReader & brr,
DB_PREFIX prefix,
bool rewindWhenDone)
{
uint8_t oneByte = brr.get_uint8_t();
bool out = (oneByte == (uint8_t)prefix);
if (rewindWhenDone)
brr.rewind(1);
return out;
}
示例6: readBlkDataKeyNoPrefix
BLKDATA_TYPE DBUtils::readBlkDataKeyNoPrefix(
BinaryRefReader & brr,
uint32_t & height,
uint8_t & dupID,
uint16_t & txIdx,
uint16_t & txOutIdx)
{
BinaryData hgtx = brr.get_BinaryData(4);
height = hgtxToHeight(hgtx);
dupID = hgtxToDupID(hgtx);
if (brr.getSizeRemaining() == 0)
{
txIdx = 0xffff;
txOutIdx = 0xffff;
return BLKDATA_HEADER;
}
else if (brr.getSizeRemaining() == 2)
{
txIdx = brr.get_uint16_t(BE);
txOutIdx = 0xffff;
return BLKDATA_TX;
}
else if (brr.getSizeRemaining() == 4)
{
txIdx = brr.get_uint16_t(BE);
txOutIdx = brr.get_uint16_t(BE);
return BLKDATA_TXOUT;
}
else
{
LOGERR << "Unexpected bytes remaining: " << brr.getSizeRemaining();
return NOT_BLKDATA;
}
}
示例7: parseScript
void ScriptParser::parseScript(BinaryRefReader& brr)
{
while (brr.getSizeRemaining() != 0)
{
auto&& oc = getNextOpcode(brr);
processOpCode(oc);
}
}
示例8: checkPrefixByteWError
bool DBUtils::checkPrefixByteWError(BinaryRefReader & brr,
DB_PREFIX prefix,
bool rewindWhenDone)
{
uint8_t oneByte = brr.get_uint8_t();
bool out;
if (oneByte == (uint8_t)prefix)
out = true;
else
{
LOGERR << "Unexpected prefix byte: "
<< "Expected: " << getPrefixName(prefix)
<< "Received: " << getPrefixName(oneByte);
out = false;
}
if (rewindWhenDone)
brr.rewind(1);
return out;
}
示例9: processScript
void StackInterpreter::processScript(BinaryRefReader& brr, bool isOutputScript)
{
if (txStubPtr_ == nullptr)
throw ("uninitialized stack");
if (isOutputScript)
outputScriptRef_ = brr.getRawRef();
opcount_ = 0;
isValid_ = false;
ScriptParser::parseScript(brr);
}
示例10: readBlkDataKey
BLKDATA_TYPE DBUtils::readBlkDataKey(BinaryRefReader & brr,
uint32_t & height,
uint8_t & dupID,
uint16_t & txIdx,
uint16_t & txOutIdx)
{
uint8_t prefix = brr.get_uint8_t();
if (prefix != (uint8_t)DB_PREFIX_TXDATA)
{
height = 0xffffffff;
dupID = 0xff;
txIdx = 0xffff;
txOutIdx = 0xffff;
return NOT_BLKDATA;
}
return readBlkDataKeyNoPrefix(brr, height, dupID, txIdx, txOutIdx);
}
示例11: getNextOpcode
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//// ScriptParser
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
OpCode ScriptParser::getNextOpcode(BinaryRefReader& brr) const
{
OpCode val;
val.offset_ = brr.getPosition();
val.opcode_ = brr.get_uint8_t();
if (val.opcode_ <= 75 && val.opcode_ > 0)
{
val.dataRef_ = brr.get_BinaryDataRef(val.opcode_);
}
else
{
unsigned len = 0;
switch (val.opcode_)
{
case OP_PUSHDATA1:
len = brr.get_uint8_t();
break;
case OP_PUSHDATA2:
len = brr.get_uint16_t();
break;
case OP_PUSHDATA4:
len = brr.get_uint32_t();
break;
case OP_IF:
case OP_NOTIF:
len = brr.getSizeRemaining();
break;
default:
return val;
}
val.dataRef_ = brr.get_BinaryDataRef(len);
}
return val;
}
示例12: unserialize
void TxOutRef::unserialize(BinaryRefReader & brr, uint32_t nbytes, TxRef* parent, int32_t idx)
{
unserialize( brr.getCurrPtr(), nbytes, parent, idx );
brr.advance(nBytes_);
}