Skip to content

Commit 5ab5677

Browse files
committed
subsystem
1 parent 2743a79 commit 5ab5677

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

src/enclave/enclave.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "node/rpc/custom_protocol_subsystem.h"
2525
#include "node/rpc/forwarder.h"
2626
#include "node/rpc/gov_effects.h"
27+
#include "node/rpc/ledger_subsystem.h"
2728
#include "node/rpc/member_frontend.h"
2829
#include "node/rpc/network_identity_subsystem.h"
2930
#include "node/rpc/node_frontend.h"
@@ -137,7 +138,9 @@ namespace ccf
137138
context->install_subsystem(cpss);
138139
rpcsessions->set_custom_protocol_subsystem(cpss);
139140

140-
// TODO: install a ledger files subsystem to manage ledger access
141+
auto ledger_subsystem =
142+
std::make_shared<ccf::ReadLedgerSubsystem>(ledger_);
143+
context->install_subsystem(ledger_subsystem);
141144

142145
static constexpr size_t max_interpreter_cache_size = 10;
143146
auto interpreter_cache =

src/node/rpc/ledger_interface.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the Apache 2.0 License.
3+
#pragma once
4+
5+
#include "ccf/node_subsystem_interface.h"
6+
7+
#include <filesystem>
8+
#include <optional>
9+
10+
namespace ccf
11+
{
12+
class AbstractReadLedgerSubsystemInterface : public AbstractNodeSubSystem
13+
{
14+
public:
15+
~AbstractReadLedgerSubsystemInterface() override = default;
16+
17+
static char const* get_subsystem_name()
18+
{
19+
return "LedgerReadInterface";
20+
}
21+
22+
virtual std::optional<std::filesystem::path> committed_ledger_path_with_idx(
23+
size_t idx) = 0;
24+
};
25+
}

src/node/rpc/ledger_subsystem.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the Apache 2.0 License.
3+
#pragma once
4+
5+
#include "host/ledger.h"
6+
#include "node/rpc/ledger_interface.h"
7+
8+
namespace ccf
9+
{
10+
class ReadLedgerSubsystem : public AbstractReadLedgerSubsystemInterface
11+
{
12+
protected:
13+
asynchost::Ledger& ledger;
14+
15+
public:
16+
ReadLedgerSubsystem(asynchost::Ledger& ledger_) : ledger(ledger_) {}
17+
18+
[[nodiscard]] std::optional<std::filesystem::path>
19+
committed_ledger_path_with_idx(size_t idx) override
20+
{
21+
return ledger.committed_ledger_path_with_idx(idx);
22+
}
23+
};
24+
}

0 commit comments

Comments
 (0)