From 2e595830b3b5c263e94460b7bfbff9c79a6cd391 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 27 Dec 2014 10:19:26 -0800 Subject: [PATCH] Levelize SHAMap: The SHAMap class is refactored into a separate module where each translation unit compiles separate without errors. Dependencies on higher level business logic are removed. SHAMap now depends only on basics, crypto, nodestore, and protocol: * Inject NodeStore::Database& to SHAMap * Move sync filter instances to app/ledger/ * Move shamap to its own module * Move FullBelowCache to shamap/ * Move private code to shamap/impl/ * Refactor SHAMap treatment of missing node handler * Inject and use Journal for logging in SHAMap --- Builds/VisualStudio2013/RippleD.vcxproj | 140 +++++++------- .../VisualStudio2013/RippleD.vcxproj.filters | 180 +++++++++--------- SConstruct | 3 + src/beast/beast/module/core/maths/Random.h | 6 +- src/ripple/app/consensus/LedgerConsensus.cpp | 9 +- src/ripple/app/ledger/AccountStateSF.cpp | 48 +++++ src/ripple/app/ledger/AccountStateSF.h | 51 +++++ .../ConsensusTransSetSF.cpp} | 52 +---- .../ConsensusTransSetSF.h} | 51 +---- src/ripple/app/ledger/InboundLedger.cpp | 4 +- src/ripple/app/ledger/Ledger.cpp | 43 +++-- src/ripple/app/ledger/Ledger.h | 2 +- src/ripple/app/ledger/TODO.md | 18 -- src/ripple/app/ledger/TransactionStateSF.cpp | 52 +++++ src/ripple/app/ledger/TransactionStateSF.h | 52 +++++ src/ripple/app/main/Application.h | 7 +- src/ripple/app/main/Tuning.h | 7 +- .../DefaultMissingNodeHandler.cpp} | 14 +- .../DefaultMissingNodeHandler.h} | 13 +- src/ripple/app/misc/NetworkOPs.h | 5 + src/ripple/app/tx/TransactionAcquire.cpp | 5 +- src/ripple/basics/CountedObject.h | 1 + .../FullBelowCache.h} | 20 +- src/ripple/{app => }/shamap/README.md | 2 +- src/ripple/{app => }/shamap/SHAMap.h | 51 ++--- src/ripple/{app => }/shamap/SHAMapAddNode.h | 0 src/ripple/{app => }/shamap/SHAMapItem.h | 4 +- .../{app => }/shamap/SHAMapMissingNode.h | 2 + src/ripple/{app => }/shamap/SHAMapNodeID.h | 8 +- .../{app => }/shamap/SHAMapSyncFilter.h | 2 +- src/ripple/{app => }/shamap/SHAMapTreeNode.h | 18 +- src/ripple/{app => }/shamap/TreeNodeCache.h | 0 .../{app/shamap => shamap/impl}/SHAMap.cpp | 96 +++++----- .../shamap => shamap/impl}/SHAMapDelta.cpp | 2 + .../shamap => shamap/impl}/SHAMapItem.cpp | 9 + .../impl}/SHAMapMissingNode.cpp | 6 +- .../shamap => shamap/impl}/SHAMapNodeID.cpp | 7 +- .../shamap => shamap/impl}/SHAMapSync.cpp | 63 +++--- .../shamap => shamap/impl}/SHAMapTreeNode.cpp | 10 +- .../{app => }/shamap/tests/FetchPack.test.cpp | 21 +- .../{app => }/shamap/tests/SHAMap.test.cpp | 25 ++- .../shamap/tests/SHAMapSync.test.cpp | 32 +++- src/ripple/unity/app.h | 1 - src/ripple/unity/app1.cpp | 1 - src/ripple/unity/app2.cpp | 12 +- src/ripple/unity/app3.cpp | 3 - src/ripple/unity/app7.cpp | 1 + src/ripple/unity/shamap.cpp | 32 ++++ 48 files changed, 724 insertions(+), 467 deletions(-) create mode 100644 src/ripple/app/ledger/AccountStateSF.cpp create mode 100644 src/ripple/app/ledger/AccountStateSF.h rename src/ripple/app/{shamap/SHAMapSyncFilters.cpp => ledger/ConsensusTransSetSF.cpp} (65%) rename src/ripple/app/{shamap/SHAMapSyncFilters.h => ledger/ConsensusTransSetSF.h} (59%) delete mode 100644 src/ripple/app/ledger/TODO.md create mode 100644 src/ripple/app/ledger/TransactionStateSF.cpp create mode 100644 src/ripple/app/ledger/TransactionStateSF.h rename src/ripple/app/{main/BasicFullBelowCache.cpp => misc/DefaultMissingNodeHandler.cpp} (82%) rename src/ripple/app/{main/FullBelowCache.h => misc/DefaultMissingNodeHandler.h} (80%) rename src/ripple/{app/main/BasicFullBelowCache.h => shamap/FullBelowCache.h} (90%) rename src/ripple/{app => }/shamap/README.md (99%) rename src/ripple/{app => }/shamap/SHAMap.h (91%) rename src/ripple/{app => }/shamap/SHAMapAddNode.h (100%) rename src/ripple/{app => }/shamap/SHAMapItem.h (96%) rename src/ripple/{app => }/shamap/SHAMapMissingNode.h (97%) rename src/ripple/{app => }/shamap/SHAMapNodeID.h (97%) rename src/ripple/{app => }/shamap/SHAMapSyncFilter.h (97%) rename src/ripple/{app => }/shamap/SHAMapTreeNode.h (94%) rename src/ripple/{app => }/shamap/TreeNodeCache.h (100%) rename src/ripple/{app/shamap => shamap/impl}/SHAMap.cpp (94%) rename src/ripple/{app/shamap => shamap/impl}/SHAMapDelta.cpp (99%) rename src/ripple/{app/shamap => shamap/impl}/SHAMapItem.cpp (84%) rename src/ripple/{app/shamap => shamap/impl}/SHAMapMissingNode.cpp (91%) rename src/ripple/{app/shamap => shamap/impl}/SHAMapNodeID.cpp (96%) rename src/ripple/{app/shamap => shamap/impl}/SHAMapSync.cpp (92%) rename src/ripple/{app/shamap => shamap/impl}/SHAMapTreeNode.cpp (97%) rename src/ripple/{app => }/shamap/tests/FetchPack.test.cpp (87%) rename src/ripple/{app => }/shamap/tests/SHAMap.test.cpp (84%) rename src/ripple/{app => }/shamap/tests/SHAMapSync.test.cpp (86%) create mode 100644 src/ripple/unity/shamap.cpp diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 5429d4a687..04b96c5652 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -1689,11 +1689,21 @@ + + True + + + True + + True + + + True @@ -1761,20 +1771,21 @@ + + True + + + True - - True - - True @@ -1815,6 +1826,11 @@ + + True + + + @@ -1956,57 +1972,6 @@ - - True - - - - - - - True - - - True - - - - - True - - - - - True - - - - - True - - - - - True - - - - - True - - - - - True - - - True - - - True - - - True @@ -2426,17 +2391,11 @@ - - True - True - - True - @@ -2457,9 +2416,6 @@ - - True - True @@ -2468,12 +2424,6 @@ True - - True - - - True - @@ -3198,6 +3148,54 @@ + + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + + + + + + + + + + + + + + + True + + + True + + + True + + + @@ -3272,6 +3270,8 @@ + + ..\..\src\snappy\config;..\..\src\snappy\snappy;%(AdditionalIncludeDirectories) ..\..\src\snappy\config;..\..\src\snappy\snappy;%(AdditionalIncludeDirectories) diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 797ea3c8b2..f189a8a698 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -313,12 +313,6 @@ {07831F2A-6752-E81C-87AF-4D47D425BE8E} - - {091DDFB4-76F4-04FB-2787-D51B4A44185E} - - - {A42D8FD4-E866-E1A8-9CBC-1C75906F16D2} - {418BEF0D-AAAB-C368-7D9E-0A97636DE5A6} @@ -445,6 +439,15 @@ {9BA46DD5-4B0C-3C1D-6F16-93DE8A9B7313} + + {81841155-E173-EABC-D87B-5DDBE199F8E3} + + + {92AC870A-6B4B-9CD5-4F7F-648C72CFA0D3} + + + {F0AEA72D-7030-C8C7-1E34-1029BBD56886} + {5DB3CD0B-B361-B301-9562-697CA8A52B68} @@ -2544,12 +2547,24 @@ ripple\app\ledger + + ripple\app\ledger + + + ripple\app\ledger + ripple\app\ledger ripple\app\ledger + + ripple\app\ledger + + + ripple\app\ledger + ripple\app\ledger @@ -2631,24 +2646,24 @@ ripple\app\ledger + + ripple\app\ledger + + + ripple\app\ledger + ripple\app\main ripple\app\main - - ripple\app\main - ripple\app\main ripple\app\main - - ripple\app\main - ripple\app\main @@ -2697,6 +2712,12 @@ ripple\app\misc + + ripple\app\misc + + + ripple\app\misc + ripple\app\misc @@ -2865,66 +2886,6 @@ ripple\app\peers - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap - - - ripple\app\shamap\tests - - - ripple\app\shamap\tests - - - ripple\app\shamap\tests - - - ripple\app\shamap - ripple\app\transactors @@ -3432,18 +3393,12 @@ ripple\nodestore - - ripple\nodestore\impl - ripple\nodestore\impl ripple\nodestore\impl - - ripple\nodestore\impl - ripple\nodestore\impl @@ -3468,9 +3423,6 @@ ripple\nodestore\impl - - ripple\nodestore\impl - ripple\nodestore\impl @@ -3480,12 +3432,6 @@ ripple\nodestore\impl - - ripple\nodestore\impl - - - ripple\nodestore\impl - ripple\nodestore\impl @@ -4341,6 +4287,63 @@ ripple\server + + ripple\shamap + + + ripple\shamap\impl + + + ripple\shamap\impl + + + ripple\shamap\impl + + + ripple\shamap\impl + + + ripple\shamap\impl + + + ripple\shamap\impl + + + ripple\shamap\impl + + + ripple\shamap + + + ripple\shamap + + + ripple\shamap + + + ripple\shamap + + + ripple\shamap + + + ripple\shamap + + + ripple\shamap + + + ripple\shamap\tests + + + ripple\shamap\tests + + + ripple\shamap\tests + + + ripple\shamap + ripple\unity @@ -4440,6 +4443,9 @@ ripple\unity + + ripple\unity + ripple\unity diff --git a/SConstruct b/SConstruct index 9e710f6190..b5d46701a5 100644 --- a/SConstruct +++ b/SConstruct @@ -580,6 +580,8 @@ for tu_style in ['classic', 'unity']: *list_sources('src/ripple/basics', '.cpp')) object_builder.add_source_files( *list_sources('src/ripple/protocol', '.cpp')) + object_builder.add_source_files( + *list_sources('src/ripple/shamap', '.cpp')) object_builder.add_source_files( *list_sources('src/ripple/nodestore', '.cpp'), CPPPATH=[ @@ -591,6 +593,7 @@ for tu_style in ['classic', 'unity']: object_builder.add_source_files( 'src/ripple/unity/basics.cpp', 'src/ripple/unity/protocol.cpp', + 'src/ripple/unity/shamap.cpp', ) object_builder.add_source_files( 'src/ripple/unity/nodestore.cpp', diff --git a/src/beast/beast/module/core/maths/Random.h b/src/beast/beast/module/core/maths/Random.h index 6f03194134..b094359dad 100644 --- a/src/beast/beast/module/core/maths/Random.h +++ b/src/beast/beast/module/core/maths/Random.h @@ -24,8 +24,10 @@ #ifndef BEAST_RANDOM_H_INCLUDED #define BEAST_RANDOM_H_INCLUDED -namespace beast -{ +#include +#include + +namespace beast { //============================================================================== /** diff --git a/src/ripple/app/consensus/LedgerConsensus.cpp b/src/ripple/app/consensus/LedgerConsensus.cpp index 83e1dadb4c..231edd4d7e 100644 --- a/src/ripple/app/consensus/LedgerConsensus.cpp +++ b/src/ripple/app/consensus/LedgerConsensus.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include // VFALCO bad dependency #include #include #include @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -351,9 +352,9 @@ public: { Application& app = getApp(); SHAMap::pointer empty = std::make_shared ( - smtTRANSACTION, - app.getFullBelowCache(), - app.getTreeNodeCache()); + smtTRANSACTION, app.getFullBelowCache(), + app.getTreeNodeCache(), getApp().getNodeStore(), + DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap")); mapCompleteInternal (hash, empty, false); return empty; } diff --git a/src/ripple/app/ledger/AccountStateSF.cpp b/src/ripple/app/ledger/AccountStateSF.cpp new file mode 100644 index 0000000000..d4e9121540 --- /dev/null +++ b/src/ripple/app/ledger/AccountStateSF.cpp @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012, 2013 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#include +#include +#include +#include + +namespace ripple { + +AccountStateSF::AccountStateSF (std::uint32_t ledgerSeq) + : mLedgerSeq (ledgerSeq) +{ +} + +void AccountStateSF::gotNode (bool fromFilter, + SHAMapNodeID const& id, + uint256 const& nodeHash, + Blob& nodeData, + SHAMapTreeNode::TNType) +{ + getApp().getNodeStore ().store (hotACCOUNT_NODE, mLedgerSeq, std::move (nodeData), nodeHash); +} + +bool AccountStateSF::haveNode (SHAMapNodeID const& id, + uint256 const& nodeHash, + Blob& nodeData) +{ + return getApp().getOPs ().getFetchPack (nodeHash, nodeData); +} + +} // ripple diff --git a/src/ripple/app/ledger/AccountStateSF.h b/src/ripple/app/ledger/AccountStateSF.h new file mode 100644 index 0000000000..97697325c4 --- /dev/null +++ b/src/ripple/app/ledger/AccountStateSF.h @@ -0,0 +1,51 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012, 2013 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef RIPPLE_LEDGER_ACCOUNTSTATESF_H_INCLUDED +#define RIPPLE_LEDGER_ACCOUNTSTATESF_H_INCLUDED + +#include + +namespace ripple { + +// This class is only needed on add functions +// sync filter for account state nodes during ledger sync +class AccountStateSF : public SHAMapSyncFilter +{ +public: + explicit AccountStateSF (std::uint32_t ledgerSeq); + + // Note that the nodeData is overwritten by this call + void gotNode (bool fromFilter, + SHAMapNodeID const& id, + uint256 const& nodeHash, + Blob& nodeData, + SHAMapTreeNode::TNType); + + bool haveNode (SHAMapNodeID const& id, + uint256 const& nodeHash, + Blob& nodeData); + +private: + std::uint32_t mLedgerSeq; +}; + +} // ripple + +#endif diff --git a/src/ripple/app/shamap/SHAMapSyncFilters.cpp b/src/ripple/app/ledger/ConsensusTransSetSF.cpp similarity index 65% rename from src/ripple/app/shamap/SHAMapSyncFilters.cpp rename to src/ripple/app/ledger/ConsensusTransSetSF.cpp index ee2e7ccbf6..da1a5cd907 100644 --- a/src/ripple/app/shamap/SHAMapSyncFilters.cpp +++ b/src/ripple/app/ledger/ConsensusTransSetSF.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include @@ -85,54 +85,4 @@ bool ConsensusTransSetSF::haveNode (const SHAMapNodeID& id, uint256 const& nodeH return false; } -//------------------------------------------------------------------------------ - -AccountStateSF::AccountStateSF (std::uint32_t ledgerSeq) - : mLedgerSeq (ledgerSeq) -{ -} - -void AccountStateSF::gotNode (bool fromFilter, - SHAMapNodeID const& id, - uint256 const& nodeHash, - Blob& nodeData, - SHAMapTreeNode::TNType) -{ - getApp().getNodeStore ().store (hotACCOUNT_NODE, mLedgerSeq, std::move (nodeData), nodeHash); -} - -bool AccountStateSF::haveNode (SHAMapNodeID const& id, - uint256 const& nodeHash, - Blob& nodeData) -{ - return getApp().getOPs ().getFetchPack (nodeHash, nodeData); -} - -//------------------------------------------------------------------------------ - -TransactionStateSF::TransactionStateSF (std::uint32_t ledgerSeq) - : mLedgerSeq (ledgerSeq) -{ -} - -void TransactionStateSF::gotNode (bool fromFilter, - SHAMapNodeID const& id, - uint256 const& nodeHash, - Blob& nodeData, - SHAMapTreeNode::TNType type) -{ - getApp().getNodeStore ().store ( - (type == SHAMapTreeNode::tnTRANSACTION_NM) ? hotTRANSACTION : hotTRANSACTION_NODE, - mLedgerSeq, - std::move (nodeData), - nodeHash); -} - -bool TransactionStateSF::haveNode (SHAMapNodeID const& id, - uint256 const& nodeHash, - Blob& nodeData) -{ - return getApp().getOPs ().getFetchPack (nodeHash, nodeData); -} - } // ripple diff --git a/src/ripple/app/shamap/SHAMapSyncFilters.h b/src/ripple/app/ledger/ConsensusTransSetSF.h similarity index 59% rename from src/ripple/app/shamap/SHAMapSyncFilters.h rename to src/ripple/app/ledger/ConsensusTransSetSF.h index 8ac2a0f4ec..425bfd8777 100644 --- a/src/ripple/app/shamap/SHAMapSyncFilters.h +++ b/src/ripple/app/ledger/ConsensusTransSetSF.h @@ -17,8 +17,11 @@ */ //============================================================================== -#ifndef RIPPLE_SHAMAPSYNCFILTERS_H -#define RIPPLE_SHAMAPSYNCFILTERS_H +#ifndef RIPPLE_LEDGER_CONSENSUSTRANSSETSF_H_INCLUDED +#define RIPPLE_LEDGER_CONSENSUSTRANSSETSF_H_INCLUDED + +#include +#include namespace ripple { @@ -50,50 +53,6 @@ private: NodeCache& m_nodeCache; }; -// This class is only needed on add functions -// sync filter for account state nodes during ledger sync -class AccountStateSF : public SHAMapSyncFilter -{ -public: - explicit AccountStateSF (std::uint32_t ledgerSeq); - - // Note that the nodeData is overwritten by this call - void gotNode (bool fromFilter, - SHAMapNodeID const& id, - uint256 const& nodeHash, - Blob& nodeData, - SHAMapTreeNode::TNType); - - bool haveNode (SHAMapNodeID const& id, - uint256 const& nodeHash, - Blob& nodeData); - -private: - std::uint32_t mLedgerSeq; -}; - -// This class is only needed on add functions -// sync filter for transactions tree during ledger sync -class TransactionStateSF : public SHAMapSyncFilter -{ -public: - explicit TransactionStateSF (std::uint32_t ledgerSeq); - - // Note that the nodeData is overwritten by this call - void gotNode (bool fromFilter, - SHAMapNodeID const& id, - uint256 const& nodeHash, - Blob& nodeData, - SHAMapTreeNode::TNType); - - bool haveNode (SHAMapNodeID const& id, - uint256 const& nodeHash, - Blob& nodeData); - -private: - std::uint32_t mLedgerSeq; -}; - } // ripple #endif diff --git a/src/ripple/app/ledger/InboundLedger.cpp b/src/ripple/app/ledger/InboundLedger.cpp index 96110f2498..7152164a42 100644 --- a/src/ripple/app/ledger/InboundLedger.cpp +++ b/src/ripple/app/ledger/InboundLedger.cpp @@ -17,7 +17,9 @@ */ //============================================================================== -#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index f6b91cbb2f..36badfaca5 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -18,6 +18,7 @@ //============================================================================== #include +#include #include #include #include @@ -45,11 +46,13 @@ Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount) , mAccepted (false) , mImmutable (false) , mTransactionMap (std::make_shared (smtTRANSACTION, - getApp().getFullBelowCache(), - getApp().getTreeNodeCache())) + getApp().getFullBelowCache(), getApp().getTreeNodeCache(), + getApp().getNodeStore(), DefaultMissingNodeHandler(), + deprecatedLogs().journal("SHAMap"))) , mAccountStateMap (std::make_shared (smtSTATE, - getApp().getFullBelowCache(), - getApp().getTreeNodeCache())) + getApp().getFullBelowCache(), getApp().getTreeNodeCache(), + getApp().getNodeStore(), DefaultMissingNodeHandler(), + deprecatedLogs().journal("SHAMap"))) { // special case: put coins in root account auto startAccount = std::make_shared (masterID); @@ -92,12 +95,13 @@ Ledger::Ledger (uint256 const& parentHash, , mAccepted (false) , mImmutable (true) , mTransactionMap (std::make_shared ( - smtTRANSACTION, transHash, - getApp().getFullBelowCache(), - getApp().getTreeNodeCache())) + smtTRANSACTION, transHash, getApp().getFullBelowCache(), + getApp().getTreeNodeCache(), getApp().getNodeStore(), + DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap"))) , mAccountStateMap (std::make_shared (smtSTATE, accountHash, - getApp().getFullBelowCache(), - getApp().getTreeNodeCache())) + getApp().getFullBelowCache(), getApp().getTreeNodeCache(), + getApp().getNodeStore(), DefaultMissingNodeHandler(), + deprecatedLogs().journal("SHAMap"))) { updateHash (); loaded = true; @@ -158,8 +162,9 @@ Ledger::Ledger (bool /* dummy */, , mAccepted (false) , mImmutable (false) , mTransactionMap (std::make_shared (smtTRANSACTION, - getApp().getFullBelowCache(), - getApp().getTreeNodeCache())) + getApp().getFullBelowCache(), getApp().getTreeNodeCache(), + getApp().getNodeStore(), DefaultMissingNodeHandler(), + deprecatedLogs().journal("SHAMap"))) , mAccountStateMap (prevLedger.mAccountStateMap->snapShot (true)) { prevLedger.updateHash (); @@ -228,10 +233,12 @@ Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime) mImmutable (false), mTransactionMap (std::make_shared ( smtTRANSACTION, getApp().getFullBelowCache(), - getApp().getTreeNodeCache())), + getApp().getTreeNodeCache(), getApp().getNodeStore(), + DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap"))), mAccountStateMap (std::make_shared ( smtSTATE, getApp().getFullBelowCache(), - getApp().getTreeNodeCache())) + getApp().getTreeNodeCache(), getApp().getNodeStore(), + DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap"))) { initializeFees (); } @@ -333,11 +340,13 @@ void Ledger::setRaw (Serializer& s, bool hasPrefix) { Application& app = getApp(); mTransactionMap = std::make_shared (smtTRANSACTION, mTransHash, - app.getFullBelowCache(), - app.getTreeNodeCache()); + app.getFullBelowCache(), app.getTreeNodeCache(), + getApp().getNodeStore(), DefaultMissingNodeHandler(), + deprecatedLogs().journal("SHAMap")); mAccountStateMap = std::make_shared (smtSTATE, mAccountHash, - app.getFullBelowCache(), - app.getTreeNodeCache()); + app.getFullBelowCache(), app.getTreeNodeCache(), + getApp().getNodeStore(), DefaultMissingNodeHandler(), + deprecatedLogs().journal("SHAMap")); } } diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h index 6333144bc4..f507d8a9ae 100644 --- a/src/ripple/app/ledger/Ledger.h +++ b/src/ripple/app/ledger/Ledger.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_LEDGER_H #define RIPPLE_LEDGER_H -#include +#include #include #include #include diff --git a/src/ripple/app/ledger/TODO.md b/src/ripple/app/ledger/TODO.md deleted file mode 100644 index 25074efe18..0000000000 --- a/src/ripple/app/ledger/TODO.md +++ /dev/null @@ -1,18 +0,0 @@ -# ripple_app - -## Ledger.cpp - -- Move all inlines into the .cpp, make the interface abstract - -- Move static database functions into a real class, perhaps LedgerMaster - -## LedgerMaster.cpp - -- Change getLedgerByHash() to not use "all bits zero" to mean - "return the current ledger" - -- replace uint32 with LedgerIndex and choose appropriate names - -## Beast - -- Change Stoppable to not require a constructor with parameters diff --git a/src/ripple/app/ledger/TransactionStateSF.cpp b/src/ripple/app/ledger/TransactionStateSF.cpp new file mode 100644 index 0000000000..913a6e1e28 --- /dev/null +++ b/src/ripple/app/ledger/TransactionStateSF.cpp @@ -0,0 +1,52 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012, 2013 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#include +#include +#include +#include + +namespace ripple { + +TransactionStateSF::TransactionStateSF (std::uint32_t ledgerSeq) + : mLedgerSeq (ledgerSeq) +{ +} + +void TransactionStateSF::gotNode (bool fromFilter, + SHAMapNodeID const& id, + uint256 const& nodeHash, + Blob& nodeData, + SHAMapTreeNode::TNType type) +{ + getApp().getNodeStore ().store ( + (type == SHAMapTreeNode::tnTRANSACTION_NM) ? hotTRANSACTION : hotTRANSACTION_NODE, + mLedgerSeq, + std::move (nodeData), + nodeHash); +} + +bool TransactionStateSF::haveNode (SHAMapNodeID const& id, + uint256 const& nodeHash, + Blob& nodeData) +{ + return getApp().getOPs ().getFetchPack (nodeHash, nodeData); +} + +} // ripple diff --git a/src/ripple/app/ledger/TransactionStateSF.h b/src/ripple/app/ledger/TransactionStateSF.h new file mode 100644 index 0000000000..b9338ef1ef --- /dev/null +++ b/src/ripple/app/ledger/TransactionStateSF.h @@ -0,0 +1,52 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012, 2013 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef RIPPLE_LEDGER_TRANSACTIONSTATESF_H_INCLUDED +#define RIPPLE_LEDGER_TRANSACTIONSTATESF_H_INCLUDED + +#include +#include + +namespace ripple { + +// This class is only needed on add functions +// sync filter for transactions tree during ledger sync +class TransactionStateSF : public SHAMapSyncFilter +{ +public: + explicit TransactionStateSF (std::uint32_t ledgerSeq); + + // Note that the nodeData is overwritten by this call + void gotNode (bool fromFilter, + SHAMapNodeID const& id, + uint256 const& nodeHash, + Blob& nodeData, + SHAMapTreeNode::TNType); + + bool haveNode (SHAMapNodeID const& id, + uint256 const& nodeHash, + Blob& nodeData); + +private: + std::uint32_t mLedgerSeq; +}; + +} // ripple + +#endif diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h index d70333d3a3..3f1440db0c 100644 --- a/src/ripple/app/main/Application.h +++ b/src/ripple/app/main/Application.h @@ -20,12 +20,13 @@ #ifndef RIPPLE_APP_APPLICATION_H_INCLUDED #define RIPPLE_APP_APPLICATION_H_INCLUDED -#include -#include +#include +#include #include #include +#include // #include - + namespace boost { namespace asio { class io_service; } } namespace ripple { diff --git a/src/ripple/app/main/Tuning.h b/src/ripple/app/main/Tuning.h index 10ba8a6815..fa09ebb4ba 100644 --- a/src/ripple/app/main/Tuning.h +++ b/src/ripple/app/main/Tuning.h @@ -24,13 +24,8 @@ namespace ripple { enum { - fullBelowTargetSize = 524288 - + fullBelowTargetSize = 524288 ,fullBelowExpirationSeconds = 600 - - ,defaultCacheTargetSize = 0 - - ,defaultCacheExpirationSeconds = 120 }; } diff --git a/src/ripple/app/main/BasicFullBelowCache.cpp b/src/ripple/app/misc/DefaultMissingNodeHandler.cpp similarity index 82% rename from src/ripple/app/main/BasicFullBelowCache.cpp rename to src/ripple/app/misc/DefaultMissingNodeHandler.cpp index b9031e214a..791b182652 100644 --- a/src/ripple/app/main/BasicFullBelowCache.cpp +++ b/src/ripple/app/misc/DefaultMissingNodeHandler.cpp @@ -17,11 +17,15 @@ */ //============================================================================== +#include +#include + namespace ripple { -namespace RadMap { -// Unit test to go here if the class becomes -// a non-trivial wrapper for KeyCache. +void +DefaultMissingNodeHandler::operator() (std::uint32_t refNUm) +{ + getApp().getOPs ().missingNodeInLedger (refNUm); +} -} -} +} // ripple diff --git a/src/ripple/app/main/FullBelowCache.h b/src/ripple/app/misc/DefaultMissingNodeHandler.h similarity index 80% rename from src/ripple/app/main/FullBelowCache.h rename to src/ripple/app/misc/DefaultMissingNodeHandler.h index 4c49616f10..ea8d2577b0 100644 --- a/src/ripple/app/main/FullBelowCache.h +++ b/src/ripple/app/misc/DefaultMissingNodeHandler.h @@ -17,15 +17,18 @@ */ //============================================================================== -#ifndef RIPPLE_FULLBELOWCACHE_H_INCLUDED -#define RIPPLE_FULLBELOWCACHE_H_INCLUDED +#ifndef RIPPLE_APP_DEFAULTMISSINGNODEHANDLER_H_INCLUDED +#define RIPPLE_APP_DEFAULTMISSINGNODEHANDLER_H_INCLUDED -#include -#include +#include namespace ripple { -typedef BasicFullBelowCache FullBelowCache; +/** Default handler which calls NetworkOPs. */ +struct DefaultMissingNodeHandler +{ + void operator()(std::uint32_t refNum); +}; } diff --git a/src/ripple/app/misc/NetworkOPs.h b/src/ripple/app/misc/NetworkOPs.h index 22007e7843..40be2f5976 100644 --- a/src/ripple/app/misc/NetworkOPs.h +++ b/src/ripple/app/misc/NetworkOPs.h @@ -21,11 +21,16 @@ #define RIPPLE_NETWORKOPS_H #include +#include +#include #include #include // #include +#include #include +#include "ripple.pb.h" + namespace ripple { // Operations that clients may wish to perform against the network diff --git a/src/ripple/app/tx/TransactionAcquire.cpp b/src/ripple/app/tx/TransactionAcquire.cpp index 23d72ae018..4c80895da6 100644 --- a/src/ripple/app/tx/TransactionAcquire.cpp +++ b/src/ripple/app/tx/TransactionAcquire.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include +#include #include #include @@ -36,7 +38,8 @@ TransactionAcquire::TransactionAcquire (uint256 const& hash, clock_type& clock) { Application& app = getApp(); mMap = std::make_shared (smtTRANSACTION, hash, - app.getFullBelowCache (), app.getTreeNodeCache()); + app.getFullBelowCache (), app.getTreeNodeCache(), app.getNodeStore(), + DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap")); mMap->setUnbacked (); } diff --git a/src/ripple/basics/CountedObject.h b/src/ripple/basics/CountedObject.h index 5a3a80e346..6bf766e825 100644 --- a/src/ripple/basics/CountedObject.h +++ b/src/ripple/basics/CountedObject.h @@ -22,6 +22,7 @@ #include #include +#include #include #include diff --git a/src/ripple/app/main/BasicFullBelowCache.h b/src/ripple/shamap/FullBelowCache.h similarity index 90% rename from src/ripple/app/main/BasicFullBelowCache.h rename to src/ripple/shamap/FullBelowCache.h index 2224a6aa9d..3baef718ea 100644 --- a/src/ripple/app/main/BasicFullBelowCache.h +++ b/src/ripple/shamap/FullBelowCache.h @@ -17,15 +17,19 @@ */ //============================================================================== -#ifndef RIPPLE_RADMAP_BASICFULLBELOWCACHE_H_INCLUDED -#define RIPPLE_RADMAP_BASICFULLBELOWCACHE_H_INCLUDED +#ifndef RIPPLE_SHAMAP_FULLBELOWCACHE_H_INCLUDED +#define RIPPLE_SHAMAP_FULLBELOWCACHE_H_INCLUDED +#include #include -#include #include +#include +#include namespace ripple { +namespace detail { + /** Remembers which tree keys have all descendants resident. This optimizes the process of acquiring a complete tree. */ @@ -36,6 +40,12 @@ private: typedef KeyCache CacheType; public: + enum + { + defaultCacheTargetSize = 0 + ,defaultCacheExpirationSeconds = 120 + }; + typedef Key key_type; typedef typename CacheType::size_type size_type; typedef typename CacheType::clock_type clock_type; @@ -122,6 +132,10 @@ private: std::atomic m_gen; }; +} // detail + +using FullBelowCache = detail::BasicFullBelowCache ; + } #endif diff --git a/src/ripple/app/shamap/README.md b/src/ripple/shamap/README.md similarity index 99% rename from src/ripple/app/shamap/README.md rename to src/ripple/shamap/README.md index 4ca8bd2a03..6ea1c6d9ab 100644 --- a/src/ripple/app/shamap/README.md +++ b/src/ripple/shamap/README.md @@ -112,7 +112,7 @@ The `fetchNodeExternalNT()` method goes through three phases: 2. If the node is not in the TreeNodeCache, we attempt to locate the node in the historic data stored by the data base. The call to - to `getApp().getNodeStore().fetch(hash)` does that work for us. + to `fetch(hash)` does that work for us. 3. Finally, if mLedgerSeq is non-zero and we did't locate the node in the historic data, then we call a MissingNodeHandler. diff --git a/src/ripple/app/shamap/SHAMap.h b/src/ripple/shamap/SHAMap.h similarity index 91% rename from src/ripple/app/shamap/SHAMap.h rename to src/ripple/shamap/SHAMap.h index b4cfde32bb..5e0b5dbc7a 100644 --- a/src/ripple/app/shamap/SHAMap.h +++ b/src/ripple/shamap/SHAMap.h @@ -17,22 +17,24 @@ */ //============================================================================== -#ifndef RIPPLE_SHAMAP_H -#define RIPPLE_SHAMAP_H +#ifndef RIPPLE_SHAMAP_SHAMAP_H_INCLUDED +#define RIPPLE_SHAMAP_SHAMAP_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include #include +#include #include #include #include +#include namespace std { @@ -71,6 +73,9 @@ enum SHAMapState smsInvalid = 4, // Map is known not to be valid (usually synching a corrupt ledger) }; +/** Function object which handles missing nodes. */ +using MissingNodeHandler = std::function ; + /** A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree. A radix tree is a tree with two properties: @@ -95,16 +100,6 @@ enum SHAMapState */ class SHAMap { -private: - /** Function object which handles missing nodes. */ - typedef std::function MissingNodeHandler; - - /** Default handler which calls NetworkOPs. */ - struct DefaultMissingNodeHandler - { - void operator() (std::uint32_t refNUm); - }; - public: enum { @@ -129,15 +124,20 @@ public: SHAMapType t, FullBelowCache& fullBelowCache, TreeNodeCache& treeNodeCache, - std::uint32_t seq = 1, - MissingNodeHandler missing_node_handler = DefaultMissingNodeHandler()); + NodeStore::Database& db, + MissingNodeHandler missing_node_handler, + beast::Journal journal, + std::uint32_t seq = 1 + ); SHAMap ( SHAMapType t, uint256 const& hash, FullBelowCache& fullBelowCache, TreeNodeCache& treeNodeCache, - MissingNodeHandler missing_node_handler = DefaultMissingNodeHandler()); + NodeStore::Database& db, + MissingNodeHandler missing_node_handler, + beast::Journal journal); ~SHAMap (); @@ -324,7 +324,8 @@ private: int walkSubTree (bool doWrite, NodeObjectType t, std::uint32_t seq); private: - + beast::Journal journal_; + NodeStore::Database& db_; FullBelowCache& m_fullBelowCache; std::uint32_t mSeq; std::uint32_t mLedgerSeq; // sequence number of ledger this is part of @@ -332,7 +333,7 @@ private: SHAMapTreeNode::pointer root; SHAMapState mState; SHAMapType mType; - bool mBacked; // Map is backed by the database + bool mBacked = true; // Map is backed by the database MissingNodeHandler m_missing_node_handler; }; diff --git a/src/ripple/app/shamap/SHAMapAddNode.h b/src/ripple/shamap/SHAMapAddNode.h similarity index 100% rename from src/ripple/app/shamap/SHAMapAddNode.h rename to src/ripple/shamap/SHAMapAddNode.h diff --git a/src/ripple/app/shamap/SHAMapItem.h b/src/ripple/shamap/SHAMapItem.h similarity index 96% rename from src/ripple/app/shamap/SHAMapItem.h rename to src/ripple/shamap/SHAMapItem.h index 3caee35729..2c78899cee 100644 --- a/src/ripple/app/shamap/SHAMapItem.h +++ b/src/ripple/shamap/SHAMapItem.h @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace ripple { @@ -122,7 +123,8 @@ public: } #endif - virtual void dump (); + // VFALCO Why is this virtual? + virtual void dump (beast::Journal journal); private: uint256 mTag; diff --git a/src/ripple/app/shamap/SHAMapMissingNode.h b/src/ripple/shamap/SHAMapMissingNode.h similarity index 97% rename from src/ripple/app/shamap/SHAMapMissingNode.h rename to src/ripple/shamap/SHAMapMissingNode.h index 8fefd1c1a6..714bd0a482 100644 --- a/src/ripple/app/shamap/SHAMapMissingNode.h +++ b/src/ripple/shamap/SHAMapMissingNode.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_SHAMAPMISSINGNODE_H #define RIPPLE_SHAMAPMISSINGNODE_H +#include + namespace ripple { enum SHAMapType diff --git a/src/ripple/app/shamap/SHAMapNodeID.h b/src/ripple/shamap/SHAMapNodeID.h similarity index 97% rename from src/ripple/app/shamap/SHAMapNodeID.h rename to src/ripple/shamap/SHAMapNodeID.h index 608bfef39a..b8fca493ef 100644 --- a/src/ripple/app/shamap/SHAMapNodeID.h +++ b/src/ripple/shamap/SHAMapNodeID.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -78,11 +79,6 @@ public: return mHash; } - virtual bool isPopulated () const - { - return false; - } - SHAMapNodeID getParentNodeID () const { assert (mDepth); @@ -113,7 +109,7 @@ public: bool operator!= (uint256 const& n) const {return !(*this == n);} virtual std::string getString () const; - void dump () const; + void dump (beast::Journal journal) const; static uint256 getNodeID (int depth, uint256 const& hash); diff --git a/src/ripple/app/shamap/SHAMapSyncFilter.h b/src/ripple/shamap/SHAMapSyncFilter.h similarity index 97% rename from src/ripple/app/shamap/SHAMapSyncFilter.h rename to src/ripple/shamap/SHAMapSyncFilter.h index 1b559aa248..b3b6ff17e0 100644 --- a/src/ripple/app/shamap/SHAMapSyncFilter.h +++ b/src/ripple/shamap/SHAMapSyncFilter.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_SHAMAPSYNCFILTER_H #define RIPPLE_SHAMAPSYNCFILTER_H -#include +#include /** Callback for filtering SHAMap during sync. */ namespace ripple { diff --git a/src/ripple/app/shamap/SHAMapTreeNode.h b/src/ripple/shamap/SHAMapTreeNode.h similarity index 94% rename from src/ripple/app/shamap/SHAMapTreeNode.h rename to src/ripple/shamap/SHAMapTreeNode.h index a9d6f64117..3c4934165b 100644 --- a/src/ripple/app/shamap/SHAMapTreeNode.h +++ b/src/ripple/shamap/SHAMapTreeNode.h @@ -17,13 +17,15 @@ */ //============================================================================== -#ifndef RIPPLE_SHAMAPTREENODE_H -#define RIPPLE_SHAMAPTREENODE_H +#ifndef RIPPLE_SHAMAP_SHAMAPTREENODE_H +#define RIPPLE_SHAMAP_SHAMAPTREENODE_H -#include -#include +#include +#include +#include #include #include +#include namespace ripple { @@ -67,11 +69,6 @@ public: SHANodeFormat format, uint256 const& hash, bool hashValid); void addRaw (Serializer&, SHANodeFormat format); - virtual bool isPopulated () const - { - return true; - } - // node functions std::uint32_t getSeq () const { @@ -178,7 +175,8 @@ public: mFullBelowGen = gen; } - virtual void dump (SHAMapNodeID const&); + // VFALCO Why is this virtual? + virtual void dump (SHAMapNodeID const&, beast::Journal journal); virtual std::string getString (SHAMapNodeID const&) const; SHAMapTreeNode* getChildPointer (int branch); diff --git a/src/ripple/app/shamap/TreeNodeCache.h b/src/ripple/shamap/TreeNodeCache.h similarity index 100% rename from src/ripple/app/shamap/TreeNodeCache.h rename to src/ripple/shamap/TreeNodeCache.h diff --git a/src/ripple/app/shamap/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp similarity index 94% rename from src/ripple/app/shamap/SHAMap.cpp rename to src/ripple/shamap/impl/SHAMap.cpp index 67f904459c..6ca9a5d833 100644 --- a/src/ripple/app/shamap/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -17,33 +17,28 @@ */ //============================================================================== -#include -#include +#include #include #include namespace ripple { -void SHAMap::DefaultMissingNodeHandler::operator() (std::uint32_t refNUm) -{ - getApp().getOPs ().missingNodeInLedger (refNUm); -}; - -//------------------------------------------------------------------------------ - SHAMap::SHAMap ( SHAMapType t, FullBelowCache& fullBelowCache, TreeNodeCache& treeNodeCache, - std::uint32_t seq, - MissingNodeHandler missing_node_handler) - : m_fullBelowCache (fullBelowCache) + NodeStore::Database& db, + MissingNodeHandler missing_node_handler, + beast::Journal journal, + std::uint32_t seq) + : journal_(journal) + , db_(db) + , m_fullBelowCache (fullBelowCache) , mSeq (seq) , mLedgerSeq (0) , mTreeNodeCache (treeNodeCache) , mState (smsModifying) , mType (t) - , mBacked (true) , m_missing_node_handler (missing_node_handler) { assert (mSeq != 0); @@ -57,14 +52,17 @@ SHAMap::SHAMap ( uint256 const& hash, FullBelowCache& fullBelowCache, TreeNodeCache& treeNodeCache, - MissingNodeHandler missing_node_handler) - : m_fullBelowCache (fullBelowCache) + NodeStore::Database& db, + MissingNodeHandler missing_node_handler, + beast::Journal journal) + : journal_(journal) + , db_(db) + , m_fullBelowCache (fullBelowCache) , mSeq (1) , mLedgerSeq (0) , mTreeNodeCache (treeNodeCache) , mState (smsSynching) , mType (t) - , mBacked (true) , m_missing_node_handler (missing_node_handler) { root = std::make_shared (mSeq); @@ -74,15 +72,13 @@ SHAMap::SHAMap ( SHAMap::~SHAMap () { mState = smsInvalid; - - if (root) - logTimedDestroy (root, "root node"); } SHAMap::pointer SHAMap::snapShot (bool isMutable) { SHAMap::pointer ret = std::make_shared (mType, - m_fullBelowCache, mTreeNodeCache); + m_fullBelowCache, mTreeNodeCache, db_, m_missing_node_handler, + journal_); SHAMap& newMap = *ret; if (!isMutable) @@ -156,14 +152,16 @@ SHAMap::dirtyUp (SharedPtrNodeStack& stack, if (! node->setChild (branch, child->getNodeHash(), child)) { - WriteLog (lsFATAL, SHAMap) << "dirtyUp terminates early"; + journal_.fatal << + "dirtyUp terminates early"; assert (false); return; } -#ifdef ST_DEBUG - WriteLog (lsTRACE, SHAMap) << "dirtyUp sets branch " << branch << " to " << prevHash; -#endif + #ifdef ST_DEBUG + if (journal_.trace) journal_.trace << + "dirtyUp sets branch " << branch << " to " << prevHash; + #endif child = std::move (node); } } @@ -192,9 +190,9 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeFromDB (uint256 const& hash) { SHAMapTreeNode::pointer node; - if (mBacked && getApp().running ()) + if (mBacked) { - NodeObject::pointer obj = getApp().getNodeStore().fetch (hash); + NodeObject::pointer obj = db_.fetch (hash); if (obj) { try @@ -205,7 +203,8 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeFromDB (uint256 const& hash) } catch (...) { - WriteLog (lsWARNING, SHAMap) << "Invalid DB node " << hash; + if (journal_.warning) journal_.warning << + "Invalid DB node " << hash; return SHAMapTreeNode::pointer (); } } @@ -394,7 +393,7 @@ SHAMapTreeNode* SHAMap::descendAsync (SHAMapTreeNode* parent, int branch, if (!ptr && mBacked) { NodeObject::pointer obj; - if (!getApp().getNodeStore().asyncFetch (hash, obj)) + if (! db_.asyncFetch (hash, obj)) { pending = true; return nullptr; @@ -877,7 +876,8 @@ bool SHAMap::updateGiveItem (SHAMapItem::ref item, bool isTransaction, bool hasM if (!node->setItem (item, !isTransaction ? SHAMapTreeNode::tnACCOUNT_STATE : (hasMeta ? SHAMapTreeNode::tnTRANSACTION_MD : SHAMapTreeNode::tnTRANSACTION_NM))) { - WriteLog (lsWARNING, SHAMap) << "SHAMap setItem, no change"; + if (journal_.warning) journal_.warning << + "SHAMap setItem, no change"; return true; } @@ -885,24 +885,28 @@ bool SHAMap::updateGiveItem (SHAMapItem::ref item, bool isTransaction, bool hasM return true; } -void SHAMapItem::dump () -{ - WriteLog (lsINFO, SHAMap) << "SHAMapItem(" << mTag << ") " << mData.size () << "bytes"; -} - bool SHAMap::fetchRoot (uint256 const& hash, SHAMapSyncFilter* filter) { if (hash == root->getNodeHash ()) return true; - if (ShouldLog (lsTRACE, SHAMap)) + if (journal_.trace) { if (mType == smtTRANSACTION) - WriteLog (lsTRACE, SHAMap) << "Fetch root TXN node " << hash; + { + journal_.trace + << "Fetch root TXN node " << hash; + } else if (mType == smtSTATE) - WriteLog (lsTRACE, SHAMap) << "Fetch root STATE node " << hash; + { + journal_.trace << + "Fetch root STATE node " << hash; + } else - WriteLog (lsTRACE, SHAMap) << "Fetch root SHAMap node " << hash; + { + journal_.trace << + "Fetch root SHAMap node " << hash; + } } SHAMapTreeNode::pointer newRoot = fetchNodeNT (SHAMapNodeID(), hash, filter); @@ -938,7 +942,7 @@ void SHAMap::writeNode ( Serializer s; node->addRaw (s, snfPREFIX); - getApp().getNodeStore().store (t, seq, + db_.store (t, seq, std::move (s.modData ()), node->getNodeHash ()); } @@ -1108,7 +1112,8 @@ bool SHAMap::getPath (uint256 const& index, std::vector< Blob >& nodes, SHANodeF void SHAMap::dump (bool hash) { int leafCount = 0; - WriteLog (lsINFO, SHAMap) << " MAP Contains"; + if (journal_.info) journal_.info << + " MAP Contains"; std::stack > stack; stack.push ({root.get (), SHAMapNodeID ()}); @@ -1119,11 +1124,11 @@ void SHAMap::dump (bool hash) SHAMapNodeID nodeID = stack.top().second; stack.pop(); - WriteLog (lsINFO, SHAMap) << node->getString (nodeID); + if (journal_.info) journal_.info << + node->getString (nodeID); if (hash) - { - WriteLog (lsINFO, SHAMap) << "Hash: " << node->getNodeHash(); - } + if (journal_.info) journal_.info << + "Hash: " << node->getNodeHash(); if (node->isInner ()) { @@ -1145,7 +1150,8 @@ void SHAMap::dump (bool hash) } while (!stack.empty ()); - WriteLog (lsINFO, SHAMap) << leafCount << " resident leaves"; + if (journal_.info) journal_.info << + leafCount << " resident leaves"; } SHAMapTreeNode::pointer SHAMap::getCache (uint256 const& hash) diff --git a/src/ripple/app/shamap/SHAMapDelta.cpp b/src/ripple/shamap/impl/SHAMapDelta.cpp similarity index 99% rename from src/ripple/app/shamap/SHAMapDelta.cpp rename to src/ripple/shamap/impl/SHAMapDelta.cpp index f6b78f5ab4..2edd5f144e 100644 --- a/src/ripple/app/shamap/SHAMapDelta.cpp +++ b/src/ripple/shamap/impl/SHAMapDelta.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include + namespace ripple { // This code is used to compare another node's transaction tree diff --git a/src/ripple/app/shamap/SHAMapItem.cpp b/src/ripple/shamap/impl/SHAMapItem.cpp similarity index 84% rename from src/ripple/app/shamap/SHAMapItem.cpp rename to src/ripple/shamap/impl/SHAMapItem.cpp index 2c7feb5e33..f2e2ff2cfd 100644 --- a/src/ripple/app/shamap/SHAMapItem.cpp +++ b/src/ripple/shamap/impl/SHAMapItem.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include + namespace ripple { class SHAMap; @@ -33,4 +35,11 @@ SHAMapItem::SHAMapItem (uint256 const& tag, const Serializer& data) { } +// VFALCO This function appears not to be called +void SHAMapItem::dump (beast::Journal journal) +{ + if (journal.info) journal.info << + "SHAMapItem(" << mTag << ") " << mData.size () << "bytes"; +} + } // ripple diff --git a/src/ripple/app/shamap/SHAMapMissingNode.cpp b/src/ripple/shamap/impl/SHAMapMissingNode.cpp similarity index 91% rename from src/ripple/app/shamap/SHAMapMissingNode.cpp rename to src/ripple/shamap/impl/SHAMapMissingNode.cpp index c5d28b6487..2563d7730d 100644 --- a/src/ripple/app/shamap/SHAMapMissingNode.cpp +++ b/src/ripple/shamap/impl/SHAMapMissingNode.cpp @@ -17,9 +17,13 @@ */ //============================================================================== +#include +#include + namespace ripple { -std::ostream& operator<< (std::ostream& out, const SHAMapMissingNode& mn) +std::ostream& +operator<< (std::ostream& out, const SHAMapMissingNode& mn) { switch (mn.getMapType ()) { diff --git a/src/ripple/app/shamap/SHAMapNodeID.cpp b/src/ripple/shamap/impl/SHAMapNodeID.cpp similarity index 96% rename from src/ripple/app/shamap/SHAMapNodeID.cpp rename to src/ripple/shamap/impl/SHAMapNodeID.cpp index 9b6c1e807c..0e708973d2 100644 --- a/src/ripple/app/shamap/SHAMapNodeID.cpp +++ b/src/ripple/shamap/impl/SHAMapNodeID.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include @@ -176,9 +176,10 @@ int SHAMapNodeID::selectBranch (uint256 const& hash) const return branch; } -void SHAMapNodeID::dump () const +void SHAMapNodeID::dump (beast::Journal journal) const { - WriteLog (lsDEBUG, SHAMapNodeID) << getString (); + if (journal.debug) journal.debug << + getString (); } } // ripple diff --git a/src/ripple/app/shamap/SHAMapSync.cpp b/src/ripple/shamap/impl/SHAMapSync.cpp similarity index 92% rename from src/ripple/app/shamap/SHAMapSync.cpp rename to src/ripple/shamap/impl/SHAMapSync.cpp index eb3c7bfebe..5f31d89754 100644 --- a/src/ripple/app/shamap/SHAMapSync.cpp +++ b/src/ripple/shamap/impl/SHAMapSync.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include // DEPRECATED namespace ripple { @@ -126,11 +126,12 @@ void SHAMap::getMissingNodes (std::vector& nodeIDs, std::vectorisInner ()) { - WriteLog (lsWARNING, SHAMap) << "synching empty tree"; + if (journal_.warning) journal_.warning << + "synching empty tree"; return; } - int const maxDefer = getApp().getNodeStore().getDesiredAsyncReadCount (); + int const maxDefer = db_.getDesiredAsyncReadCount (); // Track the missing hashes we have found so far std::set missingHashes; @@ -236,7 +237,7 @@ void SHAMap::getMissingNodes (std::vector& nodeIDs, std::vector& nodeIDs if (!node || (nodeID != wanted)) { - WriteLog (lsWARNING, SHAMap) << "peer requested node that is not in the map: " << wanted; + if (journal_.warning) journal_.warning << + "peer requested node that is not in the map: " << wanted; throw std::runtime_error ("Peer requested node not in map"); } if (node->isInner () && node->isEmpty ()) { - WriteLog (lsWARNING, SHAMap) << "peer requests empty node"; + if (journal_.warning) journal_.warning << + "peer requests empty node"; return false; } @@ -364,13 +367,14 @@ bool SHAMap::getRootNode (Serializer& s, SHANodeFormat format) return true; } -SHAMapAddNode SHAMap::addRootNode (Blob const& rootNode, SHANodeFormat format, - SHAMapSyncFilter* filter) +SHAMapAddNode SHAMap::addRootNode (Blob const& rootNode, + SHANodeFormat format, SHAMapSyncFilter* filter) { // we already have a root node if (root->getNodeHash ().isNonZero ()) { - WriteLog (lsTRACE, SHAMap) << "got root node, already have one"; + if (journal_.trace) journal_.trace << + "got root node, already have one"; return SHAMapAddNode::duplicate (); } @@ -383,7 +387,7 @@ SHAMapAddNode SHAMap::addRootNode (Blob const& rootNode, SHANodeFormat format, return SHAMapAddNode::invalid (); #ifdef BEAST_DEBUG - node->dump (SHAMapNodeID ()); + node->dump (SHAMapNodeID (), journal_); #endif if (mBacked) @@ -411,7 +415,8 @@ SHAMapAddNode SHAMap::addRootNode (uint256 const& hash, Blob const& rootNode, SH // we already have a root node if (root->getNodeHash ().isNonZero ()) { - WriteLog (lsTRACE, SHAMap) << "got root node, already have one"; + if (journal_.trace) journal_.trace << + "got root node, already have one"; assert (root->getNodeHash () == hash); return SHAMapAddNode::duplicate (); } @@ -452,7 +457,8 @@ SHAMap::addKnownNode (const SHAMapNodeID& node, Blob const& rawNode, if (!isSynching ()) { - WriteLog (lsTRACE, SHAMap) << "AddKnownNode while not synching"; + if (journal_.trace) journal_.trace << + "AddKnownNode while not synching"; return SHAMapAddNode::duplicate (); } @@ -468,8 +474,8 @@ SHAMap::addKnownNode (const SHAMapNodeID& node, Blob const& rawNode, if (iNode->isEmptyBranch (branch)) { - WriteLog (lsWARNING, SHAMap) << "Add known node for empty branch" - << node; + if (journal_.warning) journal_.warning << + "Add known node for empty branch" << node; return SHAMapAddNode::invalid (); } @@ -485,11 +491,13 @@ SHAMap::addKnownNode (const SHAMapNodeID& node, Blob const& rawNode, if (iNodeID != node) { // Either this node is broken or we didn't request it (yet) - WriteLog (lsWARNING, SHAMap) << "unable to hook node " << node; - WriteLog (lsINFO, SHAMap) << " stuck at " << iNodeID; - WriteLog (lsINFO, SHAMap) << "got depth=" << node.getDepth () - << ", walked to= " - << iNodeID.getDepth (); + if (journal_.warning) journal_.warning << + "unable to hook node " << node; + if (journal_.info) journal_.info << + " stuck at " << iNodeID; + if (journal_.info) journal_.info << + "got depth=" << node.getDepth () << + ", walked to= " << iNodeID.getDepth (); return SHAMapAddNode::invalid (); } @@ -506,7 +514,8 @@ SHAMap::addKnownNode (const SHAMapNodeID& node, Blob const& rawNode, if (childHash != newNode->getNodeHash ()) { - WriteLog (lsWARNING, SHAMap) << "Corrupt node received"; + if (journal_.warning) journal_.warning << + "Corrupt node received"; return SHAMapAddNode::invalid (); } @@ -527,7 +536,8 @@ SHAMap::addKnownNode (const SHAMapNodeID& node, Blob const& rawNode, } } - WriteLog (lsTRACE, SHAMap) << "got node, already had it (late)"; + if (journal_.trace) journal_.trace << + "got node, already had it (late)"; return SHAMapAddNode::duplicate (); } @@ -546,17 +556,17 @@ bool SHAMap::deepCompare (SHAMap& other) if (!node || !otherNode) { - WriteLog (lsINFO, SHAMap) << "unable to fetch node"; + if (journal_.info) journal_.info << + "unable to fetch node"; return false; } else if (otherNode->getNodeHash () != node->getNodeHash ()) { - WriteLog (lsWARNING, SHAMap) << "node hash mismatch"; + if (journal_.warning) journal_.warning << + "node hash mismatch"; return false; } - // WriteLog (lsTRACE) << "Comparing inner nodes " << *node; - if (node->isLeaf ()) { if (!otherNode->isLeaf ()) @@ -589,7 +599,8 @@ bool SHAMap::deepCompare (SHAMap& other) SHAMapTreeNode *otherNext = other.descend (otherNode, i); if (!next || !otherNext) { - WriteLog (lsWARNING, SHAMap) << "unable to fetch inner node"; + if (journal_.warning) journal_.warning << + "unable to fetch inner node"; return false; } stack.push ({next, otherNext}); diff --git a/src/ripple/app/shamap/SHAMapTreeNode.cpp b/src/ripple/shamap/impl/SHAMapTreeNode.cpp similarity index 97% rename from src/ripple/app/shamap/SHAMapTreeNode.cpp rename to src/ripple/shamap/impl/SHAMapTreeNode.cpp index 9d1903c127..828ffb179e 100644 --- a/src/ripple/app/shamap/SHAMapTreeNode.cpp +++ b/src/ripple/shamap/impl/SHAMapTreeNode.cpp @@ -17,7 +17,12 @@ */ //============================================================================== +#include +#include #include +#include +#include +#include namespace ripple { @@ -431,9 +436,10 @@ void SHAMapTreeNode::makeInner () mHash.zero (); } -void SHAMapTreeNode::dump (const SHAMapNodeID & id) +void SHAMapTreeNode::dump (const SHAMapNodeID & id, beast::Journal journal) { - WriteLog (lsDEBUG, SHAMapNodeID) << "SHAMapTreeNode(" << id.getNodeID () << ")"; + if (journal.debug) journal.debug << + "SHAMapTreeNode(" << id.getNodeID () << ")"; } std::string SHAMapTreeNode::getString (const SHAMapNodeID & id) const diff --git a/src/ripple/app/shamap/tests/FetchPack.test.cpp b/src/ripple/shamap/tests/FetchPack.test.cpp similarity index 87% rename from src/ripple/app/shamap/tests/FetchPack.test.cpp rename to src/ripple/shamap/tests/FetchPack.test.cpp index 922d29715c..3498a91384 100644 --- a/src/ripple/app/shamap/tests/FetchPack.test.cpp +++ b/src/ripple/shamap/tests/FetchPack.test.cpp @@ -17,9 +17,17 @@ */ //============================================================================== +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include namespace ripple { @@ -36,6 +44,14 @@ public: using Table = SHAMap; using Item = SHAMapItem; + struct Handler + { + void operator()(std::uint32_t refNum) const + { + throw std::runtime_error("missing node"); + } + }; + struct TestFilter : SHAMapSyncFilter { TestFilter (Map& map, beast::Journal journal) : mMap (map), mJournal (journal) @@ -102,9 +118,12 @@ public: FullBelowCache fullBelowCache ("test.full_below", clock); TreeNodeCache treeNodeCache ("test.tree_node_cache", 65536, 60, clock, j); + NodeStore::DummyScheduler scheduler; + auto db = NodeStore::Manager::instance().make_Database ( + "test", scheduler, j, 0, parseDelimitedKeyValueString("type=memory")); std::shared_ptr t1 (std::make_shared
( - smtFREE, fullBelowCache, treeNodeCache)); + smtFREE, fullBelowCache, treeNodeCache, *db, Handler(), beast::Journal())); pass (); diff --git a/src/ripple/app/shamap/tests/SHAMap.test.cpp b/src/ripple/shamap/tests/SHAMap.test.cpp similarity index 84% rename from src/ripple/app/shamap/tests/SHAMap.test.cpp rename to src/ripple/shamap/tests/SHAMap.test.cpp index 91daa8a623..889a9a1f82 100644 --- a/src/ripple/app/shamap/tests/SHAMap.test.cpp +++ b/src/ripple/shamap/tests/SHAMap.test.cpp @@ -17,7 +17,14 @@ */ //============================================================================== +#include +#include +#include +#include +#include +#include #include +#include #include namespace ripple { @@ -25,8 +32,14 @@ namespace ripple { class SHAMap_test : public beast::unit_test::suite { public: - // VFALCO TODO Rename this to createFilledVector and pass an unsigned char, tidy up - // + struct Handler + { + void operator()(std::uint32_t refNum) const + { + throw std::runtime_error("missing node"); + } + }; + static Blob IntToVUC (int v) { Blob vuc; @@ -43,9 +56,12 @@ public: beast::manual_clock clock; // manual advance clock beast::Journal const j; // debug journal - + FullBelowCache fullBelowCache ("test.full_below", clock); TreeNodeCache treeNodeCache ("test.tree_node_cache", 65536, 60, clock, j); + NodeStore::DummyScheduler scheduler; + auto db = NodeStore::Manager::instance().make_Database ( + "test", scheduler, j, 0, parseDelimitedKeyValueString("type=memory")); // h3 and h4 differ only in the leaf, same terminal node (level 19) uint256 h1, h2, h3, h4, h5; @@ -55,7 +71,8 @@ public: h4.SetHex ("b92891fe4ef6cee585fdc6fda2e09eb4d386363158ec3321b8123e5a772c6ca8"); h5.SetHex ("a92891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7"); - SHAMap sMap (smtFREE, fullBelowCache, treeNodeCache); + SHAMap sMap (smtFREE, fullBelowCache, treeNodeCache, + *db, Handler(), beast::Journal()); SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5)); unexpected (!sMap.addItem (i2, true, false), "no add"); unexpected (!sMap.addItem (i1, true, false), "no add"); diff --git a/src/ripple/app/shamap/tests/SHAMapSync.test.cpp b/src/ripple/shamap/tests/SHAMapSync.test.cpp similarity index 86% rename from src/ripple/app/shamap/tests/SHAMapSync.test.cpp rename to src/ripple/shamap/tests/SHAMapSync.test.cpp index 3c3fa192d3..b1171269d4 100644 --- a/src/ripple/app/shamap/tests/SHAMapSync.test.cpp +++ b/src/ripple/shamap/tests/SHAMapSync.test.cpp @@ -17,7 +17,14 @@ */ //============================================================================== +#include +#include +#include #include +#include +#include +#include +#include #include #include // DEPRECATED @@ -30,6 +37,14 @@ namespace ripple { class SHAMapSync_test : public beast::unit_test::suite { public: + struct Handler + { + void operator()(std::uint32_t refNum) const + { + throw std::runtime_error("missing node"); + } + }; + static SHAMapItem::pointer makeRandomAS () { Serializer s; @@ -96,9 +111,14 @@ public: FullBelowCache fullBelowCache ("test.full_below", clock); TreeNodeCache treeNodeCache ("test.tree_node_cache", 65536, 60, clock, j); + NodeStore::DummyScheduler scheduler; + auto db = NodeStore::Manager::instance().make_Database ( + "test", scheduler, j, 1, parseDelimitedKeyValueString("type=memory")); - SHAMap source (smtFREE, fullBelowCache, treeNodeCache); - SHAMap destination (smtFREE, fullBelowCache, treeNodeCache); + SHAMap source (smtFREE, fullBelowCache, treeNodeCache, + *db, Handler(), beast::Journal()); + SHAMap destination (smtFREE, fullBelowCache, treeNodeCache, + *db, Handler(), beast::Journal()); int items = 10000; for (int i = 0; i < items; ++i) @@ -150,7 +170,6 @@ public: { if (!source.getNodeFat (*nodeIDIterator, gotNodeIDs, gotNodes, (rand () % 2) == 0, (rand () % 2) == 0)) { - WriteLog (lsFATAL, SHAMap) << "GetNodeFat fails"; fail ("GetNodeFat"); } else @@ -182,7 +201,6 @@ public: if (!destination.addKnownNode (*nodeIDIterator, *rawNodeIterator, nullptr).isGood ()) { - WriteLog (lsTRACE, SHAMap) << "AddKnownNode fails"; fail ("AddKnownNode"); } else @@ -199,7 +217,7 @@ public: destination.clearSynching (); #ifdef SMS_DEBUG - WriteLog (lsINFO, SHAMap) << "SYNCHING COMPLETE " << items << " items, " << nodes << " nodes, " << + log << "SYNCHING COMPLETE " << items << " items, " << nodes << " nodes, " << bytes / 1024 << " KB"; #endif @@ -213,8 +231,8 @@ public: } #ifdef SMS_DEBUG - WriteLog (lsINFO, SHAMap) << "SHAMapSync test passed: " << items << " items, " << - passes << " passes, " << nodes << " nodes"; + log << "SHAMapSync test passed: " << items << " items, " << + passes << " passes, " << nodes << " nodes"; #endif } }; diff --git a/src/ripple/unity/app.h b/src/ripple/unity/app.h index a9ffae090e..f87e94b4b9 100644 --- a/src/ripple/unity/app.h +++ b/src/ripple/unity/app.h @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ripple/unity/app1.cpp b/src/ripple/unity/app1.cpp index 67b4a6a063..9a4ade0fb0 100644 --- a/src/ripple/unity/app1.cpp +++ b/src/ripple/unity/app1.cpp @@ -21,6 +21,5 @@ #include #include -#include #include #include diff --git a/src/ripple/unity/app2.cpp b/src/ripple/unity/app2.cpp index 4091045309..92e783d524 100644 --- a/src/ripple/unity/app2.cpp +++ b/src/ripple/unity/app2.cpp @@ -25,18 +25,12 @@ #include #include #include +#include #include +#include #include #include +#include #include #include #include - -#include -#include -#include -#include - -#include -#include -#include diff --git a/src/ripple/unity/app3.cpp b/src/ripple/unity/app3.cpp index ffe265f149..52be7547b5 100644 --- a/src/ripple/unity/app3.cpp +++ b/src/ripple/unity/app3.cpp @@ -23,7 +23,4 @@ #include #include -#include -#include -#include #include diff --git a/src/ripple/unity/app7.cpp b/src/ripple/unity/app7.cpp index b98b1856b1..f6b2ff536b 100644 --- a/src/ripple/unity/app7.cpp +++ b/src/ripple/unity/app7.cpp @@ -25,4 +25,5 @@ #include #include #include +#include #include diff --git a/src/ripple/unity/shamap.cpp b/src/ripple/unity/shamap.cpp new file mode 100644 index 0000000000..0ad0c92cdf --- /dev/null +++ b/src/ripple/unity/shamap.cpp @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012, 2013 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include