本文整理汇总了C++中BinaryDataRef::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryDataRef::getSize方法的具体用法?C++ BinaryDataRef::getSize怎么用?C++ BinaryDataRef::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryDataRef
的用法示例。
在下文中一共展示了BinaryDataRef::getSize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: find
int32_t BinaryData::find(BinaryDataRef const & matchStr, uint32_t startPos)
{
int32_t finalAnswer = -1;
if(matchStr.getSize()==0)
return startPos;
for(int32_t i=startPos; i<=(int32_t)getSize()-(int32_t)matchStr.getSize(); i++)
{
if(matchStr[0] != data_[i])
continue;
for(uint32_t j=0; j<matchStr.getSize(); j++)
{
if(matchStr[j] != data_[i+j])
break;
// If we are at this instruction and is the last index, it's a match
if(j==matchStr.getSize()-1)
finalAnswer = i;
}
if(finalAnswer != -1)
break;
}
return finalAnswer;
}
示例2: startsWith
bool BinaryData::startsWith(BinaryDataRef const & matchStr) const
{
if(matchStr.getSize() > getSize())
return false;
for(uint32_t i=0; i<matchStr.getSize(); i++)
if(matchStr[i] != (*this)[i])
return false;
return true;
}
示例3: unserialize
void TxOut::unserialize( BinaryDataRef const & str,
uint32_t nbytes,
TxRef parent,
uint32_t idx)
{
unserialize_checked(str.getPtr(), str.getSize(), nbytes, parent, idx);
}
示例4: return
bool BinaryData::operator==(BinaryDataRef const & bd2) const
{
if(getSize() != bd2.getSize())
return false;
return (memcmp(getPtr(), bd2.getPtr(), getSize()) == 0);
}
示例5: unserialize
void TxIOPair::unserialize(const BinaryDataRef& val)
{
BinaryRefReader brr(val);
BitUnpacker<uint8_t> bitunpack(brr);
isTxOutFromSelf_ = bitunpack.getBit();
isFromCoinbase_ = bitunpack.getBit();
bool isSpent = bitunpack.getBit();
isMultisig_ = bitunpack.getBit();
isUTXO_ = bitunpack.getBit();
isFromSameBlock_ = bitunpack.getBit();
// We always include the 8-byte value
amount_ = brr.get_uint64_t();
setTxOut(val.getSliceRef(9, 8));
if (val.getSize() == 25)
setTxIn(val.getSliceRef(17, 8));
//the key always carries the full txout ref
/*if (!isSpent)
setTxOut(key);
else
{
//spent subssh, txout key
setTxOut(val.getSliceRef(9, 8));
//when keyed by txins, the top bit in the tx index is always flipped
BinaryData txinKey(key);
txinKey.getPtr()[4] &= 0x7F;
//last 8 bytes carry the txin key
setTxIn(txinKey);
}*/
}
示例6:
bool BinaryData::operator==(BinaryDataRef const & bd2) const
{
if(getSize() != bd2.getSize())
return false;
for(unsigned int i=0; i<getSize(); i++)
if( data_[i] != bd2[i])
return false;
return true;
}
示例7: endsWith
bool BinaryData::endsWith(BinaryDataRef const & matchStr) const
{
uint32_t sz = matchStr.getSize();
if(sz > getSize())
return false;
for(uint32_t i=0; i<sz; i++)
if(matchStr[sz-(i+1)] != (*this)[getSize()-(i+1)])
return false;
return true;
}
示例8: 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();
}
示例9: loadZeroConfMempool
void ZeroConfContainer::loadZeroConfMempool(
function<bool(const BinaryData&)> filter,
bool clearMempool)
{
//run this in its own scope so the iter and tx are closed in order to open
//RW tx afterwards
{
auto dbs = db_->getDbSelect(HISTORY);
LMDBEnv::Transaction tx;
db_->beginDBTransaction(&tx, dbs, LMDB::ReadOnly);
LDBIter dbIter(db_->getIterator(dbs));
if (!dbIter.seekToStartsWith(DB_PREFIX_ZCDATA))
{
enabled_ = true;
return;
}
do
{
BinaryDataRef zcKey = dbIter.getKeyRef();
if (zcKey.getSize() == 7)
{
//Tx, grab it from DB
StoredTx zcStx;
db_->getStoredZcTx(zcStx, zcKey);
//add to newZCMap_
Tx& zcTx = newZCMap_[zcKey.getSliceCopy(1, 6)];
zcTx = Tx(zcStx.getSerializedTx());
zcTx.setTxTime(zcStx.unixTime_);
}
else if (zcKey.getSize() == 9)
{
//TxOut, ignore it
continue;
}
else
{
//shouldn't hit this
LOGERR << "Unknown key found in ZC mempool";
break;
}
} while (dbIter.advanceAndRead(DB_PREFIX_ZCDATA));
}
if (clearMempool == true)
{
vector<BinaryData> keysToWrite, keysToDelete;
for (const auto& zcTx : newZCMap_)
keysToDelete.push_back(zcTx.first);
newZCMap_.clear();
updateZCinDB(keysToWrite, keysToDelete);
}
else if (newZCMap_.size())
{
//copy newZCmap_ to keep the pre parse ZC map
auto oldZCMap = newZCMap_;
//now parse the new ZC
parseNewZC(filter);
//set the zckey to the highest used index
if (txMap_.size() > 0)
{
BinaryData topZcKey = txMap_.rbegin()->first;
topId_.store(READ_UINT32_BE(topZcKey.getSliceCopy(2, 4)) +1);
}
//intersect oldZCMap and txMap_ to figure out the invalidated ZCs
vector<BinaryData> keysToWrite, keysToDelete;
for (const auto& zcTx : oldZCMap)
{
if (txMap_.find(zcTx.first) == txMap_.end())
keysToDelete.push_back(zcTx.first);
}
//no need to run this in a side thread, this code only runs when we have
//full control over the main thread
updateZCinDB(keysToWrite, keysToDelete);
}
enabled_ = true;
}
示例10: copyFrom
void BinaryData::copyFrom(BinaryDataRef const & bdr)
{
copyFrom( bdr.getPtr(), bdr.getSize() );
}