本文整理汇总了C++中BinaryRefReader::getSizeRemaining方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryRefReader::getSizeRemaining方法的具体用法?C++ BinaryRefReader::getSizeRemaining怎么用?C++ BinaryRefReader::getSizeRemaining使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryRefReader
的用法示例。
在下文中一共展示了BinaryRefReader::getSizeRemaining方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
BinaryDataVector BinaryDataVector::deserialize(BinaryRefReader& brr)
{
auto type_code = brr.get_uint8_t();
if (type_code != BINARYDATAVECTOR_CODE)
BtcUtils::throw_type_error(BINARYDATAVECTOR_CODE, type_code);
auto size = brr.get_var_int();
if (size > brr.getSizeRemaining())
throw runtime_error("invalid bdvec size");
BinaryDataVector bdvec;
auto count = brr.get_var_int();
for (unsigned i = 0; i < count; i++)
{
auto bdsize = brr.get_var_int();
if (bdsize > brr.getSizeRemaining())
throw runtime_error("invalid bd size");
auto&& bdo = brr.get_BinaryData(bdsize);
bdvec.push_back(move(bdo));
}
return bdvec;
}
示例2: 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;
}
}
示例3: unserialize
void OutPoint::unserialize(BinaryRefReader & brr)
{
if (brr.getSizeRemaining() < 32)
throw BlockDeserializingException();
brr.get_BinaryData(txHash_, 32);
txOutIndex_ = brr.get_uint32_t();
}
示例4: parseScript
void ScriptParser::parseScript(BinaryRefReader& brr)
{
while (brr.getSizeRemaining() != 0)
{
auto&& oc = getNextOpcode(brr);
processOpCode(oc);
}
}
示例5: 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();
}
示例6: 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;
}