Skip to content

Commit

Permalink
Stub in chaser_populate.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jun 27, 2024
1 parent 0b4d160 commit ea6caf5
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ src_libbitcoin_node_la_SOURCES = \
src/chasers/chaser_check.cpp \
src/chasers/chaser_confirm.cpp \
src/chasers/chaser_header.cpp \
src/chasers/chaser_populate.cpp \
src/chasers/chaser_snapshot.cpp \
src/chasers/chaser_storage.cpp \
src/chasers/chaser_template.cpp \
Expand Down Expand Up @@ -89,6 +90,7 @@ test_libbitcoin_node_test_SOURCES = \
test/chasers/chaser_check.cpp \
test/chasers/chaser_confirm.cpp \
test/chasers/chaser_header.cpp \
test/chasers/chaser_populate.cpp \
test/chasers/chaser_template.cpp \
test/chasers/chaser_transaction.cpp \
test/chasers/chaser_validate.cpp \
Expand Down Expand Up @@ -140,6 +142,7 @@ include_bitcoin_node_chasers_HEADERS = \
include/bitcoin/node/chasers/chaser_confirm.hpp \
include/bitcoin/node/chasers/chaser_header.hpp \
include/bitcoin/node/chasers/chaser_organize.hpp \
include/bitcoin/node/chasers/chaser_populate.hpp \
include/bitcoin/node/chasers/chaser_snapshot.hpp \
include/bitcoin/node/chasers/chaser_storage.hpp \
include/bitcoin/node/chasers/chaser_template.hpp \
Expand Down
2 changes: 2 additions & 0 deletions builds/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ add_library( ${CANONICAL_LIB_NAME}
"../../src/chasers/chaser_check.cpp"
"../../src/chasers/chaser_confirm.cpp"
"../../src/chasers/chaser_header.cpp"
"../../src/chasers/chaser_populate.cpp"
"../../src/chasers/chaser_snapshot.cpp"
"../../src/chasers/chaser_storage.cpp"
"../../src/chasers/chaser_template.cpp"
Expand Down Expand Up @@ -329,6 +330,7 @@ if (with-tests)
"../../test/chasers/chaser_check.cpp"
"../../test/chasers/chaser_confirm.cpp"
"../../test/chasers/chaser_header.cpp"
"../../test/chasers/chaser_populate.cpp"
"../../test/chasers/chaser_template.cpp"
"../../test/chasers/chaser_transaction.cpp"
"../../test/chasers/chaser_validate.cpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<ClCompile Include="..\..\..\..\test\chasers\chaser_check.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_confirm.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_header.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_populate.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_template.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_transaction.cpp" />
<ClCompile Include="..\..\..\..\test\chasers\chaser_validate.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<ClCompile Include="..\..\..\..\test\chasers\chaser_header.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\chasers\chaser_populate.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\chasers\chaser_template.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
Expand Down
2 changes: 2 additions & 0 deletions builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<ClCompile Include="..\..\..\..\src\chasers\chaser_check.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_confirm.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_header.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_populate.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_snapshot.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_storage.cpp" />
<ClCompile Include="..\..\..\..\src\chasers\chaser_template.cpp" />
Expand Down Expand Up @@ -114,6 +115,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_confirm.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_header.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_organize.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_populate.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_snapshot.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_storage.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_template.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
<ClCompile Include="..\..\..\..\src\chasers\chaser_header.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\chasers\chaser_populate.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\chasers\chaser_snapshot.cpp">
<Filter>src\chasers</Filter>
</ClCompile>
Expand Down Expand Up @@ -167,6 +170,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_organize.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_populate.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser_snapshot.hpp">
<Filter>include\bitcoin\node\chasers</Filter>
</ClInclude>
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <bitcoin/node/chasers/chaser_confirm.hpp>
#include <bitcoin/node/chasers/chaser_header.hpp>
#include <bitcoin/node/chasers/chaser_organize.hpp>
#include <bitcoin/node/chasers/chaser_populate.hpp>
#include <bitcoin/node/chasers/chaser_snapshot.hpp>
#include <bitcoin/node/chasers/chaser_storage.hpp>
#include <bitcoin/node/chasers/chaser_template.hpp>
Expand Down
55 changes: 55 additions & 0 deletions include/bitcoin/node/chasers/chaser_populate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBITCOIN_NODE_CHASERS_CHASER_POPULATE_HPP
#define LIBBITCOIN_NODE_CHASERS_CHASER_POPULATE_HPP

#include <bitcoin/node/chasers/chaser.hpp>
#include <bitcoin/node/define.hpp>

namespace libbitcoin {
namespace node {

class full_node;

/// Order and populate downloaded non-bypass blocks for validation.
class BCN_API chaser_populate
: public chaser
{
public:
DELETE_COPY_MOVE_DESTRUCT(chaser_populate);

chaser_populate(full_node& node) NOEXCEPT;

/// Initialize chaser state.
code start() NOEXCEPT override;

protected:
virtual bool handle_event(const code& ec, chase event_,
event_value value) NOEXCEPT;

virtual void do_checked(height_t height) NOEXCEPT;

private:
// TODO:
};

} // namespace node
} // namespace libbitcoin

#endif
3 changes: 2 additions & 1 deletion include/bitcoin/node/chasers/chasers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
#include <bitcoin/node/chasers/chaser_confirm.hpp>
#include <bitcoin/node/chasers/chaser_header.hpp>
#include <bitcoin/node/chasers/chaser_organize.hpp>
#include <bitcoin/node/chasers/chaser_validate.hpp>
#include <bitcoin/node/chasers/chaser_populate.hpp>
#include <bitcoin/node/chasers/chaser_snapshot.hpp>
#include <bitcoin/node/chasers/chaser_storage.hpp>
#include <bitcoin/node/chasers/chaser_template.hpp>
#include <bitcoin/node/chasers/chaser_transaction.hpp>
#include <bitcoin/node/chasers/chaser_validate.hpp>

#endif
92 changes: 92 additions & 0 deletions src/chasers/chaser_populate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* Copyright (c) 2011-2024 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <bitcoin/node/chasers/chaser_populate.hpp>

#include <bitcoin/database.hpp>
#include <bitcoin/node/chasers/chaser.hpp>
#include <bitcoin/node/define.hpp>
#include <bitcoin/node/full_node.hpp>

namespace libbitcoin {
namespace node {

#define CLASS chaser_populate

////using namespace system;
////using namespace system::chain;
////using namespace database;
////using namespace network;
using namespace std::placeholders;

////// Shared pointers required for lifetime in handler parameters.
////BC_PUSH_WARNING(NO_VALUE_OR_CONST_REF_SHARED_PTR)
////BC_PUSH_WARNING(SMART_PTR_NOT_NEEDED)
////BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

chaser_populate::chaser_populate(full_node& node) NOEXCEPT
: chaser(node)
{
}

// start/stop
// ----------------------------------------------------------------------------

code chaser_populate::start() NOEXCEPT
{
SUBSCRIBE_EVENTS(handle_event, _1, _2, _3);
return error::success;
}

bool chaser_populate::handle_event(const code&, chase event_,
event_value value) NOEXCEPT
{
if (closed())
return false;

switch (event_)
{
case chase::checked:
{
POST(do_checked, height_t{});
break;
}
case chase::stop:
{
return false;
}
default:
{
break;
}
}

return true;
}

void chaser_populate::do_checked(height_t) NOEXCEPT
{
BC_ASSERT(stranded());
}

////BC_POP_WARNING()
////BC_POP_WARNING()
////BC_POP_WARNING()

} // namespace node
} // namespace libbitcoin
28 changes: 28 additions & 0 deletions test/chasers/chaser_populate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
*
* This file is part of libbitcoin.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../test.hpp"

BOOST_AUTO_TEST_SUITE(chaser_populate_tests)

BOOST_AUTO_TEST_CASE(chaser_populate_test)
{
BOOST_REQUIRE(true);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit ea6caf5

Please sign in to comment.