Skip to content

Commit 7e2e62c

Browse files
committed
Add skeleton chain and client classes
This commit does not change behavior. It just adds new skeleton classes that don't do anything and aren't instantiated yet.
1 parent 6af27b8 commit 7e2e62c

File tree

6 files changed

+98
-8
lines changed

6 files changed

+98
-8
lines changed

build_msvc/msvc-autogen.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
]
1717

1818
ignore_list = [
19-
'rpc/net.cpp',
20-
'interfaces/handler.cpp',
21-
'interfaces/node.cpp',
22-
'interfaces/wallet.cpp',
2319
]
2420

2521
lib_sources = {}
@@ -32,7 +28,9 @@ def parse_makefile(makefile):
3228
if current_lib:
3329
source = line.split()[0]
3430
if source.endswith('.cpp') and not source.startswith('$') and source not in ignore_list:
35-
lib_sources[current_lib].append(source.replace('/', '\\'))
31+
source_filename = source.replace('/', '\\')
32+
object_filename = source.replace('/', '_')[:-4] + ".obj"
33+
lib_sources[current_lib].append((source_filename, object_filename))
3634
if not line.endswith('\\'):
3735
current_lib = ''
3836
continue
@@ -51,8 +49,10 @@ def main():
5149
for key, value in lib_sources.items():
5250
vcxproj_filename = os.path.abspath(os.path.join(os.path.dirname(__file__), key, key + '.vcxproj'))
5351
content = ''
54-
for source_filename in value:
55-
content += ' <ClCompile Include="..\\..\\src\\' + source_filename + '" />\n'
52+
for source_filename, object_filename in value:
53+
content += ' <ClCompile Include="..\\..\\src\\' + source_filename + '">\n'
54+
content += ' <ObjectFileName>$(IntDir)' + object_filename + '</ObjectFileName>\n'
55+
content += ' </ClCompile>\n'
5656
with open(vcxproj_filename + '.in', 'r', encoding='utf-8') as vcxproj_in_file:
5757
with open(vcxproj_filename, 'w', encoding='utf-8') as vcxproj_file:
5858
vcxproj_file.write(vcxproj_in_file.read().replace(

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ BITCOIN_CORE_H = \
125125
index/txindex.h \
126126
indirectmap.h \
127127
init.h \
128+
interfaces/chain.h \
128129
interfaces/handler.h \
129130
interfaces/node.h \
130131
interfaces/wallet.h \
@@ -233,6 +234,7 @@ libbitcoin_server_a_SOURCES = \
233234
httpserver.cpp \
234235
index/base.cpp \
235236
index/txindex.cpp \
237+
interfaces/chain.cpp \
236238
interfaces/handler.cpp \
237239
interfaces/node.cpp \
238240
init.cpp \

src/interfaces/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The following interfaces are defined here:
44

55
* [`Chain`](chain.h) — used by wallet to access blockchain and mempool state. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).
66

7-
* [`Chain::Client`](chain.h) — used by node to start & stop `Chain` clients. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).
7+
* [`ChainClient`](chain.h) — used by node to start & stop `Chain` clients. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).
88

99
* [`Node`](node.h) — used by GUI to start & stop bitcoin node. Added in [#10244](https://github.com/bitcoin/bitcoin/pull/10244).
1010

src/interfaces/chain.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2018 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <interfaces/chain.h>
6+
7+
#include <util/system.h>
8+
9+
namespace interfaces {
10+
namespace {
11+
12+
class ChainImpl : public Chain
13+
{
14+
};
15+
16+
} // namespace
17+
18+
std::unique_ptr<Chain> MakeChain() { return MakeUnique<ChainImpl>(); }
19+
20+
} // namespace interfaces

src/interfaces/chain.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2018 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_INTERFACES_CHAIN_H
6+
#define BITCOIN_INTERFACES_CHAIN_H
7+
8+
#include <memory>
9+
#include <string>
10+
#include <vector>
11+
12+
namespace interfaces {
13+
14+
//! Interface for giving wallet processes access to blockchain state.
15+
class Chain
16+
{
17+
public:
18+
virtual ~Chain() {}
19+
};
20+
21+
//! Interface to let node manage chain clients (wallets, or maybe tools for
22+
//! monitoring and analysis in the future).
23+
class ChainClient
24+
{
25+
public:
26+
virtual ~ChainClient() {}
27+
};
28+
29+
//! Return implementation of Chain interface.
30+
std::unique_ptr<Chain> MakeChain();
31+
32+
//! Return implementation of ChainClient interface for a wallet client. This
33+
//! function will be undefined in builds where ENABLE_WALLET is false.
34+
//!
35+
//! Currently, wallets are the only chain clients. But in the future, other
36+
//! types of chain clients could be added, such as tools for monitoring,
37+
//! analysis, or fee estimation. These clients need to expose their own
38+
//! MakeXXXClient functions returning their implementations of the ChainClient
39+
//! interface.
40+
std::unique_ptr<ChainClient> MakeWalletClient(Chain& chain, std::vector<std::string> wallet_filenames);
41+
42+
} // namespace interfaces
43+
44+
#endif // BITCOIN_INTERFACES_CHAIN_H

src/interfaces/wallet.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <amount.h>
88
#include <chain.h>
99
#include <consensus/validation.h>
10+
#include <interfaces/chain.h>
1011
#include <interfaces/handler.h>
1112
#include <net.h>
1213
#include <policy/feerate.h>
@@ -20,11 +21,17 @@
2021
#include <timedata.h>
2122
#include <ui_interface.h>
2223
#include <uint256.h>
24+
#include <util/system.h>
2325
#include <validation.h>
2426
#include <wallet/feebumper.h>
2527
#include <wallet/fees.h>
2628
#include <wallet/wallet.h>
2729

30+
#include <memory>
31+
#include <string>
32+
#include <utility>
33+
#include <vector>
34+
2835
namespace interfaces {
2936
namespace {
3037

@@ -456,8 +463,25 @@ class WalletImpl : public Wallet
456463
CWallet& m_wallet;
457464
};
458465

466+
class WalletClientImpl : public ChainClient
467+
{
468+
public:
469+
WalletClientImpl(Chain& chain, std::vector<std::string> wallet_filenames)
470+
: m_chain(chain), m_wallet_filenames(std::move(wallet_filenames))
471+
{
472+
}
473+
474+
Chain& m_chain;
475+
std::vector<std::string> m_wallet_filenames;
476+
};
477+
459478
} // namespace
460479

461480
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return MakeUnique<WalletImpl>(wallet); }
462481

482+
std::unique_ptr<ChainClient> MakeWalletClient(Chain& chain, std::vector<std::string> wallet_filenames)
483+
{
484+
return MakeUnique<WalletClientImpl>(chain, std::move(wallet_filenames));
485+
}
486+
463487
} // namespace interfaces

0 commit comments

Comments
 (0)