Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <compat/endian.h>
#include <algorithm>
#include <assert.h>
#include <ios>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <stdint.h>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <prevector.h>
Go to the source code of this file.
Classes | |
struct | deserialize_type |
Dummy data type to identify deserializing constructors. More... | |
class | CFlatData |
Wrapper for serializing arrays and POD. More... | |
class | CFixedBitSet |
class | CDynamicBitSet |
class | CFixedVarIntsBitSet |
Stores a fixed size bitset as a series of VarInts. More... | |
class | CAutoBitSet |
Serializes either as a CFixedBitSet or CFixedVarIntsBitSet, depending on which would give a smaller size. More... | |
class | CVarInt< I > |
class | CCompactSize |
class | LimitedString< Limit > |
struct | is_serializable_enum< T > |
If none of the specialized versions above matched and T is an enum, default to calling Serialize/Unserialze with the underlying type. More... | |
struct | is_serializable_enum< T > |
If none of the specialized versions above matched and T is an enum, default to calling Serialize/Unserialze with the underlying type. More... | |
struct | SerializeTuple< Stream, index, Ts > |
tuple More... | |
struct | SerializeTuple< Stream, 0, Ts... > |
struct | DeserializeTuple< Stream, index, Ts > |
struct | DeserializeTuple< Stream, 0, Ts... > |
struct | CSerActionSerialize |
Support for ADD_SERIALIZE_METHODS and READWRITE macro. More... | |
struct | CSerActionUnserialize |
class | CSizeComputer |
Macros | |
#define | READWRITE(obj) (::SerReadWrite(s, (obj), ser_action)) |
#define | READWRITEMANY(...) (::SerReadWriteMany(s, ser_action, __VA_ARGS__)) |
#define | ADD_SERIALIZE_METHODS |
Implement three methods for serializable objects. More... | |
#define | FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj) + sizeof(obj))) |
#define | FIXEDBITSET(obj, size) REF(CFixedBitSet(REF(obj), (size))) |
#define | DYNBITSET(obj) REF(CDynamicBitSet(REF(obj))) |
#define | FIXEDVARINTSBITSET(obj, size) REF(CFixedVarIntsBitSet(REF(obj), (size))) |
#define | AUTOBITSET(obj, size) REF(CAutoBitSet(REF(obj), (size))) |
#define | VARINT(obj) REF(WrapVarInt(REF(obj))) |
#define | COMPACTSIZE(obj) REF(CCompactSize(REF(obj))) |
#define | LIMITED_STRING(obj, n) REF(LimitedString< n >(REF(obj))) |
Enumerations | |
enum | { SER_NETWORK = (1 << 0), SER_DISK = (1 << 1), SER_GETHASH = (1 << 2) } |
Functions | |
template<typename T > | |
T & | REF (const T &val) |
Used to bypass the rule against non-const reference to temporary where it makes sense with wrappers such as CFlatData or CTxDB. More... | |
template<typename T > | |
T * | NCONST_PTR (const T *val) |
Used to acquire a non-const pointer "this" to generate bodies of const serialization operations from a template. More... | |
template<typename Stream > | |
void | ser_writedata8 (Stream &s, uint8_t obj) |
template<typename Stream > | |
void | ser_writedata16 (Stream &s, uint16_t obj) |
template<typename Stream > | |
void | ser_writedata32 (Stream &s, uint32_t obj) |
template<typename Stream > | |
void | ser_writedata32be (Stream &s, uint32_t obj) |
template<typename Stream > | |
void | ser_writedata64 (Stream &s, uint64_t obj) |
template<typename Stream > | |
uint8_t | ser_readdata8 (Stream &s) |
template<typename Stream > | |
uint16_t | ser_readdata16 (Stream &s) |
template<typename Stream > | |
uint32_t | ser_readdata32 (Stream &s) |
template<typename Stream > | |
uint32_t | ser_readdata32be (Stream &s) |
template<typename Stream > | |
uint64_t | ser_readdata64 (Stream &s) |
uint64_t | ser_double_to_uint64 (double x) |
uint32_t | ser_float_to_uint32 (float x) |
double | ser_uint64_to_double (uint64_t y) |
float | ser_uint32_to_float (uint32_t y) |
template<typename Stream > | |
void | Serialize (Stream &s, char a) |
template<typename Stream > | |
void | Serialize (Stream &s, int8_t a) |
template<typename Stream > | |
void | Serialize (Stream &s, uint8_t a) |
template<typename Stream > | |
void | Serialize (Stream &s, int16_t a) |
template<typename Stream > | |
void | Serialize (Stream &s, uint16_t a) |
template<typename Stream > | |
void | Serialize (Stream &s, int32_t a) |
template<typename Stream > | |
void | Serialize (Stream &s, uint32_t a) |
template<typename Stream > | |
void | Serialize (Stream &s, int64_t a) |
template<typename Stream > | |
void | Serialize (Stream &s, uint64_t a) |
template<typename Stream > | |
void | Serialize (Stream &s, float a) |
template<typename Stream > | |
void | Serialize (Stream &s, double a) |
template<typename Stream > | |
void | Unserialize (Stream &s, char &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, int8_t &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, uint8_t &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, int16_t &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, uint16_t &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, int32_t &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, uint32_t &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, int64_t &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, uint64_t &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, float &a) |
template<typename Stream > | |
void | Unserialize (Stream &s, double &a) |
template<typename Stream > | |
void | Serialize (Stream &s, bool a) |
template<typename Stream > | |
void | Unserialize (Stream &s, bool &a) |
template<typename T > | |
size_t | GetSerializeSize (const T &t, int nType, int nVersion=0) |
template<typename S , typename T > | |
size_t | GetSerializeSize (const S &s, const T &t) |
unsigned int | GetSizeOfCompactSize (uint64_t nSize) |
Compact Size size < 253 – 1 byte size <= USHRT_MAX – 3 bytes (253 + 2 bytes) size <= UINT_MAX – 5 bytes (254 + 4 bytes) size > UINT_MAX – 9 bytes (255 + 8 bytes) More... | |
void | WriteCompactSize (CSizeComputer &os, uint64_t nSize) |
template<typename Stream > | |
void | WriteCompactSize (Stream &os, uint64_t nSize) |
template<typename Stream > | |
uint64_t | ReadCompactSize (Stream &is) |
template<typename I > | |
unsigned int | GetSizeOfVarInt (I n) |
Variable-length integers: bytes are a MSB base-128 encoding of the number. More... | |
template<typename I > | |
void | WriteVarInt (CSizeComputer &os, I n) |
template<typename Stream , typename I > | |
void | WriteVarInt (Stream &os, I n) |
template<typename Stream , typename I > | |
I | ReadVarInt (Stream &is) |
template<typename I > | |
CVarInt< I > | WrapVarInt (I &n) |
template<typename Stream , typename C > | |
void | Serialize (Stream &os, const std::basic_string< C > &str) |
Forward declarations. More... | |
template<typename Stream , typename C > | |
void | Unserialize (Stream &is, std::basic_string< C > &str) |
template<typename Stream , unsigned int N, typename T > | |
void | Serialize_impl (Stream &os, const prevector< N, T > &v, const unsigned char &) |
prevector prevectors of unsigned char are a special case and are intended to be serialized as a single opaque blob. More... | |
template<typename Stream , unsigned int N, typename T , typename V > | |
void | Serialize_impl (Stream &os, const prevector< N, T > &v, const V &) |
template<typename Stream , unsigned int N, typename T > | |
void | Serialize (Stream &os, const prevector< N, T > &v) |
template<typename Stream , unsigned int N, typename T > | |
void | Unserialize_impl (Stream &is, prevector< N, T > &v, const unsigned char &) |
template<typename Stream , unsigned int N, typename T , typename V > | |
void | Unserialize_impl (Stream &is, prevector< N, T > &v, const V &) |
template<typename Stream , unsigned int N, typename T > | |
void | Unserialize (Stream &is, prevector< N, T > &v) |
template<typename Stream , typename T , typename A > | |
void | Serialize_impl (Stream &os, const std::vector< T, A > &v, const unsigned char &) |
vector vectors of unsigned char are a special case and are intended to be serialized as a single opaque blob. More... | |
template<typename Stream , typename T , typename A , typename V > | |
void | Serialize_impl (Stream &os, const std::vector< T, A > &v, const V &) |
template<typename Stream , typename T , typename A > | |
void | Serialize (Stream &os, const std::vector< T, A > &v) |
template<typename Stream , typename T , typename A > | |
void | Unserialize_impl (Stream &is, std::vector< T, A > &v, const unsigned char &) |
template<typename Stream , typename T , typename A , typename V > | |
void | Unserialize_impl (Stream &is, std::vector< T, A > &v, const V &) |
template<typename Stream , typename T , typename A > | |
void | Unserialize (Stream &is, std::vector< T, A > &v) |
template<typename Stream , typename K , typename T > | |
void | Serialize (Stream &os, const std::pair< K, T > &item) |
pair More... | |
template<typename Stream , typename K , typename T > | |
void | Unserialize (Stream &is, std::pair< K, T > &item) |
template<typename Stream , typename... Elements> | |
void | Serialize (Stream &os, const std::tuple< Elements... > &item) |
pair More... | |
template<typename Stream , typename... Elements> | |
void | Unserialize (Stream &is, std::tuple< Elements... > &item) |
template<typename Stream , typename K , typename T , typename Pred , typename A > | |
void | Serialize (Stream &os, const std::map< K, T, Pred, A > &m) |
map More... | |
template<typename Stream , typename K , typename T , typename Pred , typename A > | |
void | Unserialize (Stream &is, std::map< K, T, Pred, A > &m) |
template<typename Stream , typename K , typename T , typename Hash , typename Pred , typename A > | |
void | Serialize (Stream &os, const std::unordered_map< K, T, Hash, Pred, A > &m) |
template<typename Stream , typename K , typename T , typename Hash , typename Pred , typename A > | |
void | Unserialize (Stream &is, std::unordered_map< K, T, Hash, Pred, A > &m) |
template<typename Stream , typename K , typename Pred , typename A > | |
void | Serialize (Stream &os, const std::set< K, Pred, A > &m) |
set More... | |
template<typename Stream , typename K , typename Pred , typename A > | |
void | Unserialize (Stream &is, std::set< K, Pred, A > &m) |
template<typename Stream , typename K , typename Hash , typename Pred , typename A > | |
void | Serialize (Stream &os, const std::unordered_set< K, Hash, Pred, A > &m) |
template<typename Stream , typename K , typename Hash , typename Pred , typename A > | |
void | Unserialize (Stream &is, std::unordered_set< K, Hash, Pred, A > &m) |
template<typename Stream , typename T > | |
void | Serialize (Stream &os, const std::shared_ptr< T > &p) |
shared_ptr More... | |
template<typename Stream , typename T > | |
void | Unserialize (Stream &os, std::shared_ptr< T > &p) |
template<typename Stream , typename T > | |
void | Serialize (Stream &os, const std::unique_ptr< const T > &p) |
unique_ptr More... | |
template<typename Stream , typename T > | |
void | Unserialize (Stream &os, std::unique_ptr< const T > &p) |
template<typename Stream , typename T , typename std::enable_if< std::is_class< T >::value >::type * = nullptr> | |
void | Serialize (Stream &os, const T &a) |
If none of the specialized versions above matched and T is a class, default to calling member function. More... | |
template<typename Stream , typename T , typename std::enable_if< std::is_class< T >::value >::type * = nullptr> | |
void | Unserialize (Stream &is, T &a) |
template<typename Stream , typename T , typename std::enable_if< std::is_enum< T >::value >::type * = nullptr> | |
void | Serialize (Stream &s, T a) |
template<typename Stream , typename Map > | |
void | SerializeMap (Stream &os, const Map &m) |
map More... | |
template<typename Stream , typename Map > | |
void | UnserializeMap (Stream &is, Map &m) |
template<typename Stream , typename Set > | |
void | SerializeSet (Stream &os, const Set &m) |
set More... | |
template<typename Stream , typename Set > | |
void | UnserializeSet (Stream &is, Set &m) |
template<typename Stream , typename T , typename A > | |
void | Serialize (Stream &os, const std::list< T, A > &l) |
list More... | |
template<typename Stream , typename T , typename A > | |
void | Unserialize (Stream &is, std::list< T, A > &l) |
template<typename Stream , typename T > | |
void | SerReadWrite (Stream &s, const T &obj, CSerActionSerialize ser_action) |
template<typename Stream , typename T > | |
void | SerReadWrite (Stream &s, T &obj, CSerActionUnserialize ser_action) |
template<typename Stream > | |
void | SerializeMany (Stream &s) |
template<typename Stream , typename Arg > | |
void | SerializeMany (Stream &s, Arg &&arg) |
template<typename Stream , typename Arg , typename... Args> | |
void | SerializeMany (Stream &s, Arg &&arg, Args &&... args) |
template<typename Stream > | |
void | UnserializeMany (Stream &s) |
template<typename Stream , typename Arg > | |
void | UnserializeMany (Stream &s, Arg &arg) |
template<typename Stream , typename Arg , typename... Args> | |
void | UnserializeMany (Stream &s, Arg &arg, Args &... args) |
template<typename Stream , typename... Args> | |
void | SerReadWriteMany (Stream &s, CSerActionSerialize ser_action, Args &&... args) |
template<typename Stream , typename... Args> | |
void | SerReadWriteMany (Stream &s, CSerActionUnserialize ser_action, Args &... args) |
Variables | |
static const unsigned int | MAX_SIZE = 0x02000000 |
constexpr deserialize_type | deserialize {} |
Macro Definition Documentation
◆ ADD_SERIALIZE_METHODS
#define ADD_SERIALIZE_METHODS |
Implement three methods for serializable objects.
These are actually wrappers over "SerializationOp" template, which implements the body of each class' serialization code. Adding "ADD_SERIALIZE_METHODS" in the body of the class causes these wrappers to be added as members.
Definition at line 174 of file serialize.h.
◆ AUTOBITSET
#define AUTOBITSET | ( | obj, | |
size | |||
) | REF(CAutoBitSet(REF(obj), (size))) |
Definition at line 374 of file serialize.h.
Referenced by llmq::CSigSharesInv::SerializationOp().
◆ COMPACTSIZE
#define COMPACTSIZE | ( | obj | ) | REF(CCompactSize(REF(obj))) |
Definition at line 376 of file serialize.h.
Referenced by BlockTransactionsRequest::SerializationOp(), BlockTransactions::SerializationOp(), llmq::CSigSharesInv::SerializationOp(), PrefilledTransaction::SerializationOp(), CBlockHeaderAndShortTxIDs::SerializationOp(), CTxUndo::Serialize(), and CTxUndo::Unserialize().
◆ DYNBITSET
#define DYNBITSET | ( | obj | ) | REF(CDynamicBitSet(REF(obj))) |
Definition at line 372 of file serialize.h.
Referenced by llmq::CLLMQUtils::BuildCommitmentHash(), llmq::CFinalCommitment::SerializationOp(), llmq::CDKGComplaint::SerializationOp(), and llmq::CDKGPrematureCommitment::SerializationOp().
◆ FIXEDBITSET
#define FIXEDBITSET | ( | obj, | |
size | |||
) | REF(CFixedBitSet(REF(obj), (size))) |
Definition at line 371 of file serialize.h.
Referenced by CAutoBitSet::Serialize(), and CAutoBitSet::Unserialize().
◆ FIXEDVARINTSBITSET
#define FIXEDVARINTSBITSET | ( | obj, | |
size | |||
) | REF(CFixedVarIntsBitSet(REF(obj), (size))) |
Definition at line 373 of file serialize.h.
Referenced by CAutoBitSet::Serialize(), and CAutoBitSet::Unserialize().
◆ FLATDATA
Definition at line 370 of file serialize.h.
Referenced by LoadExternalBlockFile(), CFlatDB< T >::Read(), CBLSIESEncryptedBlob::SerializationOp(), CMessageHeader::SerializationOp(), CNetAddr::SerializationOp(), CSubNet::SerializationOp(), CService::SerializationOp(), CFlatDB< T >::Write(), and WriteBlockToDisk().
◆ LIMITED_STRING
#define LIMITED_STRING | ( | obj, | |
n | |||
) | REF(LimitedString< n >(REF(obj))) |
Definition at line 377 of file serialize.h.
Referenced by ProcessMessage(), CWalletKey::SerializationOp(), and CAccountingEntry::SerializationOp().
◆ READWRITE
#define READWRITE | ( | obj | ) | (::SerReadWrite(s, (obj), ser_action)) |
Definition at line 165 of file serialize.h.
Referenced by CHDAccount::SerializationOp(), CSpentIndexKey::SerializationOp(), CBLSIESEncryptedBlob::SerializationOp(), TransactionCompressor::SerializationOp(), RecentRequestEntry::SerializationOp(), CCbTx::SerializationOp(), llmq::CInstantSendLock::SerializationOp(), CacheItem< K, V >::SerializationOp(), CNetFulfilledRequestManager::SerializationOp(), llmq::CChainLockSig::SerializationOp(), COutPoint::SerializationOp(), BlockTransactionsRequest::SerializationOp(), llmq::CRecoveredSig::SerializationOp(), CBlockHeader::SerializationOp(), CProRegTx::SerializationOp(), CBlockFileInfo::SerializationOp(), CMNAuth::SerializationOp(), CMessageHeader::SerializationOp(), CBanEntry::SerializationOp(), CMasterKey::SerializationOp(), CDiskTxPos::SerializationOp(), CSpentIndexValue::SerializationOp(), CCoin::SerializationOp(), CFeeRate::SerializationOp(), CMasternodeMetaInfo::SerializationOp(), CSimplifiedMNListEntry::SerializationOp(), llmq::CSigShare::SerializationOp(), CAddrInfo::SerializationOp(), CHDChain::SerializationOp(), llmq::CFinalCommitment::SerializationOp(), SendCoinsRecipient::SerializationOp(), vote_instance_t::SerializationOp(), CDeterministicMNState::SerializationOp(), CGovernanceObjectVoteFile::SerializationOp(), CKeyMetadata::SerializationOp(), CBloomFilter::SerializationOp(), BlockTransactions::SerializationOp(), CPartialMerkleTree::SerializationOp(), llmq::CSigSesAnn::SerializationOp(), CDiskBlockPos::SerializationOp(), CBlock::SerializationOp(), vote_rec_t::SerializationOp(), CNetAddr::SerializationOp(), CGetSimplifiedMNListDiff::SerializationOp(), CSporkMessage::SerializationOp(), CBLSIESMultiRecipientBlobs::SerializationOp(), CProUpServTx::SerializationOp(), llmq::CDKGComplaint::SerializationOp(), CMasternodeMetaMan::SerializationOp(), CBlockUndo::SerializationOp(), CPrivateSendStatusUpdate::SerializationOp(), CTxOutCompressor::SerializationOp(), llmq::CSigSharesInv::SerializationOp(), PrefilledTransaction::SerializationOp(), CTxIn::SerializationOp(), CGovernanceVote::SerializationOp(), llmq::CFinalCommitmentTxPayload::SerializationOp(), CSimplifiedMNListDiff::SerializationOp(), CKeyPool::SerializationOp(), CSubNet::SerializationOp(), llmq::CDKGJustification::SerializationOp(), CBlockLocator::SerializationOp(), CHDPubKey::SerializationOp(), CRateCheckBuffer::SerializationOp(), llmq::CBatchedSigShares::SerializationOp(), CProUpRegTx::SerializationOp(), CMerkleBlock::SerializationOp(), CPrivateSendAccept::SerializationOp(), CBlockHeaderAndShortTxIDs::SerializationOp(), CacheMap< uint256, CGovernanceVote >::SerializationOp(), CTxOut::SerializationOp(), CGovernanceManager::last_object_rec::SerializationOp(), CService::SerializationOp(), CDeterministicMNStateDiff::SerializationOp(), CSporkManager::SerializationOp(), llmq::CDKGPrematureCommitment::SerializationOp(), CacheMultiMap< uint256, vote_time_pair_t >::SerializationOp(), CPrivateSendEntry::SerializationOp(), CProUpRevTx::SerializationOp(), CAddressUnspentValue::SerializationOp(), CDeterministicMN::SerializationOp(), CMerkleTx::SerializationOp(), CPrivateSendQueue::SerializationOp(), stackframe_info::SerializationOp(), CMutableTransaction::SerializationOp(), CGovernanceObject::SerializationOp(), CPrivateSendBroadcastTx::SerializationOp(), CGovernanceManager::SerializationOp(), crash_info_header::SerializationOp(), CAddress::SerializationOp(), crash_info::SerializationOp(), CDiskBlockIndex::SerializationOp(), CWalletTx::SerializationOp(), CScript::SerializationOp(), CInv::SerializationOp(), CWalletKey::SerializationOp(), CAccountingEntry::SerializationOp(), CAccount::SerializationOp(), and CDeterministicMNList::SerializationOpBase().
◆ READWRITEMANY
#define READWRITEMANY | ( | ... | ) | (::SerReadWriteMany(s, ser_action, __VA_ARGS__)) |
Definition at line 166 of file serialize.h.
◆ VARINT
#define VARINT | ( | obj | ) | REF(WrapVarInt(REF(obj))) |
Definition at line 375 of file serialize.h.
Referenced by ApplyStats(), CBlockFileInfo::SerializationOp(), CDiskTxPos::SerializationOp(), llmq::CSigSesAnn::SerializationOp(), CDiskBlockPos::SerializationOp(), CTxOutCompressor::SerializationOp(), llmq::CSigSharesInv::SerializationOp(), llmq::CBatchedSigShares::SerializationOp(), CDeterministicMNStateDiff::SerializationOp(), CDeterministicMN::SerializationOp(), CDiskBlockIndex::SerializationOp(), TxInUndoSerializer::Serialize(), Coin::Serialize(), CScriptCompressor::Serialize(), TxInUndoDeserializer::Unserialize(), Coin::Unserialize(), and CScriptCompressor::Unserialize().
Enumeration Type Documentation
◆ anonymous enum
anonymous enum |
Enumerator | |
---|---|
SER_NETWORK | |
SER_DISK | |
SER_GETHASH |
Definition at line 157 of file serialize.h.
Function Documentation
◆ GetSerializeSize() [1/2]
size_t GetSerializeSize | ( | const T & | t, |
int | nType, | ||
int | nVersion = 0 |
||
) |
Definition at line 1295 of file serialize.h.
Referenced by AddOrphanTx(), blockToJSON(), CheckBlock(), CheckTransaction(), ContextualCheckBlock(), ContextualCheckTransaction(), CWallet::CreateTransaction(), CTransactionBuilder::CTransactionBuilder(), CTxMemPoolEntry::CTxMemPoolEntry(), dashconsensus_verify_script(), getblockstats(), GetDustThreshold(), CTransaction::GetTotalSize(), WalletModelTransaction::getTransactionSize(), PartiallyDownloadedBlock::InitData(), IsStandardTx(), MempoolEviction(), SaveBlockToDisk(), CAutoBitSet::Serialize(), TxToUniv(), CDBTransaction< RootTransaction, RootTransaction >::Write(), WriteBlockToDisk(), WriteTxIndexDataForBlock(), and WriteUndoDataForBlock().
◆ GetSerializeSize() [2/2]
size_t GetSerializeSize | ( | const S & | s, |
const T & | t | ||
) |
Definition at line 1301 of file serialize.h.
◆ GetSizeOfCompactSize()
|
inline |
Compact Size size < 253 – 1 byte size <= USHRT_MAX – 3 bytes (253 + 2 bytes) size <= UINT_MAX – 5 bytes (254 + 4 bytes) size > UINT_MAX – 9 bytes (255 + 8 bytes)
Definition at line 225 of file serialize.h.
References CSizeComputer::nSize.
Referenced by CWallet::CreateTransaction(), CCompactSize::GetSerializeSize(), GetSizeOfCompactSizeDiff(), WriteCompactSize(), and WriteTxIndexDataForBlock().
◆ GetSizeOfVarInt()
|
inline |
Variable-length integers: bytes are a MSB base-128 encoding of the number.
The high bit in each byte signifies whether another digit follows. To make sure the encoding is one-to-one, one is subtracted from all but the last digit. Thus, the byte sequence a[] with length len, where all but the last byte has bit 128 set, encodes the number:
(a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1))
Properties:
- Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes)
- Every integer has exactly one encoding
- Encoding does not depend on size of original integer type
- No redundancy: every (infinite) byte sequence corresponds to a list of encoded integers.
0: [0x00] 256: [0x81 0x00] 1: [0x01] 16383: [0xFE 0x7F] 127: [0x7F] 16384: [0xFF 0x00] 128: [0x80 0x00] 16511: [0xFF 0x7F] 255: [0x80 0x7F] 65535: [0x82 0xFE 0x7F] 2^32: [0x8E 0xFE 0xFE 0xFF 0x00]
Definition at line 317 of file serialize.h.
◆ NCONST_PTR()
|
inline |
Used to acquire a non-const pointer "this" to generate bodies of const serialization operations from a template.
Definition at line 60 of file serialize.h.
Referenced by CDeterministicMN::Serialize(), and CDeterministicMNList::Serialize().
◆ ReadCompactSize()
uint64_t ReadCompactSize | ( | Stream & | is | ) |
Definition at line 261 of file serialize.h.
References MAX_SIZE, ser_readdata16(), ser_readdata32(), ser_readdata64(), and ser_readdata8().
Referenced by ProcessMessage(), CPubKey::Unserialize(), CExtKey::Unserialize(), CExtPubKey::Unserialize(), CDeterministicMNList::Unserialize(), CDynamicBitSet::Unserialize(), CDeterministicMNListDiff::Unserialize(), CDeterministicMNListDiff_OldFormat::Unserialize(), LimitedString< Limit >::Unserialize(), Unserialize(), Unserialize_impl(), UnserializeImmerMap(), UnserializeMap(), and UnserializeSet().
◆ ReadVarInt()
I ReadVarInt | ( | Stream & | is | ) |
Definition at line 350 of file serialize.h.
References ser_readdata8().
◆ REF()
|
inline |
Used to bypass the rule against non-const reference to temporary where it makes sense with wrappers such as CFlatData or CTxDB.
Definition at line 50 of file serialize.h.
Referenced by BlockTransactions::SerializationOp(), CTxOutCompressor::SerializationOp(), PrefilledTransaction::SerializationOp(), TxInUndoSerializer::Serialize(), Coin::Serialize(), CTxUndo::Serialize(), CDynamicBitSet::Serialize(), TxInUndoDeserializer::Unserialize(), Coin::Unserialize(), CScriptCompressor::Unserialize(), and CTxUndo::Unserialize().
◆ ser_double_to_uint64()
|
inline |
Definition at line 123 of file serialize.h.
Referenced by Serialize().
◆ ser_float_to_uint32()
|
inline |
Definition at line 129 of file serialize.h.
Referenced by Serialize().
◆ ser_readdata16()
|
inline |
Definition at line 99 of file serialize.h.
References le16toh().
Referenced by ReadCompactSize(), and Unserialize().
◆ ser_readdata32()
|
inline |
Definition at line 105 of file serialize.h.
References le32toh().
Referenced by ReadCompactSize(), CAddressUnspentKey::Unserialize(), Unserialize(), and CAddressIndexKey::Unserialize().
◆ ser_readdata32be()
|
inline |
Definition at line 111 of file serialize.h.
References be32toh().
Referenced by CTimestampIndexIteratorKey::Unserialize(), CTimestampIndexKey::Unserialize(), CAddressIndexKey::Unserialize(), and CAddressIndexIteratorHeightKey::Unserialize().
◆ ser_readdata64()
|
inline |
Definition at line 117 of file serialize.h.
References le64toh().
Referenced by ReadCompactSize(), and Unserialize().
◆ ser_readdata8()
|
inline |
Definition at line 93 of file serialize.h.
Referenced by ReadCompactSize(), ReadVarInt(), CAddressUnspentKey::Unserialize(), Unserialize(), CAddressIndexKey::Unserialize(), CAddressIndexIteratorKey::Unserialize(), CAddressIndexIteratorHeightKey::Unserialize(), and CAutoBitSet::Unserialize().
◆ ser_uint32_to_float()
|
inline |
Definition at line 141 of file serialize.h.
Referenced by Unserialize().
◆ ser_uint64_to_double()
|
inline |
Definition at line 135 of file serialize.h.
Referenced by Unserialize().
◆ ser_writedata16()
|
inline |
Definition at line 73 of file serialize.h.
References htole16().
Referenced by Serialize(), and WriteCompactSize().
◆ ser_writedata32()
|
inline |
Definition at line 78 of file serialize.h.
References htole32().
Referenced by CAddressUnspentKey::Serialize(), Serialize(), CAddressIndexKey::Serialize(), and WriteCompactSize().
◆ ser_writedata32be()
|
inline |
Definition at line 83 of file serialize.h.
References htobe32().
Referenced by CTimestampIndexIteratorKey::Serialize(), CTimestampIndexKey::Serialize(), CAddressIndexKey::Serialize(), and CAddressIndexIteratorHeightKey::Serialize().
◆ ser_writedata64()
|
inline |
Definition at line 88 of file serialize.h.
References htole64().
Referenced by Serialize(), and WriteCompactSize().
◆ ser_writedata8()
|
inline |
Definition at line 69 of file serialize.h.
Referenced by CAddressUnspentKey::Serialize(), Serialize(), CAddressIndexKey::Serialize(), CAddressIndexIteratorKey::Serialize(), CAddressIndexIteratorHeightKey::Serialize(), CAutoBitSet::Serialize(), WriteCompactSize(), and WriteVarInt().
◆ Serialize() [1/26]
|
inline |
Definition at line 184 of file serialize.h.
References ser_writedata8().
Referenced by CVectorWriter::operator<<(), CHashWriter::operator<<(), CAutoFile::operator<<(), CSizeComputer::operator<<(), Serialize(), Serialize_impl(), SerializeImmerMap(), SerializeMany(), SerializeMap(), SerializeSet(), and SerReadWrite().
◆ Serialize() [2/26]
|
inline |
Definition at line 185 of file serialize.h.
References ser_writedata8().
◆ Serialize() [3/26]
|
inline |
Definition at line 186 of file serialize.h.
References ser_writedata8().
◆ Serialize() [4/26]
|
inline |
Definition at line 187 of file serialize.h.
References ser_writedata16().
◆ Serialize() [5/26]
|
inline |
Definition at line 188 of file serialize.h.
References ser_writedata16().
◆ Serialize() [6/26]
|
inline |
Definition at line 189 of file serialize.h.
References ser_writedata32().
◆ Serialize() [7/26]
|
inline |
Definition at line 190 of file serialize.h.
References ser_writedata32().
◆ Serialize() [8/26]
|
inline |
Definition at line 191 of file serialize.h.
References ser_writedata64().
◆ Serialize() [9/26]
|
inline |
Definition at line 192 of file serialize.h.
References ser_writedata64().
◆ Serialize() [10/26]
|
inline |
Definition at line 193 of file serialize.h.
References ser_float_to_uint32(), and ser_writedata32().
◆ Serialize() [11/26]
|
inline |
Definition at line 194 of file serialize.h.
References ser_double_to_uint64(), and ser_writedata64().
◆ Serialize() [12/26]
|
inline |
Definition at line 208 of file serialize.h.
References ser_writedata8().
◆ Serialize() [13/26]
void Serialize | ( | Stream & | os, |
const std::basic_string< C > & | str | ||
) |
Forward declarations.
string
Definition at line 777 of file serialize.h.
References C, and WriteCompactSize().
◆ Serialize() [14/26]
|
inline |
Definition at line 815 of file serialize.h.
References Serialize_impl().
◆ Serialize() [15/26]
|
inline |
Definition at line 883 of file serialize.h.
References Serialize_impl().
◆ Serialize() [16/26]
void Serialize | ( | Stream & | os, |
const std::pair< K, T > & | item | ||
) |
◆ Serialize() [17/26]
void Serialize | ( | Stream & | os, |
const std::tuple< Elements... > & | item | ||
) |
pair
Definition at line 983 of file serialize.h.
◆ Serialize() [18/26]
void Serialize | ( | Stream & | os, |
const std::map< K, T, Pred, A > & | m | ||
) |
◆ Serialize() [19/26]
void Serialize | ( | Stream & | os, |
const std::unordered_map< K, T, Hash, Pred, A > & | m | ||
) |
Definition at line 1035 of file serialize.h.
References SerializeMap().
◆ Serialize() [20/26]
void Serialize | ( | Stream & | os, |
const std::set< K, Pred, A > & | m | ||
) |
◆ Serialize() [21/26]
void Serialize | ( | Stream & | os, |
const std::unordered_set< K, Hash, Pred, A > & | m | ||
) |
Definition at line 1085 of file serialize.h.
References SerializeSet().
◆ Serialize() [22/26]
void Serialize | ( | Stream & | os, |
const std::shared_ptr< T > & | p | ||
) |
◆ Serialize() [23/26]
void Serialize | ( | Stream & | os, |
const std::unique_ptr< const T > & | p | ||
) |
◆ Serialize() [24/26]
|
inline |
If none of the specialized versions above matched and T is a class, default to calling member function.
Definition at line 726 of file serialize.h.
◆ Serialize() [25/26]
|
inline |
Definition at line 748 of file serialize.h.
References Serialize().
◆ Serialize() [26/26]
void Serialize | ( | Stream & | os, |
const std::list< T, A > & | l | ||
) |
◆ Serialize_impl() [1/4]
void Serialize_impl | ( | Stream & | os, |
const prevector< N, T > & | v, | ||
const unsigned char & | |||
) |
prevector prevectors of unsigned char are a special case and are intended to be serialized as a single opaque blob.
prevector
Definition at line 799 of file serialize.h.
References prevector< N, T, Size, Diff >::data(), prevector< N, T, Size, Diff >::empty(), prevector< N, T, Size, Diff >::size(), and WriteCompactSize().
Referenced by Serialize().
◆ Serialize_impl() [2/4]
void Serialize_impl | ( | Stream & | os, |
const prevector< N, T > & | v, | ||
const V & | |||
) |
Definition at line 807 of file serialize.h.
References prevector< N, T, Size, Diff >::begin(), prevector< N, T, Size, Diff >::end(), Serialize(), prevector< N, T, Size, Diff >::size(), and WriteCompactSize().
◆ Serialize_impl() [3/4]
void Serialize_impl | ( | Stream & | os, |
const std::vector< T, A > & | v, | ||
const unsigned char & | |||
) |
vector vectors of unsigned char are a special case and are intended to be serialized as a single opaque blob.
vector
Definition at line 867 of file serialize.h.
References WriteCompactSize().
◆ Serialize_impl() [4/4]
void Serialize_impl | ( | Stream & | os, |
const std::vector< T, A > & | v, | ||
const V & | |||
) |
Definition at line 875 of file serialize.h.
References Serialize(), and WriteCompactSize().
◆ SerializeMany() [1/3]
void SerializeMany | ( | Stream & | s | ) |
Definition at line 1236 of file serialize.h.
Referenced by CDataStream::CDataStream(), CVectorWriter::CVectorWriter(), SerializeMany(), and SerReadWriteMany().
◆ SerializeMany() [2/3]
void SerializeMany | ( | Stream & | s, |
Arg && | arg | ||
) |
Definition at line 1241 of file serialize.h.
References Serialize().
◆ SerializeMany() [3/3]
void SerializeMany | ( | Stream & | s, |
Arg && | arg, | ||
Args &&... | args | ||
) |
Definition at line 1247 of file serialize.h.
References Serialize(), and SerializeMany().
◆ SerializeMap()
void SerializeMap | ( | Stream & | os, |
const Map & | m | ||
) |
map
Definition at line 1001 of file serialize.h.
References Serialize(), and WriteCompactSize().
Referenced by Serialize().
◆ SerializeSet()
void SerializeSet | ( | Stream & | os, |
const Set & | m | ||
) |
set
Definition at line 1051 of file serialize.h.
References Serialize(), and WriteCompactSize().
Referenced by Serialize().
◆ SerReadWrite() [1/2]
|
inline |
Definition at line 1169 of file serialize.h.
References Serialize().
◆ SerReadWrite() [2/2]
|
inline |
Definition at line 1175 of file serialize.h.
References Unserialize().
◆ SerReadWriteMany() [1/2]
|
inline |
Definition at line 1272 of file serialize.h.
References SerializeMany().
◆ SerReadWriteMany() [2/2]
|
inline |
Definition at line 1278 of file serialize.h.
References UnserializeMany().
◆ Unserialize() [1/25]
|
inline |
Definition at line 196 of file serialize.h.
References ser_readdata8().
Referenced by CMutableTransaction::CMutableTransaction(), CHashVerifier< Source >::operator>>(), CDataStream::operator>>(), CAutoFile::operator>>(), CBufferedFile::operator>>(), SerReadWrite(), Unserialize(), Unserialize_impl(), UnserializeImmerMap(), UnserializeMany(), UnserializeMap(), and UnserializeSet().
◆ Unserialize() [2/25]
|
inline |
Definition at line 197 of file serialize.h.
References ser_readdata8().
◆ Unserialize() [3/25]
|
inline |
Definition at line 198 of file serialize.h.
References ser_readdata8().
◆ Unserialize() [4/25]
|
inline |
Definition at line 199 of file serialize.h.
References ser_readdata16().
◆ Unserialize() [5/25]
|
inline |
Definition at line 200 of file serialize.h.
References ser_readdata16().
◆ Unserialize() [6/25]
|
inline |
Definition at line 201 of file serialize.h.
References ser_readdata32().
◆ Unserialize() [7/25]
|
inline |
Definition at line 202 of file serialize.h.
References ser_readdata32().
◆ Unserialize() [8/25]
|
inline |
Definition at line 203 of file serialize.h.
References ser_readdata64().
◆ Unserialize() [9/25]
|
inline |
Definition at line 204 of file serialize.h.
References ser_readdata64().
◆ Unserialize() [10/25]
|
inline |
Definition at line 205 of file serialize.h.
References ser_readdata32(), and ser_uint32_to_float().
◆ Unserialize() [11/25]
|
inline |
Definition at line 206 of file serialize.h.
References ser_readdata64(), and ser_uint64_to_double().
◆ Unserialize() [12/25]
|
inline |
Definition at line 209 of file serialize.h.
References ser_readdata8().
◆ Unserialize() [13/25]
void Unserialize | ( | Stream & | is, |
std::basic_string< C > & | str | ||
) |
Definition at line 785 of file serialize.h.
References C, and ReadCompactSize().
◆ Unserialize() [14/25]
|
inline |
Definition at line 856 of file serialize.h.
References Unserialize_impl().
◆ Unserialize() [15/25]
|
inline |
Definition at line 924 of file serialize.h.
References Unserialize_impl().
◆ Unserialize() [16/25]
void Unserialize | ( | Stream & | is, |
std::pair< K, T > & | item | ||
) |
Definition at line 942 of file serialize.h.
References Unserialize().
◆ Unserialize() [17/25]
void Unserialize | ( | Stream & | is, |
std::tuple< Elements... > & | item | ||
) |
Definition at line 990 of file serialize.h.
◆ Unserialize() [18/25]
void Unserialize | ( | Stream & | is, |
std::map< K, T, Pred, A > & | m | ||
) |
Definition at line 1029 of file serialize.h.
References UnserializeMap().
◆ Unserialize() [19/25]
void Unserialize | ( | Stream & | is, |
std::unordered_map< K, T, Hash, Pred, A > & | m | ||
) |
Definition at line 1041 of file serialize.h.
References UnserializeMap().
◆ Unserialize() [20/25]
void Unserialize | ( | Stream & | is, |
std::set< K, Pred, A > & | m | ||
) |
Definition at line 1079 of file serialize.h.
References UnserializeSet().
◆ Unserialize() [21/25]
void Unserialize | ( | Stream & | is, |
std::unordered_set< K, Hash, Pred, A > & | m | ||
) |
Definition at line 1091 of file serialize.h.
References UnserializeSet().
◆ Unserialize() [22/25]
void Unserialize | ( | Stream & | os, |
std::shared_ptr< T > & | p | ||
) |
Definition at line 1149 of file serialize.h.
References deserialize.
◆ Unserialize() [23/25]
void Unserialize | ( | Stream & | os, |
std::unique_ptr< const T > & | p | ||
) |
Definition at line 1132 of file serialize.h.
References deserialize.
◆ Unserialize() [24/25]
|
inline |
Definition at line 732 of file serialize.h.
◆ Unserialize() [25/25]
void Unserialize | ( | Stream & | is, |
std::list< T, A > & | l | ||
) |
Definition at line 1108 of file serialize.h.
References ReadCompactSize(), and Unserialize().
◆ Unserialize_impl() [1/4]
void Unserialize_impl | ( | Stream & | is, |
prevector< N, T > & | v, | ||
const unsigned char & | |||
) |
Definition at line 822 of file serialize.h.
References prevector< N, T, Size, Diff >::clear(), ReadCompactSize(), and prevector< N, T, Size, Diff >::resize_uninitialized().
Referenced by Unserialize().
◆ Unserialize_impl() [2/4]
void Unserialize_impl | ( | Stream & | is, |
prevector< N, T > & | v, | ||
const V & | |||
) |
Definition at line 838 of file serialize.h.
References prevector< N, T, Size, Diff >::clear(), ReadCompactSize(), prevector< N, T, Size, Diff >::resize_uninitialized(), and Unserialize().
◆ Unserialize_impl() [3/4]
void Unserialize_impl | ( | Stream & | is, |
std::vector< T, A > & | v, | ||
const unsigned char & | |||
) |
Definition at line 890 of file serialize.h.
References ReadCompactSize().
◆ Unserialize_impl() [4/4]
void Unserialize_impl | ( | Stream & | is, |
std::vector< T, A > & | v, | ||
const V & | |||
) |
Definition at line 906 of file serialize.h.
References ReadCompactSize(), and Unserialize().
◆ UnserializeMany() [1/3]
|
inline |
Definition at line 1254 of file serialize.h.
Referenced by SerReadWriteMany(), and UnserializeMany().
◆ UnserializeMany() [2/3]
|
inline |
Definition at line 1259 of file serialize.h.
References Unserialize().
◆ UnserializeMany() [3/3]
|
inline |
Definition at line 1265 of file serialize.h.
References Unserialize(), and UnserializeMany().
◆ UnserializeMap()
void UnserializeMap | ( | Stream & | is, |
Map & | m | ||
) |
Definition at line 1009 of file serialize.h.
References ReadCompactSize(), and Unserialize().
Referenced by Unserialize().
◆ UnserializeSet()
void UnserializeSet | ( | Stream & | is, |
Set & | m | ||
) |
Definition at line 1059 of file serialize.h.
References ReadCompactSize(), and Unserialize().
Referenced by Unserialize().
◆ WrapVarInt()
CVarInt<I> WrapVarInt | ( | I & | n | ) |
Definition at line 646 of file serialize.h.
◆ WriteCompactSize() [1/2]
|
inline |
Definition at line 1289 of file serialize.h.
References GetSizeOfCompactSize(), and CSizeComputer::seek().
Referenced by CPubKey::Serialize(), CExtKey::Serialize(), CExtPubKey::Serialize(), CDeterministicMNList::Serialize(), CDynamicBitSet::Serialize(), CDeterministicMNListDiff::Serialize(), LimitedString< Limit >::Serialize(), Serialize(), Serialize_impl(), SerializeImmerMap(), SerializeMap(), and SerializeSet().
◆ WriteCompactSize() [2/2]
void WriteCompactSize | ( | Stream & | os, |
uint64_t | nSize | ||
) |
Definition at line 236 of file serialize.h.
References CSizeComputer::nSize, ser_writedata16(), ser_writedata32(), ser_writedata64(), and ser_writedata8().
◆ WriteVarInt() [1/2]
|
inline |
Definition at line 1284 of file serialize.h.
References CSizeComputer::seek().
Referenced by CFixedVarIntsBitSet::Serialize(), and CDeterministicMNListDiff::Serialize().
◆ WriteVarInt() [2/2]
void WriteVarInt | ( | Stream & | os, |
I | n | ||
) |
Definition at line 333 of file serialize.h.
References ser_writedata8().
Variable Documentation
◆ deserialize
constexpr deserialize_type deserialize {} |
Definition at line 43 of file serialize.h.
Referenced by dashconsensus_verify_script(), CPrivateSendClientSession::ProcessMessage(), CDeterministicMNList::Unserialize(), and Unserialize().
◆ MAX_SIZE
|
static |
Definition at line 29 of file serialize.h.
Referenced by InitHTTPServer(), CMessageHeader::IsValid(), ReadCompactSize(), and CNetMessage::readHeader().