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


C++ BinaryWriter::put_uint8_t方法代码示例

本文整理汇总了C++中BinaryWriter::put_uint8_t方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryWriter::put_uint8_t方法的具体用法?C++ BinaryWriter::put_uint8_t怎么用?C++ BinaryWriter::put_uint8_t使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinaryWriter的用法示例。


在下文中一共展示了BinaryWriter::put_uint8_t方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: serialize

void ProgressData::serialize(BinaryWriter& bw) const
{
   bw.put_uint8_t(PROGRESSDATA_CODE);

   bw.put_uint8_t((uint8_t)phase_);
   bw.put_double(progress_);
   bw.put_uint32_t(time_);
   bw.put_uint32_t(numericProgress_);
}
开发者ID:achow101,项目名称:BitcoinArmory,代码行数:9,代码来源:DataObject.cpp

示例2: serialize

BinaryData StackItem_OpCode::serialize(void) const
{
   BinaryWriter bw;
   bw.put_uint32_t(id_);
   bw.put_uint8_t(STACKITEM_OPCODE_PREFIX);
   bw.put_uint8_t(opcode_);

   return bw.getData();
}
开发者ID:Rudd-O,项目名称:BitcoinArmory,代码行数:9,代码来源:Script.cpp

示例3: serializeDbValue

void TxIOPair::serializeDbValue(BinaryWriter& bw) const
{
   uint8_t sersize = 17; //bit pack + amount + txout key

   if (hasTxIn())
      sersize += 8;

   bw.put_uint8_t(sersize);

   BitPacker<uint8_t> bitpacker;

   bitpacker.putBit(isTxOutFromSelf_);
   bitpacker.putBit(isFromCoinbase_);
   bitpacker.putBit(hasTxIn());
   bitpacker.putBit(isMultisig_);
   bitpacker.putBit(isUTXO_);
   bitpacker.putBit(isFromSameBlock_);

   bw.put_BitPacker(bitpacker);
   bw.put_uint64_t(amount_);

   bw.put_BinaryData(getDBKeyOfOutput());

   if (hasTxIn())
   {
      bw.put_BinaryData(getDBKeyOfInput());
   }
}
开发者ID:Groestlcoin,项目名称:GroestlcoinArmory,代码行数:28,代码来源:txio.cpp

示例4: getDataForSigHashAll

BinaryData SigHashDataSegWit::getDataForSigHashAll(const TransactionStub& stub,
   BinaryDataRef subScript, unsigned inputIndex)
{
   //grab subscript
   auto lastCSoffset = stub.getLastCodeSeparatorOffset(inputIndex);
   auto subScriptLen = subScript.getSize() - lastCSoffset;
   auto&& subscript = subScript.getSliceRef(lastCSoffset, subScriptLen);

   //pre state
   computePreState(stub);

   //serialize hashdata
   BinaryWriter hashdata;

   //version
   hashdata.put_uint32_t(stub.getVersion());

   //hashPrevouts
   hashdata.put_BinaryData(hashPrevouts_);

   //hashSequence
   hashdata.put_BinaryData(hashSequence_);

   //outpoint
   hashdata.put_BinaryDataRef(stub.getOutpoint(inputIndex));

   //script code
   hashdata.put_uint8_t(subScriptLen);
   hashdata.put_BinaryDataRef(subscript);

   //value
   hashdata.put_uint64_t(stub.getOutpointValue(inputIndex));

   //sequence
   hashdata.put_uint32_t(stub.getTxInSequence(inputIndex));

   //hashOutputs
   hashdata.put_BinaryData(hashOutputs_);

   //nLocktime
   hashdata.put_uint32_t(stub.getLockTime());

   //sighash type
   hashdata.put_uint32_t(1);

   return hashdata.getData();
}
开发者ID:yurivict,项目名称:BitcoinArmory,代码行数:47,代码来源:Transactions.cpp

示例5: writeBlockData

void BlockchainScanner::writeBlockData(
   shared_ptr<BatchLink> batchLinkPtr)
{
   auto getGlobalOffsetForBlock = [&](unsigned height)->size_t
   {
      auto& header = blockchain_->getHeaderByHeight(height);
      size_t val = header.getBlockFileNum();
      val *= 128 * 1024 * 1024;
      val += header.getOffset();
      return val;
   };

   ProgressCalculator calc(getGlobalOffsetForBlock(
      blockchain_->top().getBlockHeight()));
   calc.advance(getGlobalOffsetForBlock(startAt_));

   auto writeHintsLambda = 
      [&](const vector<shared_ptr<BlockDataBatch>>& batchVec)->void
   { processAndCommitTxHints(batchVec); };

   while (1)
   {
      if (batchLinkPtr == nullptr)
         break;
      
      {
         unique_lock<mutex> batchIsReady(batchLinkPtr->readyToWrite_);
      }

      if (batchLinkPtr->next_ == nullptr)
         break;

      //start txhint writer thread
      thread writeHintsThreadId = 
         thread(writeHintsLambda, batchLinkPtr->batchVec_);

      auto& topheader = 
         blockchain_->getHeaderByHash(batchLinkPtr->topScannedBlockHash_);
      auto topHeight = topheader.getBlockHeight();
      
      //serialize data
      map<BinaryData, BinaryWriter> serializedSubSSH;
      map<BinaryData, BinaryWriter> serializedStxo;
      map<BinaryData, BinaryWriter> serializedTxHints;
      map<BinaryData, StoredTxHints> txHints;

      {
         for (auto& batchPtr : batchLinkPtr->batchVec_)
         {
            for (auto& ssh : batchPtr->ssh_)
            {
               for (auto& subssh : ssh.second.subHistMap_)
               {
                  //TODO: modify subssh serialization to fit our needs

                  BinaryWriter subsshkey;
                  subsshkey.put_uint8_t(DB_PREFIX_SCRIPT);
                  subsshkey.put_BinaryData(ssh.first);
                  subsshkey.put_BinaryData(subssh.first);

                  auto& bw = serializedSubSSH[subsshkey.getDataRef()];
                  subssh.second.serializeDBValue(
                     bw, db_, ARMORY_DB_BARE, DB_PRUNE_NONE);
               }
            }

            for (auto& utxomap : batchPtr->utxos_)
            {
               auto&& txHashPrefix = utxomap.first.getSliceCopy(0, 4);
               StoredTxHints& stxh = txHints[txHashPrefix];
               if (stxh.txHashPrefix_.getSize() == 0)
                  stxh.txHashPrefix_ = txHashPrefix;


               for (auto& utxo : utxomap.second)
               {
                  stxh.dbKeyList_.push_back(utxo.second.getDBKeyOfParentTx());

                  auto& bw = serializedStxo[utxo.second.getDBKey()];
                  utxo.second.serializeDBValue(
                     bw, ARMORY_DB_BARE, DB_PRUNE_NONE, true);
               }
               
               stxh.preferredDBKey_ = stxh.dbKeyList_.front();
            }
         }
      }

      //we've serialized utxos, now let's do another pass for spent txouts
      //to make sure they overwrite utxos that were found and spent within
      //the same batch
      for (auto& batchPtr : batchLinkPtr->batchVec_)
      {
         for (auto& stxo : batchPtr->spentTxOuts_)
         {
            auto& bw = serializedStxo[stxo.getDBKey()];
            if (bw.getSize() > 0)
               bw.reset();
            stxo.serializeDBValue(
               bw, ARMORY_DB_BARE, DB_PRUNE_NONE, true);
//.........这里部分代码省略.........
开发者ID:CarltonCode,项目名称:BitcoinArmory,代码行数:101,代码来源:BlockchainScanner.cpp


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