-
Notifications
You must be signed in to change notification settings - Fork 7
Data Stream
Hantao Sun edited this page Dec 24, 2019
·
2 revisions
Data-Stream is a series of functions for serialization and deserialization of class from or to a vector. It supports basic types, std::vector
, and std::map
. If a customized class or struct to be streamed by Data-Stream, there must overwrite ToDataStream
and FromDataStream
functions. For example:
class CDestination
{
public:
uint8 prefix;
uint256 data;
void ToDataStream(xengine::CODataStream& os) const
{
os << prefix << data;
}
void FromDataStream(xengine::CIDataStream& is)
{
is >> prefix >> data;
}
It looks like a continuous byte order in memory.
- First, serialize or deserialize the length of the variable. It is 8 bytes(
sizeof(size_t)
) - Then, serialize or deserialize every item of
std::vector
,std::map
- For a vector, if the item is not a basic type, recursively the rules.
- For a map, serialize or deserialize its key and value of each item. If they are not a basic type, recursively the rules.
uint256
is a customized struct to simulate a 32-byte number by 32-byte char array. And uint224
is 28-byte.
It looks like a continuous byte order in memory.
- Source Installation
- Executable Programs
- Take A Tour of BigBang
- CPoW SOLO Guide
- Create Forks
- Exchange Token Between Two Forks
- Mining by Connect to The Pool
- Miner Program
- EDPoS Vote Guide
- JSON RPC
- Command Line Tool
- TX vchdata serialization definition
- Tx signature field structure
- Multisignature
- IO Stream
- Data Stream