20 #include <ripple/app/consensus/RCLValidations.h>
21 #include <ripple/app/ledger/InboundLedger.h>
22 #include <ripple/app/ledger/InboundLedgers.h>
23 #include <ripple/app/ledger/LedgerMaster.h>
24 #include <ripple/app/main/Application.h>
25 #include <ripple/app/misc/NetworkOPs.h>
26 #include <ripple/app/misc/ValidatorList.h>
27 #include <ripple/basics/Log.h>
28 #include <ripple/basics/StringUtilities.h>
29 #include <ripple/basics/chrono.h>
30 #include <ripple/consensus/LedgerTiming.h>
31 #include <ripple/core/DatabaseCon.h>
32 #include <ripple/core/JobQueue.h>
33 #include <ripple/core/TimeKeeper.h>
48 : ledgerID_{ledger->info().hash}, ledgerSeq_{ledger->
seq()}, j_{j}
54 ancestors_ = hashIndex->getFieldV256(
sfHashes).value();
57 JLOG(j_.
warn()) <<
"Ledger " << ledgerSeq_ <<
":" << ledgerID_
58 <<
" missing recent ancestor hashes";
80 if (s >= minSeq() && s <= seq())
85 return ancestors_[ancestors_.size() -
diff];
88 JLOG(j_.
warn()) <<
"Unable to determine hash of ancestor seq=" << s
89 <<
" from ledger hash=" << ledgerID_
90 <<
" seq=" << ledgerSeq_;
106 while (curr != Seq{0} && a[curr] != b[curr] && curr >= lower)
111 return (curr < lower) ? Seq{1} : (curr + Seq{1});
125 boost::optional<RCLValidatedLedger>
132 <<
"Need validated ledger for preferred ledger analysis " << hash;
144 assert(!ledger->open() && ledger->isImmutable());
145 assert(ledger->info().hash == hash);
155 PublicKey const& signingKey = val->getSignerPublic();
156 uint256 const& hash = val->getLedgerHash();
159 boost::optional<PublicKey> masterKey =
161 if (!val->isTrusted() && masterKey)
168 bool shouldRelay =
false;
173 s <<
"Val for " << hash
174 << (val->isTrusted() ?
" trusted/" :
" UNtrusted/")
175 << (val->isFull() ?
"full" :
"partial") <<
" from "
180 <<
" src=" << source;
186 dmp(j.
error(),
"missing ledger sequence field");
213 JLOG(j.
debug()) <<
"Val for " << hash <<
" from "
215 <<
" not added UNlisted";
boost::optional< PublicKey > getListedKey(PublicKey const &identity) const
Returns listed master public if public key is included on any lists.
RCLValidatedLedger::Seq mismatch(RCLValidatedLedger const &a, RCLValidatedLedger const &b)
NodeID calcNodeID(PublicKey const &pk)
Calculate the 160-bit node ID from a node public key.
std::vector< uint256 > ancestors_
boost::optional< RCLValidatedLedger > acquire(LedgerHash const &id)
Attempt to acquire the ledger with given id from the network.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
ValStatus
Status of newly received validation.
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
NetClock::time_point now() const
Current time used to determine if validations are stale.
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
beast::Journal journal() const
ID id() const
The ID (hash) of the ledger.
std::string to_string(ListDisposition disposition)
virtual TimeKeeper & timeKeeper()=0
RCLValidationsAdaptor(Application &app, beast::Journal j)
static Sink & getNullSink()
Returns a Sink which does nothing.
Wraps a ledger instance for use in generic Validations LedgerTrie.
bool handleNewValidation(Application &app, STValidation::ref val, std::string const &source)
Handle a new validation.
virtual InboundLedgers & getInboundLedgers()=0
@ badSeq
A validation violates the increasing seq requirement.
Seq seq() const
The sequence (index) of the ledger.
boost::optional< PublicKey > getTrustedKey(PublicKey const &identity) const
Returns master public key if public key is trusted.
RCLValidatedLedger(MakeGenesis)
const SF_U32 sfLastLedgerSequence(access, STI_UINT32, 27, "LastLedgerSequence")
ValStatus add(NodeID const &nodeID, Validation const &val)
Add a new validation.
virtual LedgerMaster & getLedgerMaster()=0
virtual JobQueue & getJobQueue()=0
Provide a light-weight way to check active() before string formatting.
const SF_U32 sfLedgerSequence(access, STI_UINT32, 6, "LedgerSequence")
ID operator[](Seq const &s) const
Lookup the ID of the ancestor ledger.
virtual time_point closeTime() const =0
Returns the close time, in network time.
@ current
This was a new validation and was added.
A generic endpoint for log messages.
virtual RCLValidations & getValidations()=0
void checkAccept(std::shared_ptr< Ledger const > const &ledger)
virtual ValidatorList & validators()=0
const SF_Vec256 sfHashes(access, STI_VECTOR256, 2, "Hashes")
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
LedgerIndex seq() const
Returns the sequence number of the base ledger.
Adaptor const & adaptor() const
Return the adaptor instance.