mirror of
https://github.com/Xahau/xahaud.git
synced 2026-06-04 01:06:37 +00:00
workinggit add -u
This commit is contained in:
@@ -305,6 +305,20 @@ Ledger::Ledger(
|
||||
}
|
||||
}
|
||||
|
||||
Ledger::Ledger(
|
||||
LedgerInfo& info,
|
||||
Config const& config,
|
||||
Family& family,
|
||||
SHAMap const& baseState)
|
||||
: mImmutable(false)
|
||||
, info_(info)
|
||||
, txMap_(SHAMapType::TRANSACTION, family)
|
||||
, stateMap_(baseState, true)
|
||||
, rules_{config.features}
|
||||
, j_(beast::Journal(beast::Journal::getNullSink()))
|
||||
{
|
||||
}
|
||||
|
||||
// Create a new ledger that follows this one
|
||||
Ledger::Ledger(Ledger const& prevLedger, NetClock::time_point closeTime)
|
||||
: mImmutable(false)
|
||||
|
||||
@@ -121,6 +121,13 @@ public:
|
||||
Family& family,
|
||||
beast::Journal j);
|
||||
|
||||
// used when loading ledgers from catalogue files
|
||||
Ledger(
|
||||
LedgerInfo& info,
|
||||
Config const& config,
|
||||
Family& family,
|
||||
SHAMap const& baseState);
|
||||
|
||||
/** Create a new ledger following a previous ledger
|
||||
|
||||
The ledger will have the sequence number that
|
||||
|
||||
@@ -112,10 +112,9 @@ private:
|
||||
|
||||
auto const& info = ledger->info();
|
||||
|
||||
uint64_t closeTime =
|
||||
0xCAFED00DCAFEBABEULL; // info.closeTime.time_since_epoch().count();
|
||||
uint64_t parentCloseTime = 0xDEADBEEFC001D00D;
|
||||
// info.parentCloseTime.time_since_epoch().count();
|
||||
uint64_t closeTime = info.closeTime.time_since_epoch().count();
|
||||
uint64_t parentCloseTime =
|
||||
info.parentCloseTime.time_since_epoch().count();
|
||||
uint32_t closeTimeResolution = info.closeTimeResolution.count();
|
||||
|
||||
uint64_t drops = info.drops.drops();
|
||||
@@ -432,16 +431,23 @@ doCatalogueLoad(RPC::JsonContext& context)
|
||||
return rpcError(rpcINTERNAL, "Missing previous ledger");
|
||||
}
|
||||
|
||||
// Create ledger from previous
|
||||
auto snapshot = prevLedger->stateMap().snapShot(true);
|
||||
|
||||
ledger = std::make_shared<Ledger>(
|
||||
*prevLedger, context.app.timeKeeper().closeTime());
|
||||
|
||||
ledger->setLedgerInfo(info);
|
||||
info,
|
||||
context.app.config(),
|
||||
context.app.getNodeFamily(),
|
||||
*snapshot);
|
||||
/*
|
||||
// Create ledger from previous
|
||||
ledger = std::make_shared<Ledger>(
|
||||
*prevLedger, context.app.timeKeeper().closeTime());
|
||||
|
||||
ledger->setLedgerInfo(info);
|
||||
*/
|
||||
// Apply delta (only leaf-node changes)
|
||||
SHAMap const& prevMap = prevLedger->stateMap();
|
||||
|
||||
if (!ledger->stateMap().deserializeFromStream(infile, prevMap))
|
||||
if (!ledger->stateMap().deserializeFromStream(infile))
|
||||
{
|
||||
JLOG(context.j.error())
|
||||
<< "Failed to apply delta to ledger " << info.seq;
|
||||
|
||||
@@ -394,10 +394,9 @@ public:
|
||||
* @return True if deserialization succeeded
|
||||
*/
|
||||
bool
|
||||
deserializeFromStream(
|
||||
std::istream& stream,
|
||||
std::optional<std::reference_wrapper<const SHAMap>> baseSHAMap =
|
||||
std::nullopt);
|
||||
deserializeFromStream(std::istream& stream);
|
||||
// std::optional<std::reference_wrapper<const SHAMap>> baseSHAMap =
|
||||
// std::nullopt);
|
||||
|
||||
private:
|
||||
using SharedPtrNodeStack =
|
||||
|
||||
@@ -1300,8 +1300,8 @@ SHAMap::serializeToStream(
|
||||
// Process each difference
|
||||
for (auto const& [key, deltaItem] : differences)
|
||||
{
|
||||
auto const& oldItem = deltaItem.first;
|
||||
auto const& newItem = deltaItem.second;
|
||||
auto const& newItem = deltaItem.first;
|
||||
auto const& oldItem = deltaItem.second;
|
||||
|
||||
if (!oldItem && newItem)
|
||||
{
|
||||
@@ -1392,9 +1392,8 @@ SHAMap::serializeToStream(
|
||||
}
|
||||
|
||||
bool
|
||||
SHAMap::deserializeFromStream(
|
||||
std::istream& stream,
|
||||
std::optional<std::reference_wrapper<const SHAMap>> baseSHAMap)
|
||||
SHAMap::deserializeFromStream(std::istream& stream)
|
||||
//, std::optional<std::reference_wrapper<const SHAMap>> baseSHAMap)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1405,18 +1404,22 @@ SHAMap::deserializeFromStream(
|
||||
if (state_ != SHAMapState::Modifying && state_ != SHAMapState::Synching)
|
||||
return false;
|
||||
|
||||
// If we have a base map, start with a copy of it
|
||||
if (baseSHAMap)
|
||||
{
|
||||
root_ = baseSHAMap->get().root_;
|
||||
if (root_)
|
||||
unshare();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start with a fresh empty root
|
||||
if (!root_)
|
||||
root_ = std::make_shared<SHAMapInnerNode>(cowid_);
|
||||
}
|
||||
/*
|
||||
// If we have a base map, start with a copy of it
|
||||
if (baseSHAMap.has_value())
|
||||
{
|
||||
root_ = baseSHAMap->get().root_;
|
||||
if (root_)
|
||||
unshare();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start with a fresh empty root
|
||||
root_ = std::make_shared<SHAMapInnerNode>(cowid_);
|
||||
}
|
||||
*/
|
||||
|
||||
// Define a lambda to deserialize a leaf node
|
||||
auto deserializeLeaf = [this](
|
||||
@@ -1498,9 +1501,15 @@ SHAMap::deserializeFromStream(
|
||||
|
||||
auto item = make_shamapitem(key, makeSlice(data));
|
||||
if (hasItem(key))
|
||||
{
|
||||
std::cout << "Modifying item: " << to_string(key) << "\n";
|
||||
return updateGiveItem(nodeType, std::move(item));
|
||||
|
||||
return addGiveItem(nodeType, std::move(item));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Adding item: " << to_string(key) << "\n";
|
||||
return addGiveItem(nodeType, std::move(item));
|
||||
}
|
||||
};
|
||||
|
||||
SHAMapNodeType lastParsed;
|
||||
|
||||
Reference in New Issue
Block a user