mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-19 18:15:50 +00:00
Migrate validators and testoverlay to the new style of source organization
This commit is contained in:
@@ -43,7 +43,6 @@ linux-g++:QMAKE_CXXFLAGS += \
|
||||
-pthread
|
||||
|
||||
INCLUDEPATH += \
|
||||
"../.." \
|
||||
"../../src" \
|
||||
"../../src/leveldb/" \
|
||||
"../../src/leveldb/port" \
|
||||
@@ -58,6 +57,9 @@ OTHER_FILES += \
|
||||
|
||||
UI_HEADERS_DIR += ../../src/ripple_basics
|
||||
|
||||
# -----
|
||||
# Beast
|
||||
#
|
||||
SOURCES += \
|
||||
../../src/beast/modules/beast_asio/beast_asio.cpp \
|
||||
../../src/beast/modules/beast_core/beast_core.cpp \
|
||||
@@ -65,7 +67,12 @@ SOURCES += \
|
||||
../../src/beast/modules/beast_db/beast_db.cpp \
|
||||
../../src/beast/modules/beast_extras/beast_extras.cpp \
|
||||
../../src/beast/modules/beast_sqdb/beast_sqdb.cpp \
|
||||
../../src/beast/modules/beast_sqlite/beast_sqlite.c \
|
||||
../../src/beast/modules/beast_sqlite/beast_sqlite.c
|
||||
|
||||
# ---------
|
||||
# Old style
|
||||
#
|
||||
SOURCES += \
|
||||
../../src/ripple_app/ripple_app.cpp \
|
||||
../../src/ripple_app/ripple_app_pt1.cpp \
|
||||
../../src/ripple_app/ripple_app_pt2.cpp \
|
||||
@@ -84,6 +91,13 @@ SOURCES += \
|
||||
../../src/ripple_net/ripple_net.cpp \
|
||||
../../src/ripple_websocket/ripple_websocket.cpp
|
||||
|
||||
# ---------
|
||||
# New style
|
||||
#
|
||||
SOURCES += \
|
||||
../../src/ripple/testoverlay/ripple_testoverlay.cpp \
|
||||
../../src/ripple/validators/ripple_validators.cpp
|
||||
|
||||
LIBS += \
|
||||
-lboost_date_time-mt\
|
||||
-lboost_filesystem-mt \
|
||||
|
||||
@@ -26,6 +26,44 @@
|
||||
<ClCompile Include="..\..\src\beast\modules\beast_db\beast_db.cpp" />
|
||||
<ClCompile Include="..\..\src\beast\modules\beast_sqdb\beast_sqdb.cpp" />
|
||||
<ClCompile Include="..\..\src\beast\modules\beast_sqlite\beast_sqlite.c" />
|
||||
<ClCompile Include="..\..\src\ripple\testoverlay\impl\TestOverlay.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\testoverlay\ripple_testoverlay.cpp" />
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\Validators.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\ValidatorSourceFile.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\ValidatorSourceStrings.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\ValidatorSourceURL.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\ValidatorsUtilities.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\ripple_validators.cpp" />
|
||||
<ClCompile Include="..\..\src\ripple_app\consensus\ripple_DisputedTx.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -784,12 +822,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_core\test\TestOverlay.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\peerfinder\ripple_PeerFinder.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -797,36 +829,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\ripple_core.cpp" />
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\ValidatorSourceFile.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\ValidatorSourceStrings.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\ValidatorSourceURL.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\Validators.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\ValidatorsUtilities.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_data\crypto\ripple_Base58.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -1378,6 +1380,23 @@
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\ConfigType.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\ConnectionType.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\InitPolicy.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\MessageType.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\NetworkType.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\PeerLogicBase.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\PeerType.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\Results.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\SimplePayload.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\StateBase.h" />
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\ripple_testoverlay.h" />
|
||||
<ClInclude Include="..\..\src\ripple\validators\api\Validators.h" />
|
||||
<ClInclude Include="..\..\src\ripple\validators\impl\ValidatorSourceFile.h" />
|
||||
<ClInclude Include="..\..\src\ripple\validators\impl\ValidatorSourceStrings.h" />
|
||||
<ClInclude Include="..\..\src\ripple\validators\impl\ValidatorSourceURL.h" />
|
||||
<ClInclude Include="..\..\src\ripple\validators\impl\ValidatorsUtilities.h" />
|
||||
<ClInclude Include="..\..\src\ripple\validators\ripple_validators.h" />
|
||||
<ClInclude Include="..\..\src\ripple_app\consensus\ripple_DisputedTx.h" />
|
||||
<ClInclude Include="..\..\src\ripple_app\consensus\ripple_LedgerConsensus.h" />
|
||||
<ClInclude Include="..\..\src\ripple_app\contracts\ripple_Contract.h" />
|
||||
@@ -1520,22 +1539,6 @@
|
||||
<ClInclude Include="..\..\src\ripple_core\node\NullBackendFactory.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\peerfinder\ripple_PeerFinder.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\ripple_core.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\ConnectionType.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\InitPolicy.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\MessageType.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\NetworkType.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\PeerLogicBase.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\ConfigType.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\PeerType.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\Results.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\SimplePayload.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\test\StateBase.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorSourceFile.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorSourceStrings.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorSourceURL.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorsImp.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\Validators.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorsUtilities.h" />
|
||||
<ClInclude Include="..\..\src\ripple_data\crypto\ripple_Base58.h" />
|
||||
<ClInclude Include="..\..\src\ripple_data\crypto\ripple_Base58Data.h" />
|
||||
<ClInclude Include="..\..\src\ripple_data\crypto\ripple_CBigNum.h" />
|
||||
|
||||
@@ -70,9 +70,6 @@
|
||||
<Filter Include="[1] Ripple\ripple_hyperleveldb">
|
||||
<UniqueIdentifier>{571acd5b-065c-4202-8de3-8692735171dc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[1] Ripple\ripple_core\validator">
|
||||
<UniqueIdentifier>{efccddf1-024d-41c4-b7f5-26ce2dd79f21}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[1] Ripple\ripple_app\main">
|
||||
<UniqueIdentifier>{cf19fa31-c40b-4203-b497-63a8c3dcb282}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -118,12 +115,6 @@
|
||||
<Filter Include="[1] Ripple\ripple_app\node">
|
||||
<UniqueIdentifier>{1d9bc26d-d76e-4fd4-a737-b968e31e614b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[1] Ripple\ripple_core\test">
|
||||
<UniqueIdentifier>{129c51dc-e885-4023-999b-e133d800fb80}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[2] doc">
|
||||
<UniqueIdentifier>{c69b07a2-44e5-4b06-99a9-81f5d137ea15}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[1] Ripple\ripple_core\peerfinder">
|
||||
<UniqueIdentifier>{d1648d3f-7d71-495d-afc9-576ed00d7185}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -157,6 +148,30 @@
|
||||
<Filter Include="[0] Libraries\websocket">
|
||||
<UniqueIdentifier>{6967f835-a1b0-47e3-9bd9-6fc8bd0f3df7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[2] Ripple %28New%29">
|
||||
<UniqueIdentifier>{a2508a4d-acbc-406b-ada6-e66ff66fafc6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[3] doc">
|
||||
<UniqueIdentifier>{c69b07a2-44e5-4b06-99a9-81f5d137ea15}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[2] Ripple %28New%29\testoverlay">
|
||||
<UniqueIdentifier>{b6d40ea6-339c-4ae5-9f48-37e235eff2f2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[2] Ripple %28New%29\validators">
|
||||
<UniqueIdentifier>{ab806f38-36f5-4c76-b83a-72ac8bf54440}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[2] Ripple %28New%29\validators\api">
|
||||
<UniqueIdentifier>{0e355563-7517-4e4b-ba7c-65eb11942cda}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[2] Ripple %28New%29\validators\impl">
|
||||
<UniqueIdentifier>{de9ef050-2263-4cd3-a563-db81d137cf34}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[2] Ripple %28New%29\testoverlay\api">
|
||||
<UniqueIdentifier>{35c905cd-afaa-467a-906d-eb2b34a18907}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="[2] Ripple %28New%29\testoverlay\impl">
|
||||
<UniqueIdentifier>{e614b68f-21cb-4866-82d1-1ea89ee11906}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\ripple_basics\containers\ripple_RangeSet.cpp">
|
||||
@@ -831,18 +846,6 @@
|
||||
<ClCompile Include="..\..\src\ripple_core\node\NullBackendFactory.cpp">
|
||||
<Filter>[1] Ripple\ripple_core\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\ValidatorSourceStrings.cpp">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\Validators.cpp">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\ValidatorsUtilities.cpp">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\ValidatorSourceFile.cpp">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\build\proto\ripple.pb.cc">
|
||||
<Filter>[1] Ripple</Filter>
|
||||
</ClCompile>
|
||||
@@ -867,7 +870,6 @@
|
||||
<ClCompile Include="..\..\src\beast\modules\beast_sqlite\beast_sqlite.c">
|
||||
<Filter>[0] Libraries\beast</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_core\test\TestOverlay.cpp" />
|
||||
<ClCompile Include="..\..\src\ripple_core\ripple_core.cpp">
|
||||
<Filter>[1] Ripple\ripple_core</Filter>
|
||||
</ClCompile>
|
||||
@@ -877,8 +879,29 @@
|
||||
<ClCompile Include="..\..\src\ripple_core\functional\Config.cpp">
|
||||
<Filter>[1] Ripple\ripple_core\functional</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple_core\validator\ValidatorSourceURL.cpp">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
<ClCompile Include="..\..\src\ripple\testoverlay\ripple_testoverlay.cpp">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\testoverlay\impl\TestOverlay.cpp">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\ripple_validators.cpp">
|
||||
<Filter>[2] Ripple %28New%29\validators</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\Validators.cpp">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\ValidatorSourceFile.cpp">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\ValidatorSourceStrings.cpp">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\ValidatorSourceURL.cpp">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ripple\validators\impl\ValidatorsUtilities.cpp">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -1680,51 +1703,6 @@
|
||||
<ClInclude Include="..\..\src\ripple_app\misc\ripple_Validations.h">
|
||||
<Filter>[1] Ripple\ripple_app\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorSourceStrings.h">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\Validators.h">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorsImp.h">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\Results.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\SimplePayload.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\MessageType.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\ConnectionType.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\PeerType.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\NetworkType.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\StateBase.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\PeerLogicBase.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\InitPolicy.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\test\ConfigType.h">
|
||||
<Filter>[1] Ripple\ripple_core\test</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorsUtilities.h">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorSourceFile.h">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\BeastConfig.h" />
|
||||
<ClInclude Include="..\..\src\ripple_core\peerfinder\ripple_PeerFinder.h">
|
||||
<Filter>[1] Ripple\ripple_core\peerfinder</Filter>
|
||||
@@ -1732,8 +1710,56 @@
|
||||
<ClInclude Include="..\..\src\ripple_core\functional\Config.h">
|
||||
<Filter>[1] Ripple\ripple_core\functional</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple_core\validator\ValidatorSourceURL.h">
|
||||
<Filter>[1] Ripple\ripple_core\validator</Filter>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\ripple_testoverlay.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\ConfigType.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\ConnectionType.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\InitPolicy.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\MessageType.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\NetworkType.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\PeerLogicBase.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\PeerType.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\Results.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\SimplePayload.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\testoverlay\api\StateBase.h">
|
||||
<Filter>[2] Ripple %28New%29\testoverlay\api</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\validators\ripple_validators.h">
|
||||
<Filter>[2] Ripple %28New%29\validators</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\validators\impl\ValidatorSourceFile.h">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\validators\impl\ValidatorSourceStrings.h">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\validators\impl\ValidatorSourceURL.h">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\validators\impl\ValidatorsUtilities.h">
|
||||
<Filter>[2] Ripple %28New%29\validators\impl</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ripple\validators\api\Validators.h">
|
||||
<Filter>[2] Ripple %28New%29\validators\api</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -1764,10 +1790,10 @@
|
||||
<Filter>%28Notes%29</Filter>
|
||||
</None>
|
||||
<None Include="..\..\doc\rippled-example.cfg">
|
||||
<Filter>[2] doc</Filter>
|
||||
<Filter>[3] doc</Filter>
|
||||
</None>
|
||||
<None Include="..\..\doc\Doxyfile">
|
||||
<Filter>[2] doc</Filter>
|
||||
<Filter>[3] doc</Filter>
|
||||
</None>
|
||||
<None Include="..\..\SConstruct" />
|
||||
<None Include="..\QtCreator\rippled.pro" />
|
||||
|
||||
51
SConstruct
51
SConstruct
@@ -101,41 +101,56 @@ else:
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# VFALCO This is my oasis of sanity. Nothing having to do with directories,
|
||||
# source files, or include paths should reside outside the boundaries.
|
||||
# VFALCO NOTE Clean area.
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# Nothing having to do with directories, source files,
|
||||
# or include paths should reside outside the boundaries.
|
||||
#
|
||||
|
||||
# List of includes passed to the C++ compiler.
|
||||
# These are all relative to the repo dir.
|
||||
#
|
||||
INCLUDE_PATHS = [
|
||||
'.',
|
||||
'build/proto',
|
||||
'src',
|
||||
'src/leveldb',
|
||||
'src/leveldb/port',
|
||||
'src/leveldb/include',
|
||||
'src/beast',
|
||||
'build/proto'
|
||||
]
|
||||
|
||||
# if BOOST_HOME:
|
||||
# INCLUDE_PATHS.append(BOOST_HOME)
|
||||
|
||||
if OSX:
|
||||
COMPILED_FILES = [
|
||||
'src/beast/modules/beast_core/beast_core.mm'
|
||||
]
|
||||
else:
|
||||
COMPILED_FILES = [
|
||||
'src/beast/modules/beast_core/beast_core.cpp'
|
||||
]
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# Compiled sources
|
||||
#
|
||||
|
||||
COMPILED_FILES = []
|
||||
|
||||
# -------------------
|
||||
# Beast unity sources
|
||||
#
|
||||
COMPILED_FILES.extend([
|
||||
'src/beast/modules/beast_asio/beast_asio.cpp',
|
||||
'src/beast/modules/beast_crypto/beast_crypto.cpp',
|
||||
'src/beast/modules/beast_db/beast_db.cpp',
|
||||
'src/beast/modules/beast_sqdb/beast_sqdb.cpp',
|
||||
'src/beast/modules/beast_sqlite/beast_sqlite.c',
|
||||
'src/beast/modules/beast_sqlite/beast_sqlite.c'
|
||||
])
|
||||
if OSX:
|
||||
# OSX: Use the Objective C++ version of beast_core
|
||||
COMPILED_FILES.extend (['src/beast/modules/beast_core/beast_core.mm'])
|
||||
else:
|
||||
COMPILED_FILES.extend (['src/beast/modules/beast_core/beast_core.cpp'])
|
||||
|
||||
# ------------------------------
|
||||
# Old-style Ripple unity sources
|
||||
#
|
||||
COMPILED_FILES.extend([
|
||||
'src/ripple_app/ripple_app.cpp',
|
||||
'src/ripple_app/ripple_app_pt1.cpp',
|
||||
'src/ripple_app/ripple_app_pt2.cpp',
|
||||
@@ -155,6 +170,16 @@ COMPILED_FILES.extend([
|
||||
'src/ripple_websocket/ripple_websocket.cpp'
|
||||
])
|
||||
|
||||
# ------------------------------
|
||||
# New-style Ripple unity sources
|
||||
#
|
||||
COMPILED_FILES.extend([
|
||||
'src/ripple/testoverlay/ripple_testoverlay.cpp',
|
||||
'src/ripple/validators/ripple_validators.cpp'
|
||||
])
|
||||
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Map top level source directories to their location in the outputs
|
||||
|
||||
@@ -3,6 +3,7 @@ RIPPLE TODO
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Vinnie's List: Changes day to day, descending priority
|
||||
- Look into using CMake
|
||||
- Validators should delay the application of newly downloaded lists from
|
||||
sources, to mitigate the effects of attacks. Unless there's no validators
|
||||
in the list.
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_CONFIGTYPE_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_CONFIGTYPE_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_CONFIGTYPE_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_CONFIGTYPE_H_INCLUDED
|
||||
|
||||
/** A simulated peer to peer network for unit tests. */
|
||||
namespace TestOverlay
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_CONNECTIONTYPE_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_CONNECTIONTYPE_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_CONNECTIONTYPE_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_CONNECTIONTYPE_H_INCLUDED
|
||||
|
||||
namespace TestOverlay
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_INITPOLICY_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_INITPOLICY_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_INITPOLICY_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_INITPOLICY_H_INCLUDED
|
||||
|
||||
/** A simulated peer to peer network for unit tests. */
|
||||
namespace TestOverlay
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_MESSAGETYPE_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_MESSAGETYPE_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_MESSAGETYPE_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_MESSAGETYPE_H_INCLUDED
|
||||
|
||||
namespace TestOverlay
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_NETWORKTYPE_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_NETWORKTYPE_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_NETWORKTYPE_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_NETWORKTYPE_H_INCLUDED
|
||||
|
||||
namespace TestOverlay
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_PEERLOGICBASE_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_PEERLOGICBASE_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_PEERLOGICBASE_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_PEERLOGICBASE_H_INCLUDED
|
||||
|
||||
namespace TestOverlay
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_PEERTYPE_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_PEERTYPE_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_PEERTYPE_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_PEERTYPE_H_INCLUDED
|
||||
|
||||
namespace TestOverlay
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_RESULTS_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_RESULTS_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_RESULTS_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_RESULTS_H_INCLUDED
|
||||
|
||||
namespace TestOverlay
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_SIMPLEPAYLOAD_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_SIMPLEPAYLOAD_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_SIMPLEPAYLOAD_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_SIMPLEPAYLOAD_H_INCLUDED
|
||||
|
||||
namespace TestOverlay
|
||||
{
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_TEST_STATEBASE_H_INCLUDED
|
||||
#define RIPPLE_CORE_TEST_STATEBASE_H_INCLUDED
|
||||
#ifndef RIPPLE_TESTOVERLAY_STATEBASE_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_STATEBASE_H_INCLUDED
|
||||
|
||||
namespace TestOverlay
|
||||
{
|
||||
16
src/ripple/testoverlay/ripple_testoverlay.cpp
Normal file
16
src/ripple/testoverlay/ripple_testoverlay.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "ripple_testoverlay.h"
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
#include "impl/TestOverlay.cpp"
|
||||
|
||||
}
|
||||
43
src/ripple/testoverlay/ripple_testoverlay.h
Normal file
43
src/ripple/testoverlay/ripple_testoverlay.h
Normal file
@@ -0,0 +1,43 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_TESTOVERLAY_H_INCLUDED
|
||||
#define RIPPLE_TESTOVERLAY_H_INCLUDED
|
||||
|
||||
#include "beast/modules/beast_core/system/BeforeBoost.h" // must come first
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#include "beast/modules/beast_core/beast_core.h"
|
||||
|
||||
/** Provides a template based peer to peer network simulator.
|
||||
|
||||
A TestOverlay::Network simulates an entire peer to peer network.
|
||||
It provides peer connectivity and message passing services, while
|
||||
allowing domain specific customization through user provided types.
|
||||
|
||||
This system is designed to allow business logic to be exercised
|
||||
in unit tests, using a simulated large scale network.
|
||||
*/
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
using namespace beast;
|
||||
|
||||
# include "api/Results.h"
|
||||
# include "api/SimplePayload.h"
|
||||
# include "api/MessageType.h"
|
||||
# include "api/ConnectionType.h"
|
||||
# include "api/PeerType.h"
|
||||
# include "api/NetworkType.h"
|
||||
# include "api/StateBase.h"
|
||||
# include "api/PeerLogicBase.h"
|
||||
# include "api/InitPolicy.h"
|
||||
# include "api/ConfigType.h"
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
131
src/ripple/validators/api/Validators.h
Normal file
131
src/ripple/validators/api/Validators.h
Normal file
@@ -0,0 +1,131 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_VALIDATOR_VALIDATORS_H_INCLUDED
|
||||
#define RIPPLE_CORE_VALIDATOR_VALIDATORS_H_INCLUDED
|
||||
|
||||
/** Maintains the list of chosen validators.
|
||||
|
||||
The algorithm for acquiring, building, and calculating metadata on
|
||||
the list of chosen validators is critical to the health of the network.
|
||||
|
||||
All operations are performed asynchronously on an internal thread.
|
||||
*/
|
||||
class Validators : public Uncopyable
|
||||
{
|
||||
public:
|
||||
typedef RipplePublicKeyHash KeyType;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/** A source of validator descriptors. */
|
||||
class Source
|
||||
{
|
||||
public:
|
||||
/** A Source's descriptor for a Validator. */
|
||||
struct Info
|
||||
{
|
||||
/** The unique key for this validator. */
|
||||
KeyType key;
|
||||
};
|
||||
|
||||
/** Destroy the Source.
|
||||
This can be called from any thread. If the Source is busy
|
||||
fetching, the destructor must block until the operation is either
|
||||
canceled or complete.
|
||||
*/
|
||||
virtual ~Source () { }
|
||||
|
||||
struct CancelCallback
|
||||
{
|
||||
virtual bool shouldCancel () = 0;
|
||||
};
|
||||
|
||||
/** Fetch the most recent list from the Source.
|
||||
If possible, the Source should periodically poll the
|
||||
CancelCallback, and abort the operation if shouldCancel
|
||||
returns `true`.
|
||||
This call will block.
|
||||
*/
|
||||
struct Result
|
||||
{
|
||||
Result ();
|
||||
void swapWith (Result& other);
|
||||
|
||||
bool success;
|
||||
String message;
|
||||
Time expirationTime;
|
||||
Array <Info> list;
|
||||
};
|
||||
virtual Result fetch (CancelCallback& callback) = 0;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/** Create a new Validators object.
|
||||
*/
|
||||
static Validators* New ();
|
||||
|
||||
/** Destroy the object.
|
||||
|
||||
Any pending source fetch operations are aborted.
|
||||
|
||||
There may be some listener calls made before the
|
||||
destructor returns.
|
||||
*/
|
||||
virtual ~Validators () { }
|
||||
|
||||
/** Add a static source of validators from a string array. */
|
||||
/** @{ */
|
||||
virtual void addStrings (std::vector <std::string> const& strings) = 0;
|
||||
virtual void addStrings (StringArray const& stringArray) = 0;
|
||||
/** @} */
|
||||
|
||||
/** Add a static source of validators from a text file. */
|
||||
virtual void addFile (File const& file) = 0;
|
||||
|
||||
/** Add a static source of validators.
|
||||
The Source is called to fetch once and the results are kept
|
||||
permanently. The fetch is performed asynchronously, this call
|
||||
returns immediately. If the fetch fails, it is not reattempted.
|
||||
The caller loses ownership of the object.
|
||||
Thread safety:
|
||||
Can be called from any thread.
|
||||
*/
|
||||
virtual void addStaticSource (Source* source) = 0;
|
||||
|
||||
/** Add a live source of validators from a trusted URL.
|
||||
The URL will be contacted periodically to update the list.
|
||||
*/
|
||||
virtual void addURL (UniformResourceLocator const& url) = 0;
|
||||
|
||||
/** Add a live source of validators.
|
||||
The caller loses ownership of the object.
|
||||
Thread safety:
|
||||
Can be called from any thread.
|
||||
*/
|
||||
virtual void addSource (Source* source) = 0;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// Trusted Validators
|
||||
|
||||
//virtual bool isPublicKeyTrusted (Validator::PublicKey const&) = 0;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
struct ReceivedValidation
|
||||
{
|
||||
uint256 ledgerHash;
|
||||
RipplePublicKeyHash signerPublicKeyHash;
|
||||
};
|
||||
|
||||
/** Called when a validation with a proper signature is received.
|
||||
*/
|
||||
virtual void receiveValidation (ReceivedValidation const& rv) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
38
src/ripple/validators/impl/ValidatorSourceFile.cpp
Normal file
38
src/ripple/validators/impl/ValidatorSourceFile.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
class ValidatorSourceFileImp : public ValidatorSourceFile
|
||||
{
|
||||
public:
|
||||
ValidatorSourceFileImp (File const& file)
|
||||
: m_file (file)
|
||||
{
|
||||
}
|
||||
|
||||
~ValidatorSourceFileImp ()
|
||||
{
|
||||
}
|
||||
|
||||
Result fetch (CancelCallback&)
|
||||
{
|
||||
Result result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
File m_file;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
ValidatorSourceFile* ValidatorSourceFile::New (File const& file)
|
||||
{
|
||||
ScopedPointer <ValidatorSourceFile> object (
|
||||
new ValidatorSourceFileImp (file));
|
||||
|
||||
return object.release ();
|
||||
}
|
||||
19
src/ripple/validators/impl/ValidatorSourceFile.h
Normal file
19
src/ripple/validators/impl/ValidatorSourceFile.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_VALIDATOR_VALIDATORSOURCEFILE_H_INCLUDED
|
||||
#define RIPPLE_CORE_VALIDATOR_VALIDATORSOURCEFILE_H_INCLUDED
|
||||
|
||||
/** Provides validators from a text file.
|
||||
Typically this will come from a local configuration file.
|
||||
*/
|
||||
class ValidatorSourceFile : public Validators::Source
|
||||
{
|
||||
public:
|
||||
static ValidatorSourceFile* New (File const& path);
|
||||
};
|
||||
|
||||
#endif
|
||||
47
src/ripple/validators/impl/ValidatorSourceStrings.cpp
Normal file
47
src/ripple/validators/impl/ValidatorSourceStrings.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
class ValidatorSourceStringsImp : public ValidatorSourceStrings
|
||||
{
|
||||
public:
|
||||
ValidatorSourceStringsImp (StringArray const& strings)
|
||||
: m_strings (strings)
|
||||
{
|
||||
}
|
||||
|
||||
~ValidatorSourceStringsImp ()
|
||||
{
|
||||
}
|
||||
|
||||
Result fetch (CancelCallback&)
|
||||
{
|
||||
Result result;
|
||||
|
||||
result.list.ensureStorageAllocated (m_strings.size ());
|
||||
|
||||
for (int i = 0; i < m_strings.size (); ++i)
|
||||
{
|
||||
ValidatorsUtilities::parseResultLine (result, m_strings [i]);
|
||||
}
|
||||
|
||||
result.success = result.list.size () > 0;
|
||||
result.expirationTime = Time::getCurrentTime () + RelativeTime::hours (24);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
StringArray m_strings;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
ValidatorSourceStrings* ValidatorSourceStrings::New (StringArray const& strings)
|
||||
{
|
||||
ScopedPointer <ValidatorSourceStrings> object (
|
||||
new ValidatorSourceStringsImp (strings));
|
||||
|
||||
return object.release ();
|
||||
}
|
||||
19
src/ripple/validators/impl/ValidatorSourceStrings.h
Normal file
19
src/ripple/validators/impl/ValidatorSourceStrings.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_VALIDATOR_VALIDATORSOURCESTRINGS_H_INCLUDED
|
||||
#define RIPPLE_CORE_VALIDATOR_VALIDATORSOURCESTRINGS_H_INCLUDED
|
||||
|
||||
/** Provides validators from a set of Validator strings.
|
||||
Typically this will come from a local configuration file.
|
||||
*/
|
||||
class ValidatorSourceStrings : public Validators::Source
|
||||
{
|
||||
public:
|
||||
static ValidatorSourceStrings* New (StringArray const& strings);
|
||||
};
|
||||
|
||||
#endif
|
||||
48
src/ripple/validators/impl/ValidatorSourceURL.cpp
Normal file
48
src/ripple/validators/impl/ValidatorSourceURL.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
class ValidatorSourceURLImp : public ValidatorSourceURL
|
||||
{
|
||||
public:
|
||||
explicit ValidatorSourceURLImp (UniformResourceLocator const& url)
|
||||
: m_url (url)
|
||||
{
|
||||
}
|
||||
|
||||
~ValidatorSourceURLImp ()
|
||||
{
|
||||
}
|
||||
|
||||
Result fetch (CancelCallback&)
|
||||
{
|
||||
Result result;
|
||||
|
||||
ScopedPointer <HTTPClientBase> client (HTTPClientBase::New ());
|
||||
|
||||
HTTPClientBase::Result httpResult (client->get (m_url));
|
||||
|
||||
if (httpResult.error == 0)
|
||||
{
|
||||
Logger::outputDebugString (httpResult.response->toString ());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
UniformResourceLocator m_url;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
ValidatorSourceURL* ValidatorSourceURL::New (
|
||||
UniformResourceLocator const& url)
|
||||
{
|
||||
ScopedPointer <ValidatorSourceURL> object (
|
||||
new ValidatorSourceURLImp (url));
|
||||
|
||||
return object.release ();
|
||||
}
|
||||
18
src/ripple/validators/impl/ValidatorSourceURL.h
Normal file
18
src/ripple/validators/impl/ValidatorSourceURL.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_VALIDATOR_VALIDATORSOURCETRUSTEDURL_H_INCLUDED
|
||||
#define RIPPLE_CORE_VALIDATOR_VALIDATORSOURCETRUSTEDURL_H_INCLUDED
|
||||
|
||||
/** Provides validators from a trusted URI (e.g. HTTPS)
|
||||
*/
|
||||
class ValidatorSourceURL : public Validators::Source
|
||||
{
|
||||
public:
|
||||
static ValidatorSourceURL* New (UniformResourceLocator const& url);
|
||||
};
|
||||
|
||||
#endif
|
||||
733
src/ripple/validators/impl/Validators.cpp
Normal file
733
src/ripple/validators/impl/Validators.cpp
Normal file
@@ -0,0 +1,733 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
/*
|
||||
|
||||
Information to track:
|
||||
|
||||
- Percentage of validations that the validator has signed
|
||||
- Number of validations the validator signed that never got accepted
|
||||
|
||||
|
||||
- Target number for Chosen
|
||||
- Pseudo-randomly choose a subset from Chosen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Goal:
|
||||
|
||||
Provide the listener with a ValidatorList.
|
||||
- This forms the UNL
|
||||
|
||||
Task:
|
||||
|
||||
fetch ValidatorInfo array from a source
|
||||
|
||||
- We have the old one and the new one, compute the following:
|
||||
|
||||
* unchanged validators list
|
||||
* new validators list
|
||||
* removed validators list
|
||||
|
||||
- From the unchanged / new / removed, figure out what to do.
|
||||
|
||||
Two important questions:
|
||||
|
||||
- Are there any validators in my ChosenValidators that I dont want
|
||||
* For example, they have dropped off all the trusted lists
|
||||
|
||||
- Do I have enough?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
ChosenValidators
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
David:
|
||||
Maybe OC should have a URL that you can query to get the latest list of URI's
|
||||
for OC-approved organzations that publish lists of validators. The server and
|
||||
client can ship with that master trust URL and also the list of URI's at the
|
||||
time it's released, in case for some reason it can't pull from OC. That would
|
||||
make the default installation safe even against major changes in the
|
||||
organizations that publish validator lists.
|
||||
|
||||
The difference is that if an organization that provides lists of validators
|
||||
goes rogue, administrators don't have to act.
|
||||
|
||||
TODO:
|
||||
Write up from end-user perspective on the deployment and administration
|
||||
of this feature, on the wiki. "DRAFT" or "PROPOSE" to mark it as provisional.
|
||||
Template: https://ripple.com/wiki/Federation_protocol
|
||||
- What to do if you're a publisher of ValidatorList
|
||||
- What to do if you're a rippled administrator
|
||||
- Overview of how ChosenValidators works
|
||||
|
||||
Goals:
|
||||
Make default configuration of rippled secure.
|
||||
* Ship with TrustedUriList
|
||||
* Also have a preset RankedValidators
|
||||
Eliminate administrative burden of maintaining
|
||||
Produce the ChosenValidators list.
|
||||
Allow quantitative analysis of network health.
|
||||
|
||||
What determines that a validator is good?
|
||||
- Are they present (i.e. sending validations)
|
||||
- Are they on the consensus ledger
|
||||
- What percentage of consensus rounds do they participate in
|
||||
- Are they stalling consensus
|
||||
* Measurements of constructive/destructive behavior is
|
||||
calculated in units of percentage of ledgers for which
|
||||
the behavior is measured.
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Validators::Source::Result::Result ()
|
||||
: success (false)
|
||||
, message ("uninitialized")
|
||||
{
|
||||
}
|
||||
|
||||
void Validators::Source::Result::swapWith (Result& other)
|
||||
{
|
||||
std::swap (success, other.success);
|
||||
std::swap (message, other.message);
|
||||
list.swapWith (other.list);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class ValidatorsImp
|
||||
: public Validators
|
||||
, private ThreadWithCallQueue::EntryPoints
|
||||
, private DeadlineTimer::Listener
|
||||
, LeakChecked <ValidatorsImp>
|
||||
{
|
||||
public:
|
||||
// Tunable constants
|
||||
enum
|
||||
{
|
||||
// We will fetch a source at this interval
|
||||
hoursBetweenFetches = 24
|
||||
|
||||
,secondsBetweenFetches = hoursBetweenFetches * 60 * 60
|
||||
|
||||
// Wake up every hour to check source times
|
||||
,secondsPerUpdate = 60 * 60
|
||||
|
||||
// This tunes the preallocated arrays
|
||||
,expectedNumberOfResults = 1000
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// Dummy CancelCallback that does nothing
|
||||
//
|
||||
struct NoOpCancelCallback : Source::CancelCallback
|
||||
{
|
||||
bool shouldCancel ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/** Receive event notifications on Validators operations.
|
||||
*/
|
||||
class Listener
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
class ChosenList : public SharedObject
|
||||
{
|
||||
public:
|
||||
typedef SharedPtr <ChosenList> Ptr;
|
||||
|
||||
struct Info
|
||||
{
|
||||
Info ()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//typedef HashMap <KeyType, Info, KeyType::HashFunction> MapType;
|
||||
typedef boost::unordered_map <KeyType, Info, KeyType::HashFunction> MapType;
|
||||
|
||||
ChosenList (std::size_t expectedSize = 0)
|
||||
{
|
||||
// Available only in recent boost versions?
|
||||
//m_map.reserve (expectedSize);
|
||||
}
|
||||
|
||||
std::size_t size () const noexcept
|
||||
{
|
||||
return m_map.size ();
|
||||
}
|
||||
|
||||
void insert (KeyType const& key, Info const& info) noexcept
|
||||
{
|
||||
m_map [key] = info;
|
||||
}
|
||||
|
||||
bool contains (KeyType const& key) const noexcept
|
||||
{
|
||||
return m_map.find (key) != m_map.cend ();
|
||||
}
|
||||
|
||||
private:
|
||||
MapType m_map;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
// Encapsulates the logic for creating the chosen validators.
|
||||
// This is a separate class to facilitate the unit tests.
|
||||
//
|
||||
class Logic
|
||||
{
|
||||
public:
|
||||
// Information associated with each Source
|
||||
//
|
||||
struct SourceDesc
|
||||
{
|
||||
enum
|
||||
{
|
||||
keysPreallocationSize = 1000
|
||||
};
|
||||
|
||||
enum Status
|
||||
{
|
||||
statusNone,
|
||||
statusFetched,
|
||||
statusFailed
|
||||
};
|
||||
|
||||
ScopedPointer <Source> source;
|
||||
Status status;
|
||||
Time whenToFetch;
|
||||
int numberOfFailures;
|
||||
|
||||
// The result of the last fetch
|
||||
Source::Result result;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
SourceDesc () noexcept
|
||||
: status (statusNone)
|
||||
, whenToFetch (Time::getCurrentTime ())
|
||||
, numberOfFailures (0)
|
||||
{
|
||||
}
|
||||
|
||||
~SourceDesc ()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef DynamicList <SourceDesc> SourcesType;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Information associated with each distinguishable validator
|
||||
//
|
||||
struct ValidatorInfo
|
||||
{
|
||||
ValidatorInfo ()
|
||||
: refCount (0)
|
||||
{
|
||||
}
|
||||
|
||||
int refCount;
|
||||
};
|
||||
|
||||
//typedef HashMap <KeyType, ValidatorInfo, KeyType::HashFunction> MapType;
|
||||
typedef boost::unordered_map <KeyType, ValidatorInfo, KeyType::HashFunction> MapType;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Logic ()
|
||||
: m_chosenListNeedsUpdate (false)
|
||||
{
|
||||
}
|
||||
|
||||
// Add a one-time static source.
|
||||
// Fetch is called right away, this call blocks.
|
||||
//
|
||||
void addStaticSource (Source* source)
|
||||
{
|
||||
ScopedPointer <Source> object (source);
|
||||
|
||||
NoOpCancelCallback cancelCallback;
|
||||
|
||||
Source::Result result (object->fetch (cancelCallback));
|
||||
|
||||
if (result.success)
|
||||
{
|
||||
addSourceInfo (result.list);
|
||||
}
|
||||
else
|
||||
{
|
||||
// VFALCO NOTE Maybe log the error and message?
|
||||
}
|
||||
}
|
||||
|
||||
// Add a live source to the list of sources.
|
||||
//
|
||||
void addSource (Source* source)
|
||||
{
|
||||
SourceDesc& desc (*m_sources.emplace_back ());
|
||||
desc.source = source;
|
||||
}
|
||||
|
||||
// Called when we receive a validation from a peer.
|
||||
//
|
||||
void receiveValidation (Validators::ReceivedValidation const& rv)
|
||||
{
|
||||
MapType::iterator iter (m_map.find (rv.signerPublicKeyHash));
|
||||
if (iter != m_map.end ())
|
||||
{
|
||||
// Exists
|
||||
//ValidatorInfo& validatorInfo (iter->value ());
|
||||
}
|
||||
else
|
||||
{
|
||||
// New
|
||||
//ValidatorInfo& validatorInfo (m_map.insert (rv.signerPublicKeyHash));
|
||||
}
|
||||
}
|
||||
|
||||
// Add each entry in the list to the map, incrementing the
|
||||
// reference count if it already exists, and updating fields.
|
||||
//
|
||||
void addSourceInfo (Array <Source::Info> const& list)
|
||||
{
|
||||
for (std::size_t i = 0; i < list.size (); ++i)
|
||||
{
|
||||
Source::Info const& info (list.getReference (i));
|
||||
std::pair <MapType::iterator, bool> result (
|
||||
m_map.emplace (info.key, ValidatorInfo ()));
|
||||
ValidatorInfo& validatorInfo (result.first->second);
|
||||
++validatorInfo.refCount;
|
||||
if (result.second)
|
||||
{
|
||||
// This is a new one
|
||||
markDirtyChosenList ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decrement the reference count of each item in the list
|
||||
// in the map
|
||||
//
|
||||
void removeSourceInfo (Array <Source::Info> const& list)
|
||||
{
|
||||
for (std::size_t i = 0; i < list.size (); ++i)
|
||||
{
|
||||
Source::Info const& info (list.getReference (i));
|
||||
MapType::iterator iter (m_map.find (info.key));
|
||||
bassert (iter != m_map.end ());
|
||||
ValidatorInfo& validatorInfo (iter->second);
|
||||
if (--validatorInfo.refCount == 0)
|
||||
{
|
||||
// Last reference removed
|
||||
m_map.erase (iter);
|
||||
markDirtyChosenList ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch one source
|
||||
//
|
||||
void fetchSource (SourceDesc& desc, Source::CancelCallback& callback)
|
||||
{
|
||||
Source::Result result (desc.source->fetch (callback));
|
||||
|
||||
if (! callback.shouldCancel ())
|
||||
{
|
||||
// Reset fetch timer for the source.
|
||||
desc.whenToFetch = Time::getCurrentTime () +
|
||||
RelativeTime (secondsBetweenFetches);
|
||||
|
||||
if (result.success)
|
||||
{
|
||||
// Add the new source info to the map
|
||||
addSourceInfo (result.list);
|
||||
|
||||
// Swap lists
|
||||
desc.result.swapWith (result);
|
||||
|
||||
// Remove the old source info from the map
|
||||
removeSourceInfo (result.list);
|
||||
|
||||
// See if we need to rebuild
|
||||
checkDirtyChosenList ();
|
||||
|
||||
// Reset failure status
|
||||
desc.numberOfFailures = 0;
|
||||
desc.status = SourceDesc::statusFetched;
|
||||
}
|
||||
else
|
||||
{
|
||||
++desc.numberOfFailures;
|
||||
desc.status = SourceDesc::statusFailed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check each source to see if it needs fetching.
|
||||
//
|
||||
void checkSources (Source::CancelCallback& callback)
|
||||
{
|
||||
Time const currentTime (Time::getCurrentTime ());
|
||||
for (SourcesType::iterator iter = m_sources.begin ();
|
||||
! callback.shouldCancel () && iter != m_sources.end (); ++iter)
|
||||
{
|
||||
SourceDesc& desc (*iter);
|
||||
if (desc.whenToFetch <= currentTime)
|
||||
fetchSource (desc, callback);
|
||||
}
|
||||
}
|
||||
|
||||
// Signal that the Chosen List needs to be rebuilt.
|
||||
//
|
||||
void markDirtyChosenList ()
|
||||
{
|
||||
m_chosenListNeedsUpdate = true;
|
||||
}
|
||||
|
||||
// Check the dirty state of the Chosen List, and rebuild it
|
||||
// if necessary.
|
||||
//
|
||||
void checkDirtyChosenList ()
|
||||
{
|
||||
if (m_chosenListNeedsUpdate)
|
||||
{
|
||||
buildChosenList ();
|
||||
m_chosenListNeedsUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuilds the Chosen List
|
||||
//
|
||||
void buildChosenList ()
|
||||
{
|
||||
ChosenList::Ptr list (new ChosenList (m_map.size ()));
|
||||
|
||||
for (MapType::iterator iter = m_map.begin ();
|
||||
iter != m_map.end (); ++iter)
|
||||
{
|
||||
ChosenList::Info info;
|
||||
list->insert (iter->first, info);
|
||||
}
|
||||
|
||||
// This is thread safe
|
||||
m_chosenList = list;
|
||||
}
|
||||
|
||||
// Get a reference to the chosen list.
|
||||
// This is safe to call from any thread at any time.
|
||||
//
|
||||
ChosenList::Ptr getChosenList ()
|
||||
{
|
||||
return m_chosenList;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Ripple interface
|
||||
//
|
||||
// These routines are modeled after UniqueNodeList
|
||||
|
||||
bool isTrustedPublicKeyHash (RipplePublicKeyHash const& key)
|
||||
{
|
||||
return m_chosenList->contains (key);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
private:
|
||||
SourcesType m_sources;
|
||||
MapType m_map;
|
||||
bool m_chosenListNeedsUpdate;
|
||||
ChosenList::Ptr m_chosenList;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
public:
|
||||
explicit ValidatorsImp (Listener* listener)
|
||||
: m_listener (listener)
|
||||
, m_thread ("Validators")
|
||||
, m_timer (this)
|
||||
{
|
||||
m_thread.start (this);
|
||||
}
|
||||
|
||||
~ValidatorsImp ()
|
||||
{
|
||||
}
|
||||
|
||||
void addStrings (std::vector <std::string> const& strings)
|
||||
{
|
||||
StringArray stringArray;
|
||||
stringArray.ensureStorageAllocated (strings.size());
|
||||
for (std::size_t i = 0; i < strings.size(); ++i)
|
||||
stringArray.add (strings [i]);
|
||||
addStrings (stringArray);
|
||||
}
|
||||
|
||||
void addStrings (StringArray const& stringArray)
|
||||
{
|
||||
addStaticSource (
|
||||
ValidatorSourceStrings::New (stringArray));
|
||||
}
|
||||
|
||||
void addFile (File const& file)
|
||||
{
|
||||
addStaticSource (ValidatorSourceFile::New (file));
|
||||
}
|
||||
|
||||
void addURL (UniformResourceLocator const& url)
|
||||
{
|
||||
addSource (ValidatorSourceURL::New (url));
|
||||
}
|
||||
|
||||
void addSource (Source* source)
|
||||
{
|
||||
m_thread.call (&Logic::addSource, &m_logic, source);
|
||||
}
|
||||
|
||||
void addStaticSource (Source* source)
|
||||
{
|
||||
m_thread.call (&Logic::addStaticSource, &m_logic, source);
|
||||
}
|
||||
|
||||
void receiveValidation (ReceivedValidation const& rv)
|
||||
{
|
||||
m_thread.call (&Logic::receiveValidation, &m_logic, rv);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void onDeadlineTimer (DeadlineTimer&)
|
||||
{
|
||||
// This will make us fall into the idle proc as needed
|
||||
//
|
||||
m_thread.interrupt ();
|
||||
}
|
||||
|
||||
void threadInit ()
|
||||
{
|
||||
m_timer.setRecurringExpiration (secondsPerUpdate);
|
||||
}
|
||||
|
||||
void threadExit ()
|
||||
{
|
||||
}
|
||||
|
||||
bool threadIdle ()
|
||||
{
|
||||
bool interrupted = false;
|
||||
|
||||
struct ThreadCancelCallback : Source::CancelCallback, Uncopyable
|
||||
{
|
||||
explicit ThreadCancelCallback (ThreadWithCallQueue& thread)
|
||||
: m_thread (thread)
|
||||
, m_interrupted (false)
|
||||
{
|
||||
}
|
||||
|
||||
bool shouldCancel ()
|
||||
{
|
||||
if (m_interrupted)
|
||||
return true;
|
||||
return m_interrupted = m_thread.interruptionPoint ();
|
||||
}
|
||||
|
||||
private:
|
||||
ThreadWithCallQueue& m_thread;
|
||||
bool m_interrupted;
|
||||
};
|
||||
|
||||
ThreadCancelCallback cancelCallback (m_thread);
|
||||
|
||||
m_logic.checkSources (cancelCallback);
|
||||
|
||||
return interrupted;
|
||||
}
|
||||
|
||||
private:
|
||||
Logic m_logic;
|
||||
Listener* const m_listener;
|
||||
ThreadWithCallQueue m_thread;
|
||||
DeadlineTimer m_timer;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Validators* Validators::New ()
|
||||
{
|
||||
return new ValidatorsImp (nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class ValidatorsTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
numberOfTestValidators = 1000
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
struct Payload
|
||||
{
|
||||
Payload ()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <class Config>
|
||||
class PeerLogic : public TestOverlay::PeerLogicBase <Config>
|
||||
{
|
||||
public:
|
||||
typedef TestOverlay::PeerLogicBase <Config> Base;
|
||||
typedef typename Config::Payload Payload;
|
||||
typedef typename Base::Connection Connection;
|
||||
typedef typename Base::Peer Peer;
|
||||
typedef typename Base::Message Message;
|
||||
typedef typename Config::SizeType SizeType;
|
||||
|
||||
explicit PeerLogic (Peer& peer)
|
||||
: TestOverlay::PeerLogicBase <Config> (peer)
|
||||
{
|
||||
}
|
||||
|
||||
~PeerLogic ()
|
||||
{
|
||||
}
|
||||
|
||||
void step ()
|
||||
{
|
||||
if (this->peer().id () == 1)
|
||||
{
|
||||
if (this->peer().network().steps() == 0)
|
||||
{
|
||||
this->peer().network().state().increment();
|
||||
this->peer().send_all (Payload (1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void receive (Connection const& c, Message const& m)
|
||||
{
|
||||
if (this->peer().id () != 1)
|
||||
{
|
||||
this->peer().network().state().increment();
|
||||
this->peer().send_all_if (Message (m.id(),
|
||||
m.payload().withHop ()),
|
||||
typename Connection::IsNotPeer (c.peer()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct Params : TestOverlay::ConfigType <
|
||||
Params,
|
||||
TestOverlay::StateBase,
|
||||
PeerLogic
|
||||
>
|
||||
{
|
||||
typedef TestOverlay::PremadeInitPolicy <250, 3> InitPolicy;
|
||||
};
|
||||
|
||||
typedef Params::Network Network;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
struct TestSource : Validators::Source
|
||||
{
|
||||
TestSource (String const& name, uint32 start, uint32 end)
|
||||
: m_name (name)
|
||||
, m_start (start)
|
||||
, m_end (end)
|
||||
{
|
||||
}
|
||||
|
||||
Result fetch (CancelCallback& cancel)
|
||||
{
|
||||
Result result;
|
||||
|
||||
result.success = true;
|
||||
result.message = String::empty;
|
||||
result.list.ensureStorageAllocated (numberOfTestValidators);
|
||||
|
||||
for (uint32 i = m_start ; i < m_end; ++i)
|
||||
{
|
||||
Info info;
|
||||
info.key = Validators::KeyType::createFromInteger (i);
|
||||
result.list.add (info);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String m_name;
|
||||
std::size_t m_start;
|
||||
std::size_t m_end;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void addSources (ValidatorsImp::Logic& logic)
|
||||
{
|
||||
#if 0
|
||||
logic.addSource (new TestSource ("source 1", 0, 1000));
|
||||
logic.addSource (new TestSource ("source 2", 200, 1500));
|
||||
logic.addSource (new TestSource ("source 3", 500, 2000));
|
||||
logic.addSource (new TestSource ("source 4", 750, 2200));
|
||||
logic.addSource (new TestSource ("source 5", 1500, 3200));
|
||||
#else
|
||||
logic.addSource (new TestSource ("source 1", 0, 1));
|
||||
#endif
|
||||
}
|
||||
|
||||
void testLogic ()
|
||||
{
|
||||
beginTestCase ("logic");
|
||||
|
||||
ValidatorsImp::Logic logic;
|
||||
addSources (logic);
|
||||
|
||||
ValidatorsImp::NoOpCancelCallback cancelCallback;
|
||||
logic.checkSources (cancelCallback);
|
||||
|
||||
ValidatorsImp::ChosenList::Ptr list (logic.getChosenList ());
|
||||
|
||||
pass ();
|
||||
}
|
||||
|
||||
void runTest ()
|
||||
{
|
||||
testLogic ();
|
||||
}
|
||||
|
||||
ValidatorsTests () : UnitTest ("Validators", "ripple", runManual)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
static ValidatorsTests validatorsTests;
|
||||
|
||||
30
src/ripple/validators/impl/ValidatorsUtilities.cpp
Normal file
30
src/ripple/validators/impl/ValidatorsUtilities.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
bool ValidatorsUtilities::parseInfoLine (Validators::Source::Info& info, String line)
|
||||
{
|
||||
bool success (false);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void ValidatorsUtilities::parseResultLine (
|
||||
Validators::Source::Result& result,
|
||||
String line)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (! success)
|
||||
{
|
||||
Validators::Source::Info info;
|
||||
|
||||
success = parseInfoLine (info, line);
|
||||
if (success)
|
||||
result.list.add (info);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
52
src/ripple/validators/impl/ValidatorsUtilities.h
Normal file
52
src/ripple/validators/impl/ValidatorsUtilities.h
Normal file
@@ -0,0 +1,52 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_CORE_VALIDATORSUTILITIES_H_INCLUDED
|
||||
#define RIPPLE_CORE_VALIDATORSUTILITIES_H_INCLUDED
|
||||
|
||||
/** Common code for Validators classes.
|
||||
*/
|
||||
class ValidatorsUtilities
|
||||
{
|
||||
public:
|
||||
typedef std::vector <std::string> Strings;
|
||||
|
||||
#if 0
|
||||
/** Parse a ConstBufferSequence of newline delimited text into strings.
|
||||
This works incrementally.
|
||||
*/
|
||||
template <typename ConstBufferSequence>
|
||||
static void parseLines (Strings& lines, ConstBufferSequence const& buffers)
|
||||
{
|
||||
for (typename ConstBufferSequence::const_iterator iter = buffers.begin ();
|
||||
iter != buffers.end (); ++iter)
|
||||
parserLines (lines, *iter);
|
||||
}
|
||||
|
||||
/** Turn a linear buffer of newline delimited text into strings.
|
||||
This can be called incrementally, i.e. successive calls with
|
||||
multiple buffer segments.
|
||||
*/
|
||||
static void parseLines (Strings& lines, char const* buf, std::size_t bytes);
|
||||
#endif
|
||||
|
||||
/** Parse a string into the Source::Result.
|
||||
Invalid or comment lines will be skipped.
|
||||
Lines containing validator info will be added to the Result object.
|
||||
Metadata lines will update the corresponding Result fields.
|
||||
*/
|
||||
static void parseResultLine (
|
||||
Validators::Source::Result& result,
|
||||
String line);
|
||||
|
||||
private:
|
||||
/** Parse a string into a Source::Info.
|
||||
@return `true` on success.
|
||||
*/
|
||||
static bool parseInfoLine (Validators::Source::Info& info, String line);
|
||||
};
|
||||
|
||||
#endif
|
||||
32
src/ripple/validators/ripple_validators.cpp
Normal file
32
src/ripple/validators/ripple_validators.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "BeastConfig.h"
|
||||
|
||||
#include "ripple_validators.h"
|
||||
|
||||
#include "beast/modules/beast_core/system/BeforeBoost.h" // must come first
|
||||
//#include <boost/algorithm/string.hpp>
|
||||
//#include <boost/foreach.hpp>
|
||||
//#include <boost/unordered_map.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
|
||||
#include "../testoverlay/ripple_testoverlay.h" // for unit test
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
# include "impl/ValidatorsUtilities.h"
|
||||
#include "impl/ValidatorsUtilities.cpp"
|
||||
# include "impl/ValidatorSourceFile.h"
|
||||
# include "impl/ValidatorSourceStrings.h"
|
||||
# include "impl/ValidatorSourceURL.h"
|
||||
#include "impl/ValidatorSourceFile.cpp"
|
||||
#include "impl/ValidatorSourceStrings.cpp"
|
||||
#include "impl/ValidatorSourceURL.cpp"
|
||||
#include "impl/Validators.cpp"
|
||||
|
||||
}
|
||||
32
src/ripple/validators/ripple_validators.h
Normal file
32
src/ripple/validators/ripple_validators.h
Normal file
@@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_VALIDATORS_H_INCLUDED
|
||||
#define RIPPLE_VALIDATORS_H_INCLUDED
|
||||
|
||||
// VFALCO TODO Remove buffers/beast_asio dependency
|
||||
//
|
||||
// VFALCO NOTE It is unfortunate that we are exposing boost/asio.hpp
|
||||
// needlessly. Its only required because of the buffers types.
|
||||
// The HTTPClient interface doesn't need asio (although the
|
||||
// implementation does. This is also required for
|
||||
// UniformResourceLocator.
|
||||
//
|
||||
#include "beast/modules/beast_asio/beast_asio.h"
|
||||
|
||||
#include "../ripple_basics/ripple_basics.h"
|
||||
#include "../ripple_data/ripple_data.h"
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
using namespace beast;
|
||||
|
||||
#include "api/Validators.h"
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -20,6 +20,8 @@
|
||||
// This .cpp will end up including all of the public header
|
||||
// material in Ripple since it holds the Application object.
|
||||
|
||||
#include "../ripple/validators/ripple_validators.h"
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "ripple_app.h"
|
||||
#include "../ripple_net/ripple_net.h"
|
||||
|
||||
#include "../ripple/validators/ripple_validators.h"
|
||||
|
||||
namespace ripple
|
||||
{
|
||||
|
||||
|
||||
@@ -51,29 +51,6 @@ namespace ripple
|
||||
#include "node/NodeStore.cpp"
|
||||
#include "node/NodeObject.cpp"
|
||||
|
||||
# include "test/Results.h"
|
||||
# include "test/SimplePayload.h"
|
||||
# include "test/MessageType.h"
|
||||
# include "test/ConnectionType.h"
|
||||
# include "test/PeerType.h"
|
||||
# include "test/NetworkType.h"
|
||||
# include "test/StateBase.h"
|
||||
# include "test/PeerLogicBase.h"
|
||||
# include "test/InitPolicy.h"
|
||||
# include "test/ConfigType.h"
|
||||
#include "test/TestOverlay.cpp"
|
||||
|
||||
# include "validator/ValidatorsUtilities.h"
|
||||
#include "validator/ValidatorsUtilities.cpp"
|
||||
# include "validator/ValidatorSourceFile.h"
|
||||
# include "validator/ValidatorSourceStrings.h"
|
||||
# include "validator/ValidatorSourceURL.h"
|
||||
# include "validator/ValidatorsImp.h"
|
||||
#include "validator/ValidatorSourceFile.cpp"
|
||||
#include "validator/ValidatorSourceStrings.cpp"
|
||||
#include "validator/ValidatorSourceURL.cpp"
|
||||
#include "validator/Validators.cpp"
|
||||
|
||||
#include "peerfinder/ripple_PeerFinder.cpp"
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace ripple
|
||||
#include "node/NodeStore.h"
|
||||
|
||||
#include "peerfinder/ripple_PeerFinder.h"
|
||||
#include "validator/Validators.h"
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user