// Build a ledger from consensus transactions std::shared_ptr<Ledger> buildLedger( std::shared_ptr<Ledger const> const& parent, NetClock::time_point closeTime, const bool closeTimeCorrect, NetClock::duration closeResolution, SHAMap const& txs, Application& app, CanonicalTXSet& retriableTxs, beast::Journal j) { JLOG(j.debug()) << "Report: TxSt = " << txs.getHash().as_uint256() << ", close " << closeTime.time_since_epoch().count() << (closeTimeCorrect ? "" : " (incorrect)"); return buildLedgerImpl( parent, closeTime, closeTimeCorrect, closeResolution, app, j, [&](OpenView& accum, std::shared_ptr<Ledger> const& buildLCL) { retriableTxs = applyTransactions(app, txs, accum, buildLCL, j); }); }
NetClock::time_point roundCloseTime ( NetClock::time_point closeTime, NetClock::duration closeResolution) { if (closeTime == NetClock::time_point{}) return closeTime; closeTime += (closeResolution / 2); return closeTime - (closeTime.time_since_epoch() % closeResolution); }
STValidation::STValidation( uint256 const& ledgerHash, std::uint32_t ledgerSeq, uint256 const& consensusHash, NetClock::time_point signTime, PublicKey const& publicKey, SecretKey const& secretKey, NodeID const& nodeID, bool isFull, FeeSettings const& fees, std::vector<uint256> const& amendments) : STObject(getFormat(), sfValidation), mNodeID(nodeID), mSeen(signTime) { // This is our own public key and it should always be valid. if (!publicKeyType(publicKey)) LogicError("Invalid validation public key"); assert(mNodeID.isNonZero()); setFieldH256(sfLedgerHash, ledgerHash); setFieldH256(sfConsensusHash, consensusHash); setFieldU32(sfSigningTime, signTime.time_since_epoch().count()); setFieldVL(sfSigningPubKey, publicKey.slice()); if (isFull) setFlag(kFullFlag); setFieldU32(sfLedgerSequence, ledgerSeq); if (fees.loadFee) setFieldU32(sfLoadFee, *fees.loadFee); if (fees.baseFee) setFieldU64(sfBaseFee, *fees.baseFee); if (fees.reserveBase) setFieldU32(sfReserveBase, *fees.reserveBase); if (fees.reserveIncrement) setFieldU32(sfReserveIncrement, *fees.reserveIncrement); if (!amendments.empty()) setFieldV256(sfAmendments, STVector256(sfAmendments, amendments)); setFlag(vfFullyCanonicalSig); auto const signingHash = getSigningHash(); setFieldVL( sfSignature, signDigest(getSignerPublic(), secretKey, signingHash)); setTrusted(); }
uint256 proposalUniqueId ( uint256 const& proposeHash, uint256 const& previousLedger, std::uint32_t proposeSeq, NetClock::time_point closeTime, Blob const& pubKey, Blob const& signature) { Serializer s (512); s.add256 (proposeHash); s.add256 (previousLedger); s.add32 (proposeSeq); s.add32 (closeTime.time_since_epoch().count()); s.addVL (pubKey); s.addVL (signature); return s.getSHA512Half (); }
STValidation::STValidation ( uint256 const& ledgerHash, NetClock::time_point signTime, PublicKey const& publicKey, bool isFull) : STObject (getFormat (), sfValidation) , mSeen (signTime) { // Does not sign setFieldH256 (sfLedgerHash, ledgerHash); setFieldU32 (sfSigningTime, signTime.time_since_epoch().count()); setFieldVL (sfSigningPubKey, publicKey.slice()); mNodeID = calcNodeID(publicKey); assert (mNodeID.isNonZero ()); if (isFull) setFlag (kFullFlag); }
std::string to_string(NetClock::time_point tp) { using namespace std::chrono; return to_string(system_clock::time_point{tp.time_since_epoch() + 946684800s}); }