Esempio n. 1
0
void CoinEng::ExportToBootstrapDat(const path& pathBoostrap) {
	uint32_t n = Db->GetMaxHeight()+1;
	
#ifndef X_DEBUG//!!!T
	if (Mode == EngMode::Bootstrap) {
		CEngStateDescription stateDesc(_self, EXT_STR("Copying " << GetBootstrapPath() << " -> " << pathBoostrap));

		return (void)copy_file(GetBootstrapPath(), pathBoostrap, copy_options::overwrite_existing);
	}
#endif

	CEngStateDescription stateDesc(_self, EXT_STR("Exporting " << n << " blocks to " << pathBoostrap));

	FileStream fs(pathBoostrap, FileMode::Create, FileAccess::Write);
	BinaryWriter wr(fs);

	for (uint32_t i=0; i<n && Runned; ++i) {
		wr << ChainParams.ProtocolMagic;
		MemoryStream ms;

		Block block = GetBlockByHeight(i);
//!!!?		block.LoadToMemory();
//!!!?		EXT_FOR (const Tx& tx, block.Txes) {
//!!!?			//			tx.m_pimpl->m_nBytesOfHash = 0;
//!!!?		}	
//!!!?		block.m_pimpl->m_hash.reset();
//!!!?block.m_pimpl->m_txHashesOutNums.clear();

		block.Write(BinaryWriter(ms).Ref());
		wr << uint32_t(ms.Position);
		fs.WriteBuf(ms);
	}
}
Esempio n. 2
0
void RTMPSender::pack(RTMPChannel& channel) {
	if (sizePos == 0)
		return;
	// writer the size of the precedent playload!
	channel.bodySize = _writer.packet.size()-sizePos+4-headerSize;
	BinaryWriter(_writer.packet.data()+sizePos,3).write24(channel.bodySize);
	sizePos=0;
}
Esempio n. 3
0
// Returns the size of the header + numTx + tx[i], no leading bytes
uint32_t BlockHeaderRef::getBlockSize(void) const
{
   uint32_t nBytes = HEADER_SIZE; 
   uint32_t nTx = txPtrList_.size();
   for(uint32_t i=0; i<nTx; i++)
   {
      if(txPtrList_[i] == NULL)
         return 0;
      else
         nBytes += txPtrList_[i]->getSize();
   }

   // Add in a couple bytes for the var_int
   nBytes += BinaryWriter().put_var_int(nTx);
   return nBytes;
}
Esempio n. 4
0
	bool ByteArray::save(const FilePath& path) const
	{
		const int64 size = pImpl->size();

		return (BinaryWriter(path).write(pImpl->data(), static_cast<size_t>(size)) == size);
	}