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
This commit is contained in:
Vinnie Falco
2014-12-27 10:19:26 -08:00
parent 96fbcc9a5a
commit 2e595830b3
48 changed files with 724 additions and 467 deletions

View File

@@ -1689,11 +1689,21 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\AcceptedLedgerTx.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\AccountStateSF.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\AccountStateSF.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\BookListeners.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\BookListeners.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\ConsensusTransSetSF.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\ConsensusTransSetSF.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\DirectoryEntryIterator.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
@@ -1761,20 +1771,21 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\OrderBookIterator.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\TransactionStateSF.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\TransactionStateSF.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\main\Application.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\main\Application.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\main\BasicFullBelowCache.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\main\CollectorManager.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\main\CollectorManager.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\main\FullBelowCache.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\main\LoadManager.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
@@ -1815,6 +1826,11 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\misc\CanonicalTXSet.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\misc\DefaultMissingNodeHandler.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\misc\DefaultMissingNodeHandler.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\misc\FeeVote.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\misc\FeeVoteImpl.cpp">
@@ -1956,57 +1972,6 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\peers\UniqueNodeList.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMap.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMap.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapAddNode.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapDelta.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapItem.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapItem.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapMissingNode.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapMissingNode.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapNodeID.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapNodeID.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapSync.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapSyncFilter.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapSyncFilters.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapSyncFilters.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapTreeNode.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapTreeNode.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\tests\FetchPack.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\shamap\tests\SHAMap.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\shamap\tests\SHAMapSync.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\TreeNodeCache.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\transactors\AddWallet.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
@@ -2426,17 +2391,11 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\nodestore\Factory.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Backend.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\BatchWriter.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\BatchWriter.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Database.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\DatabaseImp.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\DatabaseRotatingImp.cpp">
@@ -2457,9 +2416,6 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\EncodedBlob.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Factory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\ManagerImp.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
@@ -2468,12 +2424,6 @@
<ClCompile Include="..\..\src\ripple\nodestore\impl\NodeObject.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Scheduler.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Task.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\Tuning.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\nodestore\Manager.h">
@@ -3198,6 +3148,54 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\server\Writer.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\FullBelowCache.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMap.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapDelta.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapItem.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapMissingNode.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapNodeID.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapSync.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapTreeNode.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\shamap\SHAMap.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapAddNode.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapItem.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapMissingNode.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapNodeID.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapSyncFilter.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapTreeNode.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\shamap\tests\FetchPack.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\tests\SHAMap.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\tests\SHAMapSync.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\shamap\TreeNodeCache.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\unity\app.cpp">
</ClCompile>
<ClInclude Include="..\..\src\ripple\unity\app.h">
@@ -3272,6 +3270,8 @@
</ClCompile>
<ClCompile Include="..\..\src\ripple\unity\server.cpp">
</ClCompile>
<ClCompile Include="..\..\src\ripple\unity\shamap.cpp">
</ClCompile>
<ClCompile Include="..\..\src\ripple\unity\snappy.cpp">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='debug|x64'">..\..\src\snappy\config;..\..\src\snappy\snappy;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='release|x64'">..\..\src\snappy\config;..\..\src\snappy\snappy;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

View File

@@ -313,12 +313,6 @@
<Filter Include="ripple\app\peers">
<UniqueIdentifier>{07831F2A-6752-E81C-87AF-4D47D425BE8E}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\app\shamap">
<UniqueIdentifier>{091DDFB4-76F4-04FB-2787-D51B4A44185E}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\app\shamap\tests">
<UniqueIdentifier>{A42D8FD4-E866-E1A8-9CBC-1C75906F16D2}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\app\transactors">
<UniqueIdentifier>{418BEF0D-AAAB-C368-7D9E-0A97636DE5A6}</UniqueIdentifier>
</Filter>
@@ -445,6 +439,15 @@
<Filter Include="ripple\server\tests">
<UniqueIdentifier>{9BA46DD5-4B0C-3C1D-6F16-93DE8A9B7313}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\shamap">
<UniqueIdentifier>{81841155-E173-EABC-D87B-5DDBE199F8E3}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\shamap\impl">
<UniqueIdentifier>{92AC870A-6B4B-9CD5-4F7F-648C72CFA0D3}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\shamap\tests">
<UniqueIdentifier>{F0AEA72D-7030-C8C7-1E34-1029BBD56886}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\unity">
<UniqueIdentifier>{5DB3CD0B-B361-B301-9562-697CA8A52B68}</UniqueIdentifier>
</Filter>
@@ -2544,12 +2547,24 @@
<ClInclude Include="..\..\src\ripple\app\ledger\AcceptedLedgerTx.h">
<Filter>ripple\app\ledger</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\AccountStateSF.cpp">
<Filter>ripple\app\ledger</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\AccountStateSF.h">
<Filter>ripple\app\ledger</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\BookListeners.cpp">
<Filter>ripple\app\ledger</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\BookListeners.h">
<Filter>ripple\app\ledger</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\ConsensusTransSetSF.cpp">
<Filter>ripple\app\ledger</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\ConsensusTransSetSF.h">
<Filter>ripple\app\ledger</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\DirectoryEntryIterator.cpp">
<Filter>ripple\app\ledger</Filter>
</ClCompile>
@@ -2631,24 +2646,24 @@
<ClInclude Include="..\..\src\ripple\app\ledger\OrderBookIterator.h">
<Filter>ripple\app\ledger</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\TransactionStateSF.cpp">
<Filter>ripple\app\ledger</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\ledger\TransactionStateSF.h">
<Filter>ripple\app\ledger</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\main\Application.cpp">
<Filter>ripple\app\main</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\main\Application.h">
<Filter>ripple\app\main</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\main\BasicFullBelowCache.h">
<Filter>ripple\app\main</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\main\CollectorManager.cpp">
<Filter>ripple\app\main</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\main\CollectorManager.h">
<Filter>ripple\app\main</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\main\FullBelowCache.h">
<Filter>ripple\app\main</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\main\LoadManager.cpp">
<Filter>ripple\app\main</Filter>
</ClCompile>
@@ -2697,6 +2712,12 @@
<ClInclude Include="..\..\src\ripple\app\misc\CanonicalTXSet.h">
<Filter>ripple\app\misc</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\misc\DefaultMissingNodeHandler.cpp">
<Filter>ripple\app\misc</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\misc\DefaultMissingNodeHandler.h">
<Filter>ripple\app\misc</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\misc\FeeVote.h">
<Filter>ripple\app\misc</Filter>
</ClInclude>
@@ -2865,66 +2886,6 @@
<ClInclude Include="..\..\src\ripple\app\peers\UniqueNodeList.h">
<Filter>ripple\app\peers</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMap.cpp">
<Filter>ripple\app\shamap</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMap.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapAddNode.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapDelta.cpp">
<Filter>ripple\app\shamap</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapItem.cpp">
<Filter>ripple\app\shamap</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapItem.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapMissingNode.cpp">
<Filter>ripple\app\shamap</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapMissingNode.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapNodeID.cpp">
<Filter>ripple\app\shamap</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapNodeID.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapSync.cpp">
<Filter>ripple\app\shamap</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapSyncFilter.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapSyncFilters.cpp">
<Filter>ripple\app\shamap</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapSyncFilters.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\SHAMapTreeNode.cpp">
<Filter>ripple\app\shamap</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\SHAMapTreeNode.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\shamap\tests\FetchPack.test.cpp">
<Filter>ripple\app\shamap\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\shamap\tests\SHAMap.test.cpp">
<Filter>ripple\app\shamap\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\shamap\tests\SHAMapSync.test.cpp">
<Filter>ripple\app\shamap\tests</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\shamap\TreeNodeCache.h">
<Filter>ripple\app\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\transactors\AddWallet.cpp">
<Filter>ripple\app\transactors</Filter>
</ClCompile>
@@ -3432,18 +3393,12 @@
<ClInclude Include="..\..\src\ripple\nodestore\Factory.h">
<Filter>ripple\nodestore</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Backend.cpp">
<Filter>ripple\nodestore\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\BatchWriter.cpp">
<Filter>ripple\nodestore\impl</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\BatchWriter.h">
<Filter>ripple\nodestore\impl</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Database.cpp">
<Filter>ripple\nodestore\impl</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\DatabaseImp.h">
<Filter>ripple\nodestore\impl</Filter>
</ClInclude>
@@ -3468,9 +3423,6 @@
<ClInclude Include="..\..\src\ripple\nodestore\impl\EncodedBlob.h">
<Filter>ripple\nodestore\impl</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Factory.cpp">
<Filter>ripple\nodestore\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\ManagerImp.cpp">
<Filter>ripple\nodestore\impl</Filter>
</ClCompile>
@@ -3480,12 +3432,6 @@
<ClCompile Include="..\..\src\ripple\nodestore\impl\NodeObject.cpp">
<Filter>ripple\nodestore\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Scheduler.cpp">
<Filter>ripple\nodestore\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\nodestore\impl\Task.cpp">
<Filter>ripple\nodestore\impl</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\nodestore\impl\Tuning.h">
<Filter>ripple\nodestore\impl</Filter>
</ClInclude>
@@ -4341,6 +4287,63 @@
<ClInclude Include="..\..\src\ripple\server\Writer.h">
<Filter>ripple\server</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\FullBelowCache.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMap.cpp">
<Filter>ripple\shamap\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapDelta.cpp">
<Filter>ripple\shamap\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapItem.cpp">
<Filter>ripple\shamap\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapMissingNode.cpp">
<Filter>ripple\shamap\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapNodeID.cpp">
<Filter>ripple\shamap\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapSync.cpp">
<Filter>ripple\shamap\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\impl\SHAMapTreeNode.cpp">
<Filter>ripple\shamap\impl</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\shamap\SHAMap.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapAddNode.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapItem.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapMissingNode.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapNodeID.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapSyncFilter.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\shamap\SHAMapTreeNode.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\shamap\tests\FetchPack.test.cpp">
<Filter>ripple\shamap\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\tests\SHAMap.test.cpp">
<Filter>ripple\shamap\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\shamap\tests\SHAMapSync.test.cpp">
<Filter>ripple\shamap\tests</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\shamap\TreeNodeCache.h">
<Filter>ripple\shamap</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\unity\app.cpp">
<Filter>ripple\unity</Filter>
</ClCompile>
@@ -4440,6 +4443,9 @@
<ClCompile Include="..\..\src\ripple\unity\server.cpp">
<Filter>ripple\unity</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\unity\shamap.cpp">
<Filter>ripple\unity</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\unity\snappy.cpp">
<Filter>ripple\unity</Filter>
</ClCompile>

View File

@@ -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',

View File

@@ -24,8 +24,10 @@
#ifndef BEAST_RANDOM_H_INCLUDED
#define BEAST_RANDOM_H_INCLUDED
namespace beast
{
#include <cstddef>
#include <cstdint>
namespace beast {
//==============================================================================
/**

View File

@@ -19,7 +19,7 @@
#include <ripple/app/consensus/DisputedTx.h>
#include <ripple/app/consensus/LedgerConsensus.h>
#include <ripple/json/to_string.h>
#include <ripple/app/misc/DefaultMissingNodeHandler.h> // VFALCO bad dependency
#include <ripple/app/ledger/InboundLedgers.h>
#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/app/ledger/LedgerTiming.h>
@@ -36,6 +36,7 @@
#include <ripple/core/Config.h>
#include <ripple/core/JobQueue.h>
#include <ripple/core/LoadFeeTrack.h>
#include <ripple/json/to_string.h>
#include <ripple/overlay/Overlay.h>
#include <ripple/overlay/predicates.h>
#include <ripple/protocol/STValidation.h>
@@ -351,9 +352,9 @@ public:
{
Application& app = getApp();
SHAMap::pointer empty = std::make_shared<SHAMap> (
smtTRANSACTION,
app.getFullBelowCache(),
app.getTreeNodeCache());
smtTRANSACTION, app.getFullBelowCache(),
app.getTreeNodeCache(), getApp().getNodeStore(),
DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap"));
mapCompleteInternal (hash, empty, false);
return empty;
}

View File

@@ -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 <ripple/app/ledger/AccountStateSF.h>
#include <ripple/app/tx/TransactionMaster.h>
#include <ripple/nodestore/Database.h>
#include <ripple/protocol/HashPrefix.h>
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

View File

@@ -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 <ripple/shamap/SHAMapSyncFilter.h>
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

View File

@@ -17,7 +17,7 @@
*/
//==============================================================================
#include <ripple/app/shamap/SHAMapSyncFilters.h>
#include <ripple/app/ledger/ConsensusTransSetSF.h>
#include <ripple/app/tx/TransactionMaster.h>
#include <ripple/nodestore/Database.h>
#include <ripple/protocol/HashPrefix.h>
@@ -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

View File

@@ -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 <ripple/shamap/SHAMapSyncFilter.h>
#include <ripple/basics/TaggedCache.h>
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

View File

@@ -17,7 +17,9 @@
*/
//==============================================================================
#include <ripple/app/shamap/SHAMapNodeID.h>
#include <ripple/shamap/SHAMapNodeID.h>
#include <ripple/app/ledger/AccountStateSF.h>
#include <ripple/app/ledger/TransactionStateSF.h>
#include <ripple/basics/Log.h>
#include <ripple/core/JobQueue.h>
#include <ripple/overlay/Overlay.h>

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <ripple/app/ledger/LedgerToJson.h>
#include <ripple/app/misc/DefaultMissingNodeHandler.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/LoggedTimings.h>
#include <ripple/basics/StringUtilities.h>
@@ -45,11 +46,13 @@ Ledger::Ledger (RippleAddress const& masterID, std::uint64_t startAmount)
, mAccepted (false)
, mImmutable (false)
, mTransactionMap (std::make_shared <SHAMap> (smtTRANSACTION,
getApp().getFullBelowCache(),
getApp().getTreeNodeCache()))
getApp().getFullBelowCache(), getApp().getTreeNodeCache(),
getApp().getNodeStore(), DefaultMissingNodeHandler(),
deprecatedLogs().journal("SHAMap")))
, mAccountStateMap (std::make_shared <SHAMap> (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<AccountState> (masterID);
@@ -92,12 +95,13 @@ Ledger::Ledger (uint256 const& parentHash,
, mAccepted (false)
, mImmutable (true)
, mTransactionMap (std::make_shared <SHAMap> (
smtTRANSACTION, transHash,
getApp().getFullBelowCache(),
getApp().getTreeNodeCache()))
smtTRANSACTION, transHash, getApp().getFullBelowCache(),
getApp().getTreeNodeCache(), getApp().getNodeStore(),
DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap")))
, mAccountStateMap (std::make_shared <SHAMap> (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 <SHAMap> (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 <SHAMap> (
smtTRANSACTION, getApp().getFullBelowCache(),
getApp().getTreeNodeCache())),
getApp().getTreeNodeCache(), getApp().getNodeStore(),
DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap"))),
mAccountStateMap (std::make_shared <SHAMap> (
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<SHAMap> (smtTRANSACTION, mTransHash,
app.getFullBelowCache(),
app.getTreeNodeCache());
app.getFullBelowCache(), app.getTreeNodeCache(),
getApp().getNodeStore(), DefaultMissingNodeHandler(),
deprecatedLogs().journal("SHAMap"));
mAccountStateMap = std::make_shared<SHAMap> (smtSTATE, mAccountHash,
app.getFullBelowCache(),
app.getTreeNodeCache());
app.getFullBelowCache(), app.getTreeNodeCache(),
getApp().getNodeStore(), DefaultMissingNodeHandler(),
deprecatedLogs().journal("SHAMap"));
}
}

View File

@@ -20,7 +20,7 @@
#ifndef RIPPLE_LEDGER_H
#define RIPPLE_LEDGER_H
#include <ripple/app/shamap/SHAMap.h>
#include <ripple/shamap/SHAMap.h>
#include <ripple/app/tx/Transaction.h>
#include <ripple/app/tx/TransactionMeta.h>
#include <ripple/app/misc/AccountState.h>

View File

@@ -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

View File

@@ -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 <ripple/app/ledger/TransactionStateSF.h>
#include <ripple/app/tx/TransactionMaster.h>
#include <ripple/nodestore/Database.h>
#include <ripple/protocol/HashPrefix.h>
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

View File

@@ -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 <ripple/shamap/SHAMapSyncFilter.h>
#include <cstdint>
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

View File

@@ -20,10 +20,11 @@
#ifndef RIPPLE_APP_APPLICATION_H_INCLUDED
#define RIPPLE_APP_APPLICATION_H_INCLUDED
#include <ripple/app/main/FullBelowCache.h>
#include <ripple/app/shamap/TreeNodeCache.h>
#include <ripple/shamap/FullBelowCache.h>
#include <ripple/shamap/TreeNodeCache.h>
#include <ripple/basics/TaggedCache.h>
#include <beast/utility/PropertyStream.h>
#include <beast/cxx14/memory.h> // <memory>
#include <mutex>
namespace boost { namespace asio { class io_service; } }

View File

@@ -25,12 +25,7 @@ namespace ripple {
enum
{
fullBelowTargetSize = 524288
,fullBelowExpirationSeconds = 600
,defaultCacheTargetSize = 0
,defaultCacheExpirationSeconds = 120
};
}

View File

@@ -17,11 +17,15 @@
*/
//==============================================================================
#include <ripple/app/misc/DefaultMissingNodeHandler.h>
#include <ripple/app/misc/NetworkOPs.h>
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

View File

@@ -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 <ripple/basics/base_uint.h>
#include <ripple/app/main/BasicFullBelowCache.h>
#include <cstdint>
namespace ripple {
typedef BasicFullBelowCache <uint256> FullBelowCache;
/** Default handler which calls NetworkOPs. */
struct DefaultMissingNodeHandler
{
void operator()(std::uint32_t refNum);
};
}

View File

@@ -21,11 +21,16 @@
#define RIPPLE_NETWORKOPS_H
#include <ripple/protocol/STValidation.h>
#include <ripple/app/ledger/Ledger.h>
#include <ripple/app/ledger/LedgerProposal.h>
#include <ripple/net/InfoSub.h>
#include <beast/cxx14/memory.h> // <memory>
#include <beast/threads/Stoppable.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <tuple>
#include "ripple.pb.h"
namespace ripple {
// Operations that clients may wish to perform against the network

View File

@@ -17,6 +17,8 @@
*/
//==============================================================================
#include <ripple/app/ledger/ConsensusTransSetSF.h>
#include <ripple/app/misc/DefaultMissingNodeHandler.h>
#include <ripple/overlay/Overlay.h>
#include <boost/foreach.hpp>
@@ -36,7 +38,8 @@ TransactionAcquire::TransactionAcquire (uint256 const& hash, clock_type& clock)
{
Application& app = getApp();
mMap = std::make_shared<SHAMap> (smtTRANSACTION, hash,
app.getFullBelowCache (), app.getTreeNodeCache());
app.getFullBelowCache (), app.getTreeNodeCache(), app.getNodeStore(),
DefaultMissingNodeHandler(), deprecatedLogs().journal("SHAMap"));
mMap->setUnbacked ();
}

View File

@@ -22,6 +22,7 @@
#include <beast/utility/LeakChecked.h>
#include <atomic>
#include <string>
#include <utility>
#include <vector>

View File

@@ -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 <ripple/basics/base_uint.h>
#include <ripple/basics/KeyCache.h>
#include <ripple/app/main/Tuning.h>
#include <beast/insight/Collector.h>
#include <atomic>
#include <string>
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 <Key> 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 <std::uint32_t> m_gen;
};
} // detail
using FullBelowCache = detail::BasicFullBelowCache <uint256>;
}
#endif

View File

@@ -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.

View File

@@ -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 <ripple/app/shamap/SHAMapAddNode.h>
#include <ripple/app/shamap/SHAMapItem.h>
#include <ripple/app/shamap/SHAMapMissingNode.h>
#include <ripple/app/shamap/SHAMapNodeID.h>
#include <ripple/app/shamap/SHAMapSyncFilter.h>
#include <ripple/app/shamap/SHAMapTreeNode.h>
#include <ripple/basics/LoggedTimings.h>
#include <ripple/shamap/FullBelowCache.h>
#include <ripple/shamap/SHAMapAddNode.h>
#include <ripple/shamap/SHAMapItem.h>
#include <ripple/shamap/SHAMapMissingNode.h>
#include <ripple/shamap/SHAMapNodeID.h>
#include <ripple/shamap/SHAMapSyncFilter.h>
#include <ripple/shamap/SHAMapTreeNode.h>
#include <ripple/basics/UnorderedContainers.h>
#include <ripple/app/main/FullBelowCache.h>
#include <ripple/nodestore/Database.h>
#include <ripple/nodestore/NodeObject.h>
#include <beast/utility/Journal.h>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_lock_guard.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <stack>
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 <void (std::uint32_t refNum)>;
/** 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 <void (std::uint32_t refNum)> 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;
};

View File

@@ -23,6 +23,7 @@
#include <ripple/basics/CountedObject.h>
#include <ripple/protocol/Serializer.h>
#include <ripple/basics/base_uint.h>
#include <beast/utility/Journal.h>
#include <memory>
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;

View File

@@ -20,6 +20,8 @@
#ifndef RIPPLE_SHAMAPMISSINGNODE_H
#define RIPPLE_SHAMAPMISSINGNODE_H
#include <ripple/basics/base_uint.h>
namespace ripple {
enum SHAMapType

View File

@@ -22,6 +22,7 @@
#include <ripple/protocol/Serializer.h>
#include <ripple/basics/base_uint.h>
#include <beast/utility/Journal.h>
#include <ostream>
#include <string>
#include <tuple>
@@ -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);

View File

@@ -20,7 +20,7 @@
#ifndef RIPPLE_SHAMAPSYNCFILTER_H
#define RIPPLE_SHAMAPSYNCFILTER_H
#include <ripple/app/shamap/SHAMapTreeNode.h>
#include <ripple/shamap/SHAMapTreeNode.h>
/** Callback for filtering SHAMap during sync. */
namespace ripple {

View File

@@ -17,13 +17,15 @@
*/
//==============================================================================
#ifndef RIPPLE_SHAMAPTREENODE_H
#define RIPPLE_SHAMAPTREENODE_H
#ifndef RIPPLE_SHAMAP_SHAMAPTREENODE_H
#define RIPPLE_SHAMAP_SHAMAPTREENODE_H
#include <ripple/app/shamap/SHAMapNodeID.h>
#include <ripple/app/shamap/TreeNodeCache.h>
#include <ripple/shamap/SHAMapItem.h>
#include <ripple/shamap/SHAMapNodeID.h>
#include <ripple/shamap/TreeNodeCache.h>
#include <ripple/basics/CountedObject.h>
#include <ripple/basics/TaggedCache.h>
#include <beast/utility/Journal.h>
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);

View File

@@ -17,33 +17,28 @@
*/
//==============================================================================
#include <ripple/basics/Log.h>
#include <ripple/nodestore/Database.h>
#include <ripple/shamap/SHAMap.h>
#include <beast/unit_test/suite.h>
#include <beast/chrono/manual_clock.h>
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<SHAMapTreeNode> (mSeq);
@@ -74,15 +72,13 @@ SHAMap::SHAMap (
SHAMap::~SHAMap ()
{
mState = smsInvalid;
if (root)
logTimedDestroy <SHAMap> (root, "root node");
}
SHAMap::pointer SHAMap::snapShot (bool isMutable)
{
SHAMap::pointer ret = std::make_shared<SHAMap> (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 <std::pair <SHAMapTreeNode*, SHAMapNodeID> > 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)

View File

@@ -17,6 +17,8 @@
*/
//==============================================================================
#include <ripple/shamap/SHAMap.h>
namespace ripple {
// This code is used to compare another node's transaction tree

View File

@@ -17,6 +17,8 @@
*/
//==============================================================================
#include <ripple/shamap/SHAMapItem.h>
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

View File

@@ -17,9 +17,13 @@
*/
//==============================================================================
#include <ripple/shamap/SHAMapMissingNode.h>
#include <ostream>
namespace ripple {
std::ostream& operator<< (std::ostream& out, const SHAMapMissingNode& mn)
std::ostream&
operator<< (std::ostream& out, const SHAMapMissingNode& mn)
{
switch (mn.getMapType ())
{

View File

@@ -17,7 +17,7 @@
*/
//==============================================================================
#include <ripple/app/shamap/SHAMapNodeID.h>
#include <ripple/shamap/SHAMapNodeID.h>
#include <ripple/crypto/RandomNumbers.h>
#include <beast/module/core/text/LexicalCast.h>
#include <beast/utility/static_initializer.h>
@@ -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

View File

@@ -17,9 +17,9 @@
*/
//==============================================================================
#include <ripple/shamap/SHAMap.h>
#include <ripple/nodestore/Database.h>
#include <beast/unit_test/suite.h>
#include <openssl/rand.h> // DEPRECATED
namespace ripple {
@@ -126,11 +126,12 @@ void SHAMap::getMissingNodes (std::vector<SHAMapNodeID>& nodeIDs, std::vector<ui
if (!root->isInner ())
{
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 <uint256> missingHashes;
@@ -236,7 +237,7 @@ void SHAMap::getMissingNodes (std::vector<SHAMapNodeID>& nodeIDs, std::vector<ui
if (deferredReads.empty ())
break;
getApp().getNodeStore().waitReads();
db_.waitReads();
// Process all deferred reads
for (auto const& node : deferredReads)
@@ -299,13 +300,15 @@ bool SHAMap::getNodeFat (SHAMapNodeID wanted, std::vector<SHAMapNodeID>& 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});

View File

@@ -17,7 +17,12 @@
*/
//==============================================================================
#include <ripple/shamap/SHAMapTreeNode.h>
#include <ripple/basics/Log.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/protocol/HashPrefix.h>
#include <beast/module/core/text/LexicalCast.h>
#include <mutex>
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

View File

@@ -17,9 +17,17 @@
*/
//==============================================================================
#include <ripple/shamap/SHAMap.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/basics/UnorderedContainers.h>
#include <ripple/nodestore/DummyScheduler.h>
#include <ripple/nodestore/Manager.h>
#include <ripple/protocol/UInt160.h>
#include <beast/chrono/manual_clock.h>
#include <beast/module/core/maths/Random.h>
#include <beast/unit_test/suite.h>
#include <functional>
#include <stdexcept>
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 <Table> t1 (std::make_shared <Table> (
smtFREE, fullBelowCache, treeNodeCache));
smtFREE, fullBelowCache, treeNodeCache, *db, Handler(), beast::Journal()));
pass ();

View File

@@ -17,7 +17,14 @@
*/
//==============================================================================
#include <ripple/shamap/FullBelowCache.h>
#include <ripple/shamap/SHAMap.h>
#include <ripple/basics/Blob.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/nodestore/DummyScheduler.h>
#include <ripple/nodestore/Manager.h>
#include <beast/unit_test/suite.h>
#include <beast/utility/Journal.h>
#include <beast/chrono/manual_clock.h>
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;
@@ -46,6 +59,9 @@ 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"));
// 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");

View File

@@ -17,7 +17,14 @@
*/
//==============================================================================
#include <ripple/shamap/SHAMap.h>
#include <ripple/shamap/SHAMapItem.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/nodestore/Database.h>
#include <ripple/nodestore/DummyScheduler.h>
#include <ripple/nodestore/Manager.h>
#include <ripple/protocol/UInt160.h>
#include <beast/chrono/manual_clock.h>
#include <beast/unit_test/suite.h>
#include <openssl/rand.h> // 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,7 +231,7 @@ public:
}
#ifdef SMS_DEBUG
WriteLog (lsINFO, SHAMap) << "SHAMapSync test passed: " << items << " items, " <<
log << "SHAMapSync test passed: " << items << " items, " <<
passes << " passes, " << nodes << " nodes";
#endif
}

View File

@@ -49,7 +49,6 @@
#include <ripple/app/ledger/Ledger.h>
#include <ripple/app/main/LoadManager.h>
#include <ripple/app/misc/OrderBook.h>
#include <ripple/app/shamap/SHAMapSyncFilters.h>
#include <ripple/app/misc/AmendmentTable.h>
#include <ripple/app/misc/FeeVote.h>
#include <ripple/app/misc/IHashRouter.h>

View File

@@ -21,6 +21,5 @@
#include <ripple/app/consensus/LedgerConsensus.cpp>
#include <ripple/app/peers/PeerSet.cpp>
#include <ripple/app/shamap/SHAMapSyncFilters.cpp>
#include <ripple/app/ledger/LedgerCleaner.cpp>
#include <ripple/app/ledger/LedgerMaster.cpp>

View File

@@ -25,18 +25,12 @@
#include <ripple/app/data/DatabaseCon.cpp>
#include <ripple/app/data/SqliteDatabase.cpp>
#include <ripple/app/data/DBInit.cpp>
#include <ripple/app/ledger/AccountStateSF.cpp>
#include <ripple/app/ledger/BookListeners.cpp>
#include <ripple/app/ledger/ConsensusTransSetSF.cpp>
#include <ripple/app/ledger/LedgerProposal.cpp>
#include <ripple/app/ledger/OrderBookDB.cpp>
#include <ripple/app/ledger/TransactionStateSF.cpp>
#include <ripple/app/main/LoadManager.cpp>
#include <ripple/app/misc/CanonicalTXSet.cpp>
#include <ripple/app/misc/SHAMapStoreImp.cpp>
#include <ripple/app/shamap/SHAMap.cpp>
#include <ripple/app/shamap/SHAMapItem.cpp>
#include <ripple/app/shamap/SHAMapSync.cpp>
#include <ripple/app/shamap/SHAMapMissingNode.cpp>
#include <ripple/app/shamap/tests/FetchPack.test.cpp>
#include <ripple/app/shamap/tests/SHAMap.test.cpp>
#include <ripple/app/shamap/tests/SHAMapSync.test.cpp>

View File

@@ -23,7 +23,4 @@
#include <ripple/app/ledger/Ledger.cpp>
#include <ripple/app/ledger/Ledger.test.cpp>
#include <ripple/app/shamap/SHAMapDelta.cpp>
#include <ripple/app/shamap/SHAMapNodeID.cpp>
#include <ripple/app/shamap/SHAMapTreeNode.cpp>
#include <ripple/app/misc/AccountState.cpp>

View File

@@ -25,4 +25,5 @@
#include <ripple/app/ledger/LedgerHistory.cpp>
#include <ripple/app/tx/TransactionAcquire.cpp>
#include <ripple/app/tx/LocalTxs.cpp>
#include <ripple/app/misc/DefaultMissingNodeHandler.cpp>
#include <ripple/app/misc/NetworkOPs.cpp>

View File

@@ -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 <BeastConfig.h>
#include <ripple/shamap/impl/SHAMap.cpp>
#include <ripple/shamap/impl/SHAMapDelta.cpp>
#include <ripple/shamap/impl/SHAMapItem.cpp>
#include <ripple/shamap/impl/SHAMapMissingNode.cpp>
#include <ripple/shamap/impl/SHAMapNodeID.cpp>
#include <ripple/shamap/impl/SHAMapSync.cpp>
#include <ripple/shamap/impl/SHAMapTreeNode.cpp>
#include <ripple/shamap/tests/FetchPack.test.cpp>
#include <ripple/shamap/tests/SHAMap.test.cpp>
#include <ripple/shamap/tests/SHAMapSync.test.cpp>