mirror of
https://github.com/Xahau/xahaud.git
synced 2026-04-29 15:37:46 +00:00
ensure XahauGenesis is enabled correctly just after the genesis ledger
This commit is contained in:
@@ -206,7 +206,14 @@ Ledger::Ledger(
|
||||
if (!amendments.empty())
|
||||
{
|
||||
auto const sle = std::make_shared<SLE>(keylet::amendments());
|
||||
sle->setFieldV256(sfAmendments, STVector256{amendments});
|
||||
|
||||
// filter out XahauGenesis, which should be always activated with an EnableAmendment txn
|
||||
std::vector<uint256> amendmentsLessXahauGenesis;
|
||||
for (auto a: amendments)
|
||||
if (a != featureXahauGenesis)
|
||||
amendmentsLessXahauGenesis.push_back(a);
|
||||
|
||||
sle->setFieldV256(sfAmendments, STVector256{amendmentsLessXahauGenesis});
|
||||
rawInsert(sle);
|
||||
}
|
||||
|
||||
|
||||
@@ -1726,6 +1726,38 @@ ApplicationImp::startGenesisLedger()
|
||||
openLedger_.emplace(next, cachedSLEs_, logs_->journal("OpenLedger"));
|
||||
m_ledgerMaster->storeLedger(next);
|
||||
m_ledgerMaster->switchLCL(next);
|
||||
|
||||
// XahauGenesis must be activated via an enable amendment pseudo txn, otherwise it does nothing
|
||||
// so rather than add it directly to the amendments table, here is its activation on the first open
|
||||
// ledger.
|
||||
for (auto const& a: initialAmendments)
|
||||
{
|
||||
if (a == featureXahauGenesis)
|
||||
{
|
||||
STTx amendTx(
|
||||
ttAMENDMENT,
|
||||
[&](auto& obj) {
|
||||
obj.setAccountID(sfAccount, AccountID());
|
||||
obj.setFieldH256(sfAmendment, featureXahauGenesis);
|
||||
obj.setFieldU32(sfLedgerSequence, openLedger_->current()->info().seq);
|
||||
});
|
||||
|
||||
auto txID = amendTx.getTransactionID();
|
||||
|
||||
auto s = std::make_shared<Serializer>();
|
||||
amendTx.add(*s);
|
||||
|
||||
forceValidity(getHashRouter(), txID, Validity::SigGoodOnly);
|
||||
|
||||
openLedger_->modify(
|
||||
[&txID, &s](OpenView& view, beast::Journal j) {
|
||||
view.rawTxInsert(txID, std::move(s), nullptr);
|
||||
return true;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<Ledger>
|
||||
|
||||
Reference in New Issue
Block a user