Metadata rework to make it possible to watch things like order books or

directories.

1) Some fields are never put in metadata, like Indexes, PreviousTxnID, and
others that are useless/redundant

2) Directory nodes now contain a RootIndex field so you can tell which
directory they're part of.

3) Some fields are always put in metdata, even if they don't change, like
RootIndex. So if a directory entry node is touched, you can tell what
directory it was part of.

Note that this change will cause ledger divergence. Also, existing directory
nodes will not be fully metadata indexed but newly-created nodes will be.
This commit is contained in:
JoelKatz
2012-11-18 17:13:19 -08:00
parent b9bdcceecf
commit 366b477052
5 changed files with 64 additions and 33 deletions

View File

@@ -40,6 +40,14 @@ public:
typedef const SField& ref;
typedef SField const * ptr;
static const int sMD_Never = 0x00;
static const int sMD_ChangeOrig = 0x01; // original value when it changes
static const int sMD_ChangeNew = 0x02; // new value when it changes
static const int sMD_DeleteFinal = 0x04; // final value when it is deleted
static const int sMD_Create = 0x08; // value when it's created
static const int sMD_Always = 0x10; // value when node containing it is affected at all
static const int sMD_Default = sMD_ChangeOrig | sMD_ChangeNew | sMD_DeleteFinal;
protected:
static std::map<int, ptr> codeToField;
static boost::mutex mapMutex;
@@ -52,23 +60,25 @@ public:
const SerializedTypeID fieldType; // STI_*
const int fieldValue; // Code number for protocol
std::string fieldName;
int fieldMeta;
bool signingField;
SField(int fc, SerializedTypeID tid, int fv, const char* fn) :
fieldCode(fc), fieldType(tid), fieldValue(fv), fieldName(fn), signingField(true)
fieldCode(fc), fieldType(tid), fieldValue(fv), fieldName(fn), fieldMeta(sMD_Default), signingField(true)
{
boost::mutex::scoped_lock sl(mapMutex);
codeToField[fieldCode] = this;
}
SField(SerializedTypeID tid, int fv, const char *fn) :
fieldCode(FIELD_CODE(tid, fv)), fieldType(tid), fieldValue(fv), fieldName(fn), signingField(true)
fieldCode(FIELD_CODE(tid, fv)), fieldType(tid), fieldValue(fv), fieldName(fn),
fieldMeta(sMD_Default), signingField(true)
{
boost::mutex::scoped_lock sl(mapMutex);
codeToField[fieldCode] = this;
}
SField(int fc) : fieldCode(fc), fieldType(STI_UNKNOWN), fieldValue(0) { ; }
SField(int fc) : fieldCode(fc), fieldType(STI_UNKNOWN), fieldValue(0), fieldMeta(sMD_Never) { ; }
~SField();
@@ -86,8 +96,10 @@ public:
bool isBinary() const { return fieldValue < 256; }
bool isDiscardable() const { return fieldValue > 256; }
bool isSigningField() const { return signingField; }
void notSigningField() { signingField = false; }
bool isSigningField() const { return signingField; }
void notSigningField() { signingField = false; }
bool shouldMeta(int c) const { return (fieldMeta & c) != 0; }
void setMeta(int c) { fieldMeta = c; }
bool shouldInclude(bool withSigningField) const
{ return (fieldValue < 256) && (withSigningField || signingField); }