From 7708968cff5596910f42f76aa8f2abe0bda2024f Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 2 Dec 2012 15:23:17 -0800 Subject: [PATCH] Stuctures for feature enabling. --- src/cpp/ripple/Ledger.cpp | 7 +++++++ src/cpp/ripple/Ledger.h | 2 ++ src/cpp/ripple/LedgerFormats.cpp | 4 ++++ src/cpp/ripple/LedgerFormats.h | 2 ++ src/cpp/ripple/SerializeProto.h | 2 ++ src/cpp/ripple/TransactionFormats.cpp | 4 ++++ src/cpp/ripple/TransactionFormats.h | 2 ++ 7 files changed, 23 insertions(+) diff --git a/src/cpp/ripple/Ledger.cpp b/src/cpp/ripple/Ledger.cpp index a498fee1c..8e3c47c6b 100644 --- a/src/cpp/ripple/Ledger.cpp +++ b/src/cpp/ripple/Ledger.cpp @@ -918,6 +918,13 @@ uint256 Ledger::getAccountRootIndex(const uint160& uAccountID) return s.getSHA512Half(); } +uint256 Ledger::getLedgerFeatureIndex() +{ // get the index of the node that holds the last 256 ledgers + Serializer s(2); + s.add16(spaceFeature); + return s.getSHA512Half(); +} + uint256 Ledger::getLedgerHashIndex() { // get the index of the node that holds the last 256 ledgers Serializer s(2); diff --git a/src/cpp/ripple/Ledger.h b/src/cpp/ripple/Ledger.h index 23292254b..a9b560571 100644 --- a/src/cpp/ripple/Ledger.h +++ b/src/cpp/ripple/Ledger.h @@ -193,6 +193,8 @@ public: static int getLedgerHashOffset(uint32 desiredLedgerIndex); static int getLedgerHashOffset(uint32 desiredLedgerIndex, uint32 currentLedgerIndex); + static uint256 getLedgerFeatureIndex(); + // index calculation functions static uint256 getAccountRootIndex(const uint160& uAccountID); diff --git a/src/cpp/ripple/LedgerFormats.cpp b/src/cpp/ripple/LedgerFormats.cpp index 98c70857a..e727afc58 100644 --- a/src/cpp/ripple/LedgerFormats.cpp +++ b/src/cpp/ripple/LedgerFormats.cpp @@ -98,6 +98,10 @@ static bool LEFInit() << SOElement(sfHashes, SOE_REQUIRED) ; + DECLARE_LEF(EnabledFeatures, ltFEATURES) + << SOElement(sfEnabledFeatures, SOE_REQUIRED) + ; + return true; } diff --git a/src/cpp/ripple/LedgerFormats.h b/src/cpp/ripple/LedgerFormats.h index 2c3f3cd5a..5f16c63f4 100644 --- a/src/cpp/ripple/LedgerFormats.h +++ b/src/cpp/ripple/LedgerFormats.h @@ -15,6 +15,7 @@ enum LedgerEntryType ltOFFER = 'o', ltCONTRACT = 'c', ltLEDGER_HASHES = 'h', + ltFEATURES = 'f', }; // Used as a prefix for computing ledger indexes (keys). @@ -30,6 +31,7 @@ enum LedgerNameSpace spaceBookDir = 'B', // Directory of order books. spaceContract = 'c', spaceSkipList = 's', + spaceFeature = 'f', }; enum LedgerSpecificFlags diff --git a/src/cpp/ripple/SerializeProto.h b/src/cpp/ripple/SerializeProto.h index a10ab314b..dc736adfc 100644 --- a/src/cpp/ripple/SerializeProto.h +++ b/src/cpp/ripple/SerializeProto.h @@ -84,6 +84,7 @@ FIELD(BookDirectory, HASH256, 16) FIELD(InvoiceID, HASH256, 17) FIELD(Nickname, HASH256, 18) + FIELD(Feature, HASH256, 19) // 160-bit (common) FIELD(TakerPaysCurrency, HASH160, 1) @@ -154,5 +155,6 @@ FIELD(Necessary, ARRAY, 6) FIELD(Sufficient, ARRAY, 7) FIELD(AffectedNodes, ARRAY, 8) + FIELD(EnabledFeatures, ARRAY, 9) // vim:ts=4 diff --git a/src/cpp/ripple/TransactionFormats.cpp b/src/cpp/ripple/TransactionFormats.cpp index f54cb1868..5f0feb40e 100644 --- a/src/cpp/ripple/TransactionFormats.cpp +++ b/src/cpp/ripple/TransactionFormats.cpp @@ -71,6 +71,10 @@ static bool TFInit() << SOElement(sfTarget, SOE_REQUIRED) ; + DECLARE_TF(EnableFeature, ttFEATURE) + << SOElement(sfFeature, SOE_REQUIRED) + ; + return true; } diff --git a/src/cpp/ripple/TransactionFormats.h b/src/cpp/ripple/TransactionFormats.h index 091978ba1..6f399c591 100644 --- a/src/cpp/ripple/TransactionFormats.h +++ b/src/cpp/ripple/TransactionFormats.h @@ -19,6 +19,8 @@ enum TransactionType ttCONTRACT_REMOVE = 10, // can we use the same msg as offer cancel ttTRUST_SET = 20, + + ttFEATURE = 100, }; class TransactionFormat