mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Inject Application (cont.)
This commit is contained in:
committed by
Edward Hennis
parent
eed1a891a7
commit
ffbcb96eff
@@ -156,14 +156,15 @@ ManifestCache::configValidatorKey(
|
||||
}
|
||||
|
||||
void
|
||||
ManifestCache::configManifest(Manifest m, beast::Journal const& journal)
|
||||
ManifestCache::configManifest (
|
||||
Manifest m, UniqueNodeList& unl, beast::Journal const& journal)
|
||||
{
|
||||
if (!m.verify())
|
||||
{
|
||||
throw std::runtime_error("Unverifiable manifest in config");
|
||||
}
|
||||
|
||||
auto const result = applyManifest (std::move(m), journal);
|
||||
auto const result = applyManifest (std::move(m), unl, journal);
|
||||
|
||||
if (result != ManifestDisposition::accepted)
|
||||
{
|
||||
@@ -225,7 +226,8 @@ ManifestCache::canApply (PublicKey const& pk, std::uint32_t seq,
|
||||
|
||||
|
||||
ManifestDisposition
|
||||
ManifestCache::applyManifest (Manifest m, beast::Journal const& journal)
|
||||
ManifestCache::applyManifest (
|
||||
Manifest m, UniqueNodeList& unl, beast::Journal const& journal)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock (mutex_);
|
||||
@@ -253,8 +255,6 @@ ManifestCache::applyManifest (Manifest m, beast::Journal const& journal)
|
||||
return ManifestDisposition::invalid;
|
||||
}
|
||||
|
||||
auto& unl = getApp().getUNL();
|
||||
|
||||
std::lock_guard<std::mutex> lock (mutex_);
|
||||
|
||||
/*
|
||||
@@ -334,7 +334,7 @@ ManifestCache::applyManifest (Manifest m, beast::Journal const& journal)
|
||||
}
|
||||
|
||||
void ManifestCache::load (
|
||||
DatabaseCon& dbCon, beast::Journal const& journal)
|
||||
DatabaseCon& dbCon, UniqueNodeList& unl, beast::Journal const& journal)
|
||||
{
|
||||
static const char* const sql =
|
||||
"SELECT RawData FROM ValidatorManifests;";
|
||||
@@ -358,7 +358,7 @@ void ManifestCache::load (
|
||||
map_[mo->masterKey];
|
||||
|
||||
// OK if not accepted (may have been loaded from the config file)
|
||||
applyManifest (std::move(*mo), journal);
|
||||
applyManifest (std::move(*mo), unl, journal);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#ifndef RIPPLE_OVERLAY_MANIFEST_H_INCLUDED
|
||||
#define RIPPLE_OVERLAY_MANIFEST_H_INCLUDED
|
||||
|
||||
#include <ripple/app/misc/UniqueNodeList.h>
|
||||
#include <ripple/basics/BasicConfig.h>
|
||||
#include <ripple/basics/UnorderedContainers.h>
|
||||
#include <ripple/protocol/PublicKey.h>
|
||||
@@ -193,14 +194,16 @@ public:
|
||||
~ManifestCache() = default;
|
||||
|
||||
void configValidatorKey(std::string const& line, beast::Journal const& journal);
|
||||
void configManifest(Manifest m, beast::Journal const& journal);
|
||||
void configManifest (Manifest m, UniqueNodeList& unl, beast::Journal const& journal);
|
||||
|
||||
void addTrustedKey (PublicKey const& pk, std::string comment);
|
||||
|
||||
ManifestDisposition
|
||||
applyManifest (Manifest m, beast::Journal const& journal);
|
||||
applyManifest (
|
||||
Manifest m, UniqueNodeList& unl, beast::Journal const& journal);
|
||||
|
||||
void load (DatabaseCon& dbCon, beast::Journal const& journal);
|
||||
void load (
|
||||
DatabaseCon& dbCon, UniqueNodeList& unl, beast::Journal const& journal);
|
||||
void save (DatabaseCon& dbCon) const;
|
||||
|
||||
// A "for_each" for populated manifests only
|
||||
|
||||
@@ -459,7 +459,7 @@ OverlayImpl::setupValidatorKeyManifests (BasicConfig const& config,
|
||||
s = beast::base64_decode(s);
|
||||
if (auto mo = make_Manifest (std::move (s)))
|
||||
{
|
||||
manifestCache_.configManifest (std::move (*mo), journal_);
|
||||
manifestCache_.configManifest (std::move (*mo), app_.getUNL (), journal_);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -472,7 +472,7 @@ OverlayImpl::setupValidatorKeyManifests (BasicConfig const& config,
|
||||
journal_.warning << "No [validation_manifest] section in config";
|
||||
}
|
||||
|
||||
manifestCache_.load (db, journal_);
|
||||
manifestCache_.load (db, app_.getUNL(), journal_);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -657,7 +657,7 @@ OverlayImpl::onManifests (
|
||||
|
||||
auto const serialized = mo->serialized;
|
||||
auto const result =
|
||||
manifestCache_.applyManifest (std::move(*mo), journal);
|
||||
manifestCache_.applyManifest (std::move(*mo), app_.getUNL(), journal);
|
||||
|
||||
if (result == ManifestDisposition::accepted)
|
||||
{
|
||||
|
||||
@@ -1737,7 +1737,7 @@ PeerImp::checkTransaction (int flags, STTx::pointer stx)
|
||||
std::string reason;
|
||||
auto tx = std::make_shared<Transaction> (stx, validate,
|
||||
directSigVerify,
|
||||
reason);
|
||||
reason, app_);
|
||||
|
||||
if (tx->getStatus () == INVALID)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <ripple/protocol/SecretKey.h>
|
||||
#include <ripple/protocol/Sign.h>
|
||||
#include <ripple/protocol/STExchange.h>
|
||||
#include <ripple/test/jtx.h>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
@@ -121,7 +122,7 @@ public:
|
||||
return Manifest (m.serialized, m.masterKey, m.signingKey, m.sequence);
|
||||
}
|
||||
|
||||
void testLoadStore (ManifestCache const& m)
|
||||
void testLoadStore (ManifestCache const& m, UniqueNodeList& unl)
|
||||
{
|
||||
testcase ("load/store");
|
||||
|
||||
@@ -137,7 +138,7 @@ public:
|
||||
|
||||
ManifestCache loaded;
|
||||
beast::Journal journal;
|
||||
loaded.load (dbCon, journal);
|
||||
loaded.load (dbCon, unl, journal);
|
||||
|
||||
auto getPopulatedManifests =
|
||||
[](ManifestCache const& cache) -> std::vector<Manifest const*>
|
||||
@@ -183,6 +184,8 @@ public:
|
||||
run() override
|
||||
{
|
||||
ManifestCache cache;
|
||||
test::jtx::Env env(*this);
|
||||
auto& unl = env.app().getUNL();
|
||||
{
|
||||
testcase ("apply");
|
||||
auto const accepted = ManifestDisposition::accepted;
|
||||
@@ -207,26 +210,26 @@ public:
|
||||
make_Manifest (KeyType::ed25519, sk_b, kp_b.first, 2, true); // broken
|
||||
auto const fake = s_b1.serialized + '\0';
|
||||
|
||||
expect (cache.applyManifest (clone (s_a0), journal) == untrusted,
|
||||
expect (cache.applyManifest (clone (s_a0), unl, journal) == untrusted,
|
||||
"have to install a trusted key first");
|
||||
|
||||
cache.addTrustedKey (pk_a, "a");
|
||||
cache.addTrustedKey (pk_b, "b");
|
||||
|
||||
expect (cache.applyManifest (clone (s_a0), journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_a0), journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_a0), unl, journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_a0), unl, journal) == stale);
|
||||
|
||||
expect (cache.applyManifest (clone (s_a1), journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_a1), journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_a0), journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_a1), unl, journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_a1), unl, journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_a0), unl, journal) == stale);
|
||||
|
||||
expect (cache.applyManifest (clone (s_b0), journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_b0), journal) == stale);
|
||||
expect (cache.applyManifest (clone (s_b0), unl, journal) == accepted);
|
||||
expect (cache.applyManifest (clone (s_b0), unl, journal) == stale);
|
||||
|
||||
expect (!ripple::make_Manifest(fake));
|
||||
expect (cache.applyManifest (clone (s_b2), journal) == invalid);
|
||||
expect (cache.applyManifest (clone (s_b2), unl, journal) == invalid);
|
||||
}
|
||||
testLoadStore (cache);
|
||||
testLoadStore (cache, unl);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user