remove unused offers code

This commit is contained in:
CJ Cobb
2021-08-06 12:32:06 -04:00
parent 56e81eb1d8
commit ea5f9162b7
11 changed files with 16 additions and 83 deletions

Submodule rippled updated: 63547c0b63...0ec275bc48

View File

@@ -39,20 +39,15 @@ void
BackendInterface::writeLedgerObject( BackendInterface::writeLedgerObject(
std::string&& key, std::string&& key,
uint32_t seq, uint32_t seq,
std::string&& blob, std::string&& blob) const
bool isCreated,
bool isDeleted,
std::optional<ripple::uint256>&& book) const
{ {
assert(key.size() == sizeof(rippled::uint256));
ripple::uint256 key256 = ripple::uint256::fromVoid(key.data()); ripple::uint256 key256 = ripple::uint256::fromVoid(key.data());
indexer_.addKey(std::move(key256)); indexer_.addKey(std::move(key256));
doWriteLedgerObject( doWriteLedgerObject(
std::move(key), std::move(key),
seq, seq,
std::move(blob), std::move(blob));
isCreated,
isDeleted,
std::move(book));
} }
std::optional<LedgerRange> std::optional<LedgerRange>
BackendInterface::hardFetchLedgerRangeNoThrow() const BackendInterface::hardFetchLedgerRangeNoThrow() const

View File

@@ -204,10 +204,7 @@ protected:
writeLedgerObject( writeLedgerObject(
std::string&& key, std::string&& key,
uint32_t seq, uint32_t seq,
std::string&& blob, std::string&& blob) const;
bool isCreated,
bool isDeleted,
std::optional<ripple::uint256>&& book) const;
virtual void virtual void
writeTransaction( writeTransaction(
@@ -263,10 +260,7 @@ private:
doWriteLedgerObject( doWriteLedgerObject(
std::string&& key, std::string&& key,
uint32_t seq, uint32_t seq,
std::string&& blob, std::string&& blob) const = 0;
bool isCreated,
bool isDeleted,
std::optional<ripple::uint256>&& book) const = 0;
virtual bool virtual bool
doFinishWrites() const = 0; doFinishWrites() const = 0;

View File

@@ -148,10 +148,7 @@ void
CassandraBackend::doWriteLedgerObject( CassandraBackend::doWriteLedgerObject(
std::string&& key, std::string&& key,
uint32_t seq, uint32_t seq,
std::string&& blob, std::string&& blob) const
bool isCreated,
bool isDeleted,
std::optional<ripple::uint256>&& book) const
{ {
BOOST_LOG_TRIVIAL(trace) << "Writing ledger object to cassandra"; BOOST_LOG_TRIVIAL(trace) << "Writing ledger object to cassandra";
makeAndExecuteAsyncWrite( makeAndExecuteAsyncWrite(

View File

@@ -833,10 +833,7 @@ public:
doWriteLedgerObject( doWriteLedgerObject(
std::string&& key, std::string&& key,
uint32_t seq, uint32_t seq,
std::string&& blob, std::string&& blob) const override;
bool isCreated,
bool isDeleted,
std::optional<ripple::uint256>&& book) const override;
void void
writeAccountTransactions( writeAccountTransactions(

View File

@@ -60,10 +60,7 @@ void
PostgresBackend::doWriteLedgerObject( PostgresBackend::doWriteLedgerObject(
std::string&& key, std::string&& key,
uint32_t seq, uint32_t seq,
std::string&& blob, std::string&& blob) const
bool isCreated,
bool isDeleted,
std::optional<ripple::uint256>&& book) const
{ {
if (abortWrite_) if (abortWrite_)
return; return;

View File

@@ -79,10 +79,7 @@ public:
doWriteLedgerObject( doWriteLedgerObject(
std::string&& key, std::string&& key,
uint32_t seq, uint32_t seq,
std::string&& blob, std::string&& blob) const override;
bool isCreated,
bool isDeleted,
std::optional<ripple::uint256>&& book) const override;
void void
writeTransaction( writeTransaction(

View File

@@ -435,22 +435,10 @@ public:
BOOST_LOG_TRIVIAL(trace) << "Writing objects"; BOOST_LOG_TRIVIAL(trace) << "Writing objects";
for (auto& obj : *(cur_->mutable_ledger_objects()->mutable_objects())) for (auto& obj : *(cur_->mutable_ledger_objects()->mutable_objects()))
{ {
std::optional<ripple::uint256> book = {};
short offer_bytes = (obj.data()[1] << 8) | obj.data()[2];
if (offer_bytes == 0x006f)
{
ripple::SerialIter it{obj.data().data(), obj.data().size()};
ripple::SLE sle{it, {}};
book = sle.getFieldH256(ripple::sfBookDirectory);
}
backend.writeLedgerObject( backend.writeLedgerObject(
std::move(*obj.mutable_key()), std::move(*obj.mutable_key()),
request_.ledger().sequence(), request_.ledger().sequence(),
std::move(*obj.mutable_data()), std::move(*obj.mutable_data()));
true,
false,
std::move(book));
} }
BOOST_LOG_TRIVIAL(trace) << "Wrote objects"; BOOST_LOG_TRIVIAL(trace) << "Wrote objects";

View File

@@ -294,34 +294,11 @@ ReportingETL::buildNextLedger(org::xrpl::rpc::v1::GetLedgerResponse& rawData)
for (auto& obj : *(rawData.mutable_ledger_objects()->mutable_objects())) for (auto& obj : *(rawData.mutable_ledger_objects()->mutable_objects()))
{ {
bool isCreated = false;
bool isDeleted = false;
if (obj.mod_type() == org::xrpl::rpc::v1::RawLedgerObject::CREATED)
isCreated = true;
else if (
obj.mod_type() == org ::xrpl::rpc::v1::RawLedgerObject::DELETED)
isDeleted = true;
std::optional<ripple::uint256> bookDir;
if (isCreated)
{
if (isOffer(obj.data()))
bookDir = getBook(obj.data());
}
else if (obj.book_of_deleted_offer().size())
{
bookDir =
ripple::uint256::fromVoid(obj.book_of_deleted_offer().data());
}
assert(not(isCreated and isDeleted));
backend_->writeLedgerObject( backend_->writeLedgerObject(
std::move(*obj.mutable_key()), std::move(*obj.mutable_key()),
lgrInfo.seq, lgrInfo.seq,
std::move(*obj.mutable_data()), std::move(*obj.mutable_data()));
isCreated,
isDeleted,
std::move(bookDir));
} }
BOOST_LOG_TRIVIAL(debug) BOOST_LOG_TRIVIAL(debug)
<< __func__ << " : " << __func__ << " : "

View File

@@ -97,7 +97,7 @@ doLedger(Context const& context)
entry["tx_blob"] = ripple::strHex(obj.transaction); entry["tx_blob"] = ripple::strHex(obj.transaction);
entry["meta"] = ripple::strHex(obj.metadata); entry["meta"] = ripple::strHex(obj.metadata);
} }
entry["ledger_index"] = obj.ledgerSequence; //entry["ledger_index"] = obj.ledgerSequence;
return entry; return entry;
}); });
} }

View File

@@ -253,10 +253,7 @@ TEST(BackendTest, Basic)
backend->writeLedgerObject( backend->writeLedgerObject(
std::move(std::string{accountIndexBlob}), std::move(std::string{accountIndexBlob}),
lgrInfoNext.seq, lgrInfoNext.seq,
std::move(std::string{accountBlob}), std::move(std::string{accountBlob}));
true,
false,
{});
ASSERT_TRUE(backend->finishWrites(lgrInfoNext.seq)); ASSERT_TRUE(backend->finishWrites(lgrInfoNext.seq));
} }
@@ -324,10 +321,7 @@ TEST(BackendTest, Basic)
backend->writeLedgerObject( backend->writeLedgerObject(
std::move(std::string{accountIndexBlob}), std::move(std::string{accountIndexBlob}),
lgrInfoNext.seq, lgrInfoNext.seq,
std::move(std::string{accountBlob}), std::move(std::string{accountBlob}));
true,
false,
{});
ASSERT_TRUE(backend->finishWrites(lgrInfoNext.seq)); ASSERT_TRUE(backend->finishWrites(lgrInfoNext.seq));
} }
@@ -474,10 +468,7 @@ TEST(BackendTest, Basic)
backend->writeLedgerObject( backend->writeLedgerObject(
std::move(key), std::move(key),
lgrInfo.seq, lgrInfo.seq,
std::move(obj), std::move(obj));
true,
false,
std::move(bookDir));
} }
backend->writeAccountTransactions(std::move(accountTx)); backend->writeAccountTransactions(std::move(accountTx));