Skip to content

Commit 43a6950

Browse files
authored
Feature: synchronizing and networking modules (#30)
* update: adopt SubscriptionEngine Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * update: scale Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * feature: configurable base and module paths Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> # Conflicts: # src/executable/jam_node.cpp * update: qtils * feature: jam_types * refactor: bases of loader and module (no compilable yet) Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> # The commit message #2 will be skipped: # + base # # Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * update: example module Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * feature: networking module Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> # Conflicts: # src/modules/CMakeLists.txt # src/se/subscription_fwd.hpp * feature: synchronizer module Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * tmp: temporary disable safrole tests * fix: review issue * refactor: app configuration Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> --------- Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
1 parent 2e7904b commit 43a6950

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1484
-358
lines changed

example/config.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
general:
22
name: NameFromConfig
3+
base_path: /tmp/jam_node
4+
modules_dir: modules
35

46
metrics:
57
enabled: true
@@ -17,11 +19,16 @@ logging:
1719
groups:
1820
- name: main
1921
sink: console
20-
level: info
22+
level: trace
2123
is_fallback: true
2224
children:
2325
- name: jam
2426
children:
27+
- name: modules
28+
children:
29+
- name: example_module
30+
- name: synchronizer_module
31+
- name: networking_module
2532
- name: injector
2633
- name: application
2734
- name: rpc

scripts/asn1.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ def asn_sequence_of(t):
185185
if T == "U8":
186186
if fixed:
187187
if type(size) is int:
188-
return "qtils::BytesN<%u>" % size
188+
return "qtils::ByteArr<%u>" % size
189189
else:
190190
return "::jam::ConfigVec<uint8_t, Config::Field::%s>" % c_dash(size)
191-
return "qtils::Bytes"
191+
return "qtils::ByteVec"
192192
if fixed:
193193
if isinstance(size, str):
194194
return "::jam::ConfigVec<%s, Config::Field::%s>" % (T, c_dash(size))
@@ -412,7 +412,8 @@ def __init__(self, cpp_namespace: str, path: str):
412412
"#include <string_view>",
413413
"#include <variant>",
414414
"",
415-
"#include <qtils/bytes.hpp>",
415+
"#include <qtils/byte_arr.hpp>",
416+
"#include <qtils/byte_vec.hpp>",
416417
"#include <qtils/empty.hpp>",
417418
"#include <qtils/tagged.hpp>",
418419
"",
@@ -468,7 +469,8 @@ def __init__(self, cpp_namespace: str, name: str, path: str, module: str):
468469
"#include <string_view>",
469470
"#include <variant>",
470471
"",
471-
"#include <qtils/bytes.hpp>",
472+
"#include <qtils/byte_arr.hpp>",
473+
"#include <qtils/byte_vec.hpp>",
472474
"",
473475
*includes,
474476
"#include <test-vectors/config-types.hpp>",

src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

7-
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
7+
include_directories(${CMAKE_SOURCE_DIR})
8+
include_directories(${CMAKE_SOURCE_DIR}/src)
9+
include_directories(${CMAKE_BINARY_DIR}/generated)
810

911
# Executables (should contain `main()` function)
1012
add_subdirectory(executable)

src/app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ target_link_libraries(app_configurator
4242

4343
add_library(app_state_manager SHARED impl/state_manager_impl.cpp)
4444
target_link_libraries(app_state_manager
45+
qtils::qtils
4546
logger
4647
)
4748

src/app/configuration.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,31 @@
88
namespace jam::app {
99

1010
Configuration::Configuration()
11-
: version_("undefined"), name_("unnamed"), metrics_endpoint_() {}
11+
: version_("undefined"),
12+
name_("unnamed"),
13+
metrics_{
14+
.endpoint{},
15+
.enabled{},
16+
} {}
1217

13-
std::string Configuration::nodeVersion() const {
18+
const std::string &Configuration::nodeVersion() const {
1419
return version_;
1520
}
1621

17-
std::string Configuration::nodeName() const {
22+
const std::string &Configuration::nodeName() const {
1823
return name_;
1924
}
2025

21-
std::optional<Configuration::Endpoint> Configuration::metricsEndpoint()
22-
const {
23-
return metrics_endpoint_;
26+
const std::filesystem::path &Configuration::basePath() const {
27+
return base_path_;
28+
}
29+
30+
const std::filesystem::path &Configuration::modulesDir() const {
31+
return modules_dir_;
32+
}
33+
34+
const Configuration::MetricsConfig &Configuration::metrics() const {
35+
return metrics_;
2436
}
2537

2638
} // namespace jam::app

src/app/configuration.hpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <filesystem>
99
#include <string>
1010

11+
#include <filesystem>
1112
#include <boost/asio/ip/tcp.hpp>
1213
#include <utils/ctor_limiters.hpp>
1314

@@ -16,24 +17,32 @@ namespace jam::app {
1617
public:
1718
using Endpoint = boost::asio::ip::tcp::endpoint;
1819

20+
struct MetricsConfig {
21+
Endpoint endpoint;
22+
std::optional<bool> enabled;
23+
};
24+
1925
Configuration();
2026

2127
// /// Generate yaml-file with actual config
2228
// virtual void generateConfigFile() const = 0;
2329

24-
[[nodiscard]] std::string nodeVersion() const;
25-
[[nodiscard]] std::string nodeName() const;
30+
[[nodiscard]] virtual const std::string &nodeVersion() const;
31+
[[nodiscard]] virtual const std::string &nodeName() const;
32+
[[nodiscard]] virtual const std::filesystem::path &basePath() const;
33+
[[nodiscard]] virtual const std::filesystem::path &modulesDir() const;
2634

27-
[[nodiscard]] std::optional<Endpoint> metricsEndpoint() const;
35+
[[nodiscard]] virtual const MetricsConfig &metrics() const;
2836

2937
private:
3038
friend class Configurator; // for external configure
3139

3240
std::string version_;
3341
std::string name_;
42+
std::filesystem::path base_path_;
43+
std::filesystem::path modules_dir_;
3444

35-
Endpoint metrics_endpoint_;
36-
std::optional<bool> metrics_enabled_;
45+
MetricsConfig metrics_;
3746
};
3847

3948
} // namespace jam::app

0 commit comments

Comments
 (0)