mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Introducing ledger shards and new ledger syncing logic. (#247)
- The ledgers are stored in a sqlite database in ledger file system. - Ledgers are organized in shards inside primary folder. - Raw inputs are saved as shards inside blob folder. No input files are created if neither inputs nor outputs are available. - Both last primary shard hash and last blob shard hashes are subjected to consensus and necessary sync operations are performed if out of sync. - Hpfs sync support setting single sync targets from both ends of the list. (Targets set from front are prioritized). - Contract and ledger syncs and serving are performed independently.
This commit is contained in:
committed by
GitHub
parent
e394497698
commit
16c5b3fae2
@@ -410,4 +410,35 @@ namespace util
|
||||
lock.l_type = F_UNLCK;
|
||||
return fcntl(fd, F_SETLKW, &lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert given little endian byte stream to uint64_t.
|
||||
* @param data Byte stream to be converted.
|
||||
* @return Returns converted uint64_t.
|
||||
*/
|
||||
uint64_t uint64_from_bytes(const uint8_t *data)
|
||||
{
|
||||
return ((uint64_t)data[0] << 56) +
|
||||
((uint64_t)data[1] << 48) +
|
||||
((uint64_t)data[2] << 40) +
|
||||
((uint64_t)data[3] << 32) +
|
||||
((uint64_t)data[4] << 24) +
|
||||
((uint64_t)data[5] << 16) +
|
||||
((uint64_t)data[6] << 8) +
|
||||
((uint64_t)data[7]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert given uint64_t to little endian byte stream.
|
||||
* @param dest Byte stream to be populated.
|
||||
* @param x uint64_t to be converted.
|
||||
*/
|
||||
void uint64_to_bytes(uint8_t *dest, uint64_t x)
|
||||
{
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
*(dest + (7 - j)) = x & 0xff;
|
||||
x >>= 8;
|
||||
}
|
||||
}
|
||||
} // namespace util
|
||||
|
||||
Reference in New Issue
Block a user