mirror of
https://github.com/Xahau/xahaud.git
synced 2026-07-27 00:50:20 +00:00
fix close flags (hacky) and more debug
This commit is contained in:
@@ -385,6 +385,12 @@ Ledger::setImmutable(bool rehash)
|
||||
setup();
|
||||
}
|
||||
|
||||
void
|
||||
Ledger::setCloseFlags(int closeFlags)
|
||||
{
|
||||
info_.closeFlags = closeFlags;
|
||||
}
|
||||
|
||||
void
|
||||
Ledger::setAccepted(
|
||||
NetClock::time_point closeTime,
|
||||
|
||||
@@ -275,6 +275,9 @@ public:
|
||||
void
|
||||
setImmutable(bool rehash = true);
|
||||
|
||||
void
|
||||
setCloseFlags(int closeFlags);
|
||||
|
||||
bool
|
||||
isImmutable() const
|
||||
{
|
||||
@@ -306,6 +309,8 @@ public:
|
||||
info_.drops = totDrops;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SHAMap const&
|
||||
stateMap() const
|
||||
{
|
||||
|
||||
@@ -724,10 +724,18 @@ doCatalogueLoad(RPC::JsonContext& context)
|
||||
infile.read(
|
||||
reinterpret_cast<char*>(&info.parentCloseTime),
|
||||
sizeof(info.parentCloseTime));
|
||||
infile.read(info.hash.cdata(), 32);
|
||||
infile.read(info.txHash.cdata(), 32);
|
||||
infile.read(info.accountHash.cdata(), 32);
|
||||
|
||||
char orig_hash[32], orig_ah[32], orig_th[32];
|
||||
|
||||
|
||||
infile.read(&orig_hash[0], 32); info.hash = beast::zero;
|
||||
infile.read(&orig_th[0], 32); info.txHash = beast::zero;
|
||||
infile.read(&orig_ah[0], 32); info.accountHash = beast::zero;
|
||||
// infile.read(info.hash.cdata(), 32);
|
||||
// infile.read(info.txHash.cdata(), 32);
|
||||
// infile.read(info.accountHash.cdata(), 32);
|
||||
infile.read(info.parentHash.cdata(), 32);
|
||||
|
||||
infile.read(reinterpret_cast<char*>(&info.drops), sizeof(info.drops));
|
||||
infile.read(
|
||||
reinterpret_cast<char*>(&info.validated), sizeof(info.validated));
|
||||
@@ -867,7 +875,7 @@ doCatalogueLoad(RPC::JsonContext& context)
|
||||
|
||||
std::cout << "Read state data at pos " << it->filePos
|
||||
<< " size " << it->size
|
||||
<< " hex: " << strHex(makeSlice(data))
|
||||
//<< " hex: " << strHex(makeSlice(data))
|
||||
<< std::endl;
|
||||
|
||||
// Verify data read was successful
|
||||
@@ -897,16 +905,39 @@ doCatalogueLoad(RPC::JsonContext& context)
|
||||
std::cout << "Applied " << stateChangeCount << " state changes"
|
||||
<< std::endl;
|
||||
|
||||
currentLedger->stateMap().flushDirty(hotACCOUNT_NODE);
|
||||
currentLedger->updateSkipList();
|
||||
currentLedger->stateMap().flushDirty(hotACCOUNT_NODE);
|
||||
currentLedger->txMap().flushDirty(hotTRANSACTION_NODE);
|
||||
|
||||
currentLedger->unshare(); //?
|
||||
|
||||
auto const ah = currentLedger->stateMap().getHash().as_uint256();
|
||||
auto const th = currentLedger->txMap().getHash().as_uint256();
|
||||
|
||||
std::cout << "ah: " << to_string(ah) << " orig: " << to_string(uint256::fromVoid(orig_ah)) << "\n";
|
||||
std::cout << "th: " << to_string(th) << " orig: " << to_string(uint256::fromVoid(orig_th)) << "\n";
|
||||
|
||||
memcpy(info.accountHash.cdata(), ah.data(), 32);
|
||||
memcpy(info.txHash.cdata(), th.data(), 32);
|
||||
|
||||
currentLedger->setLedgerInfo(info);
|
||||
|
||||
// infile.read(info.txHash.cdata(), 32);
|
||||
// infile.read(info.accountHash.cdata(), 32);
|
||||
|
||||
// Finalize and store the ledger
|
||||
currentLedger->setValidated();
|
||||
|
||||
auto cf = currentLedger->info().closeFlags;
|
||||
currentLedger->setAccepted(
|
||||
currentLedger->info().closeTime,
|
||||
currentLedger->info().closeTimeResolution,
|
||||
currentLedger->info().closeFlags & sLCF_NoConsensusTime);
|
||||
|
||||
// hacky
|
||||
currentLedger->setCloseFlags(cf);
|
||||
|
||||
|
||||
// Set the ledger as immutable after all mutations are complete
|
||||
currentLedger->setImmutable(true);
|
||||
|
||||
|
||||
@@ -326,19 +326,46 @@ class Catalogue_test : public beast::unit_test::suite
|
||||
auto const loadedLedger = loadEnv.closed();
|
||||
|
||||
// After loading each ledger
|
||||
std::cout << "Original ledger hash: "
|
||||
<< to_string(sourceLedger->info().hash)
|
||||
<< "\nLoaded ledger hash: "
|
||||
<< to_string(loadedLedger->info().hash)
|
||||
<< "Original ledger seq: "
|
||||
<< to_string(sourceLedger->info().seq)
|
||||
<< "\nLoaded ledger seq: "
|
||||
<< to_string(loadedLedger->info().seq) << std::endl;
|
||||
//
|
||||
// After loading each ledger
|
||||
std::cout << "\n=== Original Ledger Information ===\n"
|
||||
<< "Sequence: " << to_string(sourceLedger->info().seq) << "\n"
|
||||
<< "Hash: " << to_string(sourceLedger->info().hash) << "\n"
|
||||
<< "Parent Close Time: " << to_string(sourceLedger->info().parentCloseTime.time_since_epoch().count()) << "\n"
|
||||
<< "Transaction Hash: " << to_string(sourceLedger->info().txHash) << "\n"
|
||||
<< "Account Hash: " << to_string(sourceLedger->info().accountHash) << "\n"
|
||||
<< "Parent Hash: " << to_string(sourceLedger->info().parentHash) << "\n"
|
||||
<< "Drops: " << to_string(sourceLedger->info().drops) << "\n"
|
||||
<< "Validated: " << (sourceLedger->info().validated ? "true" : "false") << "\n"
|
||||
<< "Accepted: " << (sourceLedger->info().accepted ? "true" : "false") << "\n"
|
||||
<< "Close Flags: " << sourceLedger->info().closeFlags << "\n"
|
||||
<< "Close Time Resolution: " << to_string(sourceLedger->info().closeTimeResolution.count()) << "\n"
|
||||
<< "Close Time: " << to_string(sourceLedger->info().closeTime.time_since_epoch().count()) << "\n"
|
||||
<< "\n=== Loaded Ledger Information ===\n"
|
||||
<< "Sequence: " << to_string(loadedLedger->info().seq) << "\n"
|
||||
<< "Hash: " << to_string(loadedLedger->info().hash) << "\n"
|
||||
<< "Parent Close Time: " << to_string(loadedLedger->info().parentCloseTime.time_since_epoch().count()) << "\n"
|
||||
<< "Transaction Hash: " << to_string(loadedLedger->info().txHash) << "\n"
|
||||
<< "Account Hash: " << to_string(loadedLedger->info().accountHash) << "\n"
|
||||
<< "Parent Hash: " << to_string(loadedLedger->info().parentHash) << "\n"
|
||||
<< "Drops: " << to_string(loadedLedger->info().drops) << "\n"
|
||||
<< "Validated: " << (loadedLedger->info().validated ? "true" : "false") << "\n"
|
||||
<< "Accepted: " << (loadedLedger->info().accepted ? "true" : "false") << "\n"
|
||||
<< "Close Flags: " << loadedLedger->info().closeFlags << "\n"
|
||||
<< "Close Time Resolution: " << to_string(loadedLedger->info().closeTimeResolution.count()) << "\n"
|
||||
<< "Close Time: " << to_string(loadedLedger->info().closeTime.time_since_epoch().count()) << "\n"
|
||||
<< std::endl;
|
||||
|
||||
auto const loadedBobAcct = loadedLedger->read(bobKeylet);
|
||||
auto const loadedCharlieAcct = loadedLedger->read(charlieKeylet);
|
||||
auto const loadedEurTrust = loadedLedger->read(eurTrustKeylet);
|
||||
|
||||
auto const& ll = *loadedLedger;
|
||||
|
||||
std::cout << "bob exists: " << (ll.exists(bobKeylet) ? "t" : "f") << "\n";
|
||||
std::cout << "chl exists: " << (ll.exists(charlieKeylet) ? "t" : "f") << "\n";
|
||||
std::cout << "eur exists: " << (ll.exists(eurTrustKeylet) ? "t" : "f") << "\n";
|
||||
|
||||
BEAST_EXPECT(!!loadedBobAcct);
|
||||
BEAST_EXPECT(!!loadedCharlieAcct);
|
||||
BEAST_EXPECT(!!loadedEurTrust);
|
||||
|
||||
Reference in New Issue
Block a user