mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Threading support for node deletion.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "Ledger.h"
|
||||
|
||||
SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint256& index)
|
||||
: SerializedType("LedgerEntry"), mIndex(index)
|
||||
{
|
||||
@@ -103,4 +105,30 @@ void SerializedLedgerEntry::thread(const uint256& txID, uint32 ledgerSeq, uint25
|
||||
setIFieldU32(sfLastTxnSeq, ledgerSeq);
|
||||
}
|
||||
|
||||
std::vector<uint256> SerializedLedgerEntry::getOwners()
|
||||
{
|
||||
std::vector<uint256> owners;
|
||||
uint160 account;
|
||||
|
||||
for (int i = 0, fields = getIFieldCount(); i < fields; ++i)
|
||||
{
|
||||
switch (getIFieldSType(i))
|
||||
{
|
||||
case sfAccount:
|
||||
case sfLowID:
|
||||
case sfHighID:
|
||||
{
|
||||
const STAccount* entry = dynamic_cast<const STAccount *>(mObject.peekAtPIndex(i));
|
||||
if ((entry != NULL) && entry->getValueH160(account))
|
||||
owners.push_back(Ledger::getAccountRootIndex(account));
|
||||
}
|
||||
|
||||
default:
|
||||
nothing();
|
||||
}
|
||||
}
|
||||
|
||||
return owners;
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
int getIFieldCount() const { return mObject.getCount(); }
|
||||
const SerializedType& peekIField(SOE_Field field) const { return mObject.peekAtField(field); }
|
||||
SerializedType& getIField(SOE_Field field) { return mObject.getField(field); }
|
||||
SOE_Field getIFieldSType(int index) { return mObject.getFieldSType(index); }
|
||||
|
||||
std::string getIFieldString(SOE_Field field) const { return mObject.getFieldString(field); }
|
||||
unsigned char getIFieldU8(SOE_Field field) const { return mObject.getValueFieldU8(field); }
|
||||
@@ -67,6 +68,7 @@ public:
|
||||
uint256 getThreadedTransaction();
|
||||
uint32 getThreadedLedger();
|
||||
void thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID);
|
||||
std::vector<uint256> getOwners(); // nodes notified if this node is deleted
|
||||
|
||||
void setIFieldU8(SOE_Field field, unsigned char v) { return mObject.setValueFieldU8(field, v); }
|
||||
void setIFieldU16(SOE_Field field, uint16 v) { return mObject.setValueFieldU16(field, v); }
|
||||
|
||||
@@ -257,35 +257,45 @@ int STObject::getFieldIndex(SOE_Field field) const
|
||||
const SerializedType& STObject::peekAtField(SOE_Field field) const
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1) throw std::runtime_error("Field not found");
|
||||
if (index == -1)
|
||||
throw std::runtime_error("Field not found");
|
||||
return peekAtIndex(index);
|
||||
}
|
||||
|
||||
SerializedType& STObject::getField(SOE_Field field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index==-1) throw std::runtime_error("Field not found");
|
||||
if (index == -1)
|
||||
throw std::runtime_error("Field not found");
|
||||
return getIndex(index);
|
||||
}
|
||||
|
||||
SOE_Field STObject::getFieldSType(int index) const
|
||||
{
|
||||
return mType[index]->e_field;
|
||||
}
|
||||
|
||||
const SerializedType* STObject::peekAtPField(SOE_Field field) const
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1) return NULL;
|
||||
if (index == -1)
|
||||
return NULL;
|
||||
return peekAtPIndex(index);
|
||||
}
|
||||
|
||||
SerializedType* STObject::getPField(SOE_Field field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1) return NULL;
|
||||
if (index == -1)
|
||||
return NULL;
|
||||
return getPIndex(index);
|
||||
}
|
||||
|
||||
bool STObject::isFieldPresent(SOE_Field field) const
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1) return false;
|
||||
if (index == -1)
|
||||
return false;
|
||||
return peekAtIndex(index).getSType() != STI_NOTPRESENT;
|
||||
}
|
||||
|
||||
@@ -318,7 +328,8 @@ uint32 STObject::getFlags(void) const
|
||||
SerializedType* STObject::makeFieldPresent(SOE_Field field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1) throw std::runtime_error("Field not found");
|
||||
if (index == -1)
|
||||
throw std::runtime_error("Field not found");
|
||||
if ((mType[index]->e_type != SOE_IFFLAG) && (mType[index]->e_type != SOE_IFNFLAG))
|
||||
throw std::runtime_error("field is not optional");
|
||||
|
||||
@@ -338,7 +349,8 @@ SerializedType* STObject::makeFieldPresent(SOE_Field field)
|
||||
void STObject::makeFieldAbsent(SOE_Field field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1) throw std::runtime_error("Field not found");
|
||||
if (index == -1)
|
||||
throw std::runtime_error("Field not found");
|
||||
if ((mType[index]->e_type != SOE_IFFLAG) && (mType[index]->e_type != SOE_IFNFLAG))
|
||||
throw std::runtime_error("field is not optional");
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ enum SOE_Field
|
||||
sfAcceptRate,
|
||||
sfAcceptStart,
|
||||
sfAccount,
|
||||
sfAccountID,
|
||||
sfAmount,
|
||||
sfAuthorizedKey,
|
||||
sfBalance,
|
||||
@@ -162,6 +161,7 @@ public:
|
||||
SerializedType* getPIndex(int offset) { return &(mData[offset]); }
|
||||
|
||||
int getFieldIndex(SOE_Field field) const;
|
||||
SOE_Field getFieldSType(int index) const;
|
||||
|
||||
const SerializedType& peekAtField(SOE_Field field) const;
|
||||
SerializedType& getField(SOE_Field field);
|
||||
|
||||
Reference in New Issue
Block a user