From db873ff9f52961526f07e4f78ca1743a4b624ba2 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 24 Aug 2012 09:32:58 -0700 Subject: [PATCH] Functions for owned nodes (nodes that have a single other node that owns them) and dual-owner nodes (nodes that have two other nodes that own them). Owned nodes would be things like nicknames. Dual-owner nodes would be things like ripple balances. --- src/SerializedLedger.cpp | 25 +++++++++++++++++++++++++ src/SerializedLedger.h | 5 +++++ 2 files changed, 30 insertions(+) diff --git a/src/SerializedLedger.cpp b/src/SerializedLedger.cpp index e79b19c1b7..5796952368 100644 --- a/src/SerializedLedger.cpp +++ b/src/SerializedLedger.cpp @@ -109,6 +109,31 @@ bool SerializedLedgerEntry::thread(const uint256& txID, uint32 ledgerSeq, uint25 return true; } +bool SerializedLedgerEntry::hasOneOwner() +{ + return (mType != ltACCOUNT_ROOT) && (getIFieldIndex(sfAccount) != -1); +} + +bool SerializedLedgerEntry::hasTwoOwners() +{ + return mType == ltRIPPLE_STATE; +} + +NewcoinAddress SerializedLedgerEntry::getOwner() +{ + return getIValueFieldAccount(sfAccount); +} + +NewcoinAddress SerializedLedgerEntry::getFirstOwner() +{ + return getIValueFieldAccount(sfLowID); +} + +NewcoinAddress SerializedLedgerEntry::getSecondOwner() +{ + return getIValueFieldAccount(sfHighID); +} + std::vector SerializedLedgerEntry::getOwners() { std::vector owners; diff --git a/src/SerializedLedger.h b/src/SerializedLedger.h index 5f66a765dc..21faba8c35 100644 --- a/src/SerializedLedger.h +++ b/src/SerializedLedger.h @@ -65,6 +65,11 @@ public: bool isThreadedType(); // is this a ledger entry that can be threaded bool isThreaded(); // is this ledger entry actually threaded + bool hasOneOwner(); // This node has one other node that owns it (like nickname) + bool hasTwoOwners(); // This node has two nodes that own it (like ripple balance) + NewcoinAddress getOwner(); + NewcoinAddress getFirstOwner(); + NewcoinAddress getSecondOwner(); uint256 getThreadedTransaction(); uint32 getThreadedLedger(); bool thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID);