当前位置: 首页>>代码示例>>C++>>正文


C++ BinaryRefReader类代码示例

本文整理汇总了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();
}
开发者ID:R0B3RDV,项目名称:BitcoinArmory,代码行数:7,代码来源:BlockObj.cpp

示例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());
}
开发者ID:achow101,项目名称:BitcoinArmory,代码行数:8,代码来源:DataObject.cpp

示例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();
}
开发者ID:achow101,项目名称:BitcoinArmory,代码行数:11,代码来源:BitcoinP2P.cpp

示例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();
}
开发者ID:Rudd-O,项目名称:BitcoinArmory,代码行数:11,代码来源:Script.cpp

示例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;
}
开发者ID:achow101,项目名称:BitcoinArmory,代码行数:12,代码来源:DBUtils.cpp

示例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;
   }
}
开发者ID:achow101,项目名称:BitcoinArmory,代码行数:35,代码来源:DBUtils.cpp

示例7: parseScript

void ScriptParser::parseScript(BinaryRefReader& brr)
{
   while (brr.getSizeRemaining() != 0)
   {
      auto&& oc = getNextOpcode(brr);
      processOpCode(oc);
   }
}
开发者ID:Rudd-O,项目名称:BitcoinArmory,代码行数:8,代码来源:Script.cpp

示例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;
}
开发者ID:achow101,项目名称:BitcoinArmory,代码行数:21,代码来源:DBUtils.cpp

示例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);
}
开发者ID:Rudd-O,项目名称:BitcoinArmory,代码行数:13,代码来源:Script.cpp

示例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);
}
开发者ID:achow101,项目名称:BitcoinArmory,代码行数:18,代码来源:DBUtils.cpp

示例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;
}
开发者ID:Rudd-O,项目名称:BitcoinArmory,代码行数:45,代码来源:Script.cpp

示例12: unserialize

void TxOutRef::unserialize(BinaryRefReader & brr, uint32_t nbytes, TxRef* parent, int32_t idx)
{
   unserialize( brr.getCurrPtr(), nbytes, parent, idx );
   brr.advance(nBytes_);
}
开发者ID:Ajaydhyani,项目名称:PyBtcEngine,代码行数:5,代码来源:BlockObjRef.cpp


注:本文中的BinaryRefReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。