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.
This commit is contained in:
parent
6af27b8157
commit
7e2e62cf7c
6 changed files with 98 additions and 8 deletions
|
@ -16,10 +16,6 @@ libs = [
|
||||||
]
|
]
|
||||||
|
|
||||||
ignore_list = [
|
ignore_list = [
|
||||||
'rpc/net.cpp',
|
|
||||||
'interfaces/handler.cpp',
|
|
||||||
'interfaces/node.cpp',
|
|
||||||
'interfaces/wallet.cpp',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
lib_sources = {}
|
lib_sources = {}
|
||||||
|
@ -32,7 +28,9 @@ def parse_makefile(makefile):
|
||||||
if current_lib:
|
if current_lib:
|
||||||
source = line.split()[0]
|
source = line.split()[0]
|
||||||
if source.endswith('.cpp') and not source.startswith('$') and source not in ignore_list:
|
if source.endswith('.cpp') and not source.startswith('$') and source not in ignore_list:
|
||||||
lib_sources[current_lib].append(source.replace('/', '\\'))
|
source_filename = source.replace('/', '\\')
|
||||||
|
object_filename = source.replace('/', '_')[:-4] + ".obj"
|
||||||
|
lib_sources[current_lib].append((source_filename, object_filename))
|
||||||
if not line.endswith('\\'):
|
if not line.endswith('\\'):
|
||||||
current_lib = ''
|
current_lib = ''
|
||||||
continue
|
continue
|
||||||
|
@ -51,8 +49,10 @@ def main():
|
||||||
for key, value in lib_sources.items():
|
for key, value in lib_sources.items():
|
||||||
vcxproj_filename = os.path.abspath(os.path.join(os.path.dirname(__file__), key, key + '.vcxproj'))
|
vcxproj_filename = os.path.abspath(os.path.join(os.path.dirname(__file__), key, key + '.vcxproj'))
|
||||||
content = ''
|
content = ''
|
||||||
for source_filename in value:
|
for source_filename, object_filename in value:
|
||||||
content += ' <ClCompile Include="..\\..\\src\\' + source_filename + '" />\n'
|
content += ' <ClCompile Include="..\\..\\src\\' + source_filename + '">\n'
|
||||||
|
content += ' <ObjectFileName>$(IntDir)' + object_filename + '</ObjectFileName>\n'
|
||||||
|
content += ' </ClCompile>\n'
|
||||||
with open(vcxproj_filename + '.in', 'r', encoding='utf-8') as vcxproj_in_file:
|
with open(vcxproj_filename + '.in', 'r', encoding='utf-8') as vcxproj_in_file:
|
||||||
with open(vcxproj_filename, 'w', encoding='utf-8') as vcxproj_file:
|
with open(vcxproj_filename, 'w', encoding='utf-8') as vcxproj_file:
|
||||||
vcxproj_file.write(vcxproj_in_file.read().replace(
|
vcxproj_file.write(vcxproj_in_file.read().replace(
|
||||||
|
|
|
@ -125,6 +125,7 @@ BITCOIN_CORE_H = \
|
||||||
index/txindex.h \
|
index/txindex.h \
|
||||||
indirectmap.h \
|
indirectmap.h \
|
||||||
init.h \
|
init.h \
|
||||||
|
interfaces/chain.h \
|
||||||
interfaces/handler.h \
|
interfaces/handler.h \
|
||||||
interfaces/node.h \
|
interfaces/node.h \
|
||||||
interfaces/wallet.h \
|
interfaces/wallet.h \
|
||||||
|
@ -233,6 +234,7 @@ libbitcoin_server_a_SOURCES = \
|
||||||
httpserver.cpp \
|
httpserver.cpp \
|
||||||
index/base.cpp \
|
index/base.cpp \
|
||||||
index/txindex.cpp \
|
index/txindex.cpp \
|
||||||
|
interfaces/chain.cpp \
|
||||||
interfaces/handler.cpp \
|
interfaces/handler.cpp \
|
||||||
interfaces/node.cpp \
|
interfaces/node.cpp \
|
||||||
init.cpp \
|
init.cpp \
|
||||||
|
|
|
@ -4,7 +4,7 @@ The following interfaces are defined here:
|
||||||
|
|
||||||
* [`Chain`](chain.h) — used by wallet to access blockchain and mempool state. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).
|
* [`Chain`](chain.h) — used by wallet to access blockchain and mempool state. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).
|
||||||
|
|
||||||
* [`Chain::Client`](chain.h) — used by node to start & stop `Chain` clients. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).
|
* [`ChainClient`](chain.h) — used by node to start & stop `Chain` clients. Added in [#10973](https://github.com/bitcoin/bitcoin/pull/10973).
|
||||||
|
|
||||||
* [`Node`](node.h) — used by GUI to start & stop bitcoin node. Added in [#10244](https://github.com/bitcoin/bitcoin/pull/10244).
|
* [`Node`](node.h) — used by GUI to start & stop bitcoin node. Added in [#10244](https://github.com/bitcoin/bitcoin/pull/10244).
|
||||||
|
|
||||||
|
|
20
src/interfaces/chain.cpp
Normal file
20
src/interfaces/chain.cpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright (c) 2018 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#include <interfaces/chain.h>
|
||||||
|
|
||||||
|
#include <util/system.h>
|
||||||
|
|
||||||
|
namespace interfaces {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class ChainImpl : public Chain
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
std::unique_ptr<Chain> MakeChain() { return MakeUnique<ChainImpl>(); }
|
||||||
|
|
||||||
|
} // namespace interfaces
|
44
src/interfaces/chain.h
Normal file
44
src/interfaces/chain.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// Copyright (c) 2018 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifndef BITCOIN_INTERFACES_CHAIN_H
|
||||||
|
#define BITCOIN_INTERFACES_CHAIN_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace interfaces {
|
||||||
|
|
||||||
|
//! Interface for giving wallet processes access to blockchain state.
|
||||||
|
class Chain
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Chain() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Interface to let node manage chain clients (wallets, or maybe tools for
|
||||||
|
//! monitoring and analysis in the future).
|
||||||
|
class ChainClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~ChainClient() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Return implementation of Chain interface.
|
||||||
|
std::unique_ptr<Chain> MakeChain();
|
||||||
|
|
||||||
|
//! Return implementation of ChainClient interface for a wallet client. This
|
||||||
|
//! function will be undefined in builds where ENABLE_WALLET is false.
|
||||||
|
//!
|
||||||
|
//! Currently, wallets are the only chain clients. But in the future, other
|
||||||
|
//! types of chain clients could be added, such as tools for monitoring,
|
||||||
|
//! analysis, or fee estimation. These clients need to expose their own
|
||||||
|
//! MakeXXXClient functions returning their implementations of the ChainClient
|
||||||
|
//! interface.
|
||||||
|
std::unique_ptr<ChainClient> MakeWalletClient(Chain& chain, std::vector<std::string> wallet_filenames);
|
||||||
|
|
||||||
|
} // namespace interfaces
|
||||||
|
|
||||||
|
#endif // BITCOIN_INTERFACES_CHAIN_H
|
|
@ -7,6 +7,7 @@
|
||||||
#include <amount.h>
|
#include <amount.h>
|
||||||
#include <chain.h>
|
#include <chain.h>
|
||||||
#include <consensus/validation.h>
|
#include <consensus/validation.h>
|
||||||
|
#include <interfaces/chain.h>
|
||||||
#include <interfaces/handler.h>
|
#include <interfaces/handler.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#include <policy/feerate.h>
|
#include <policy/feerate.h>
|
||||||
|
@ -20,11 +21,17 @@
|
||||||
#include <timedata.h>
|
#include <timedata.h>
|
||||||
#include <ui_interface.h>
|
#include <ui_interface.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
#include <util/system.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <wallet/feebumper.h>
|
#include <wallet/feebumper.h>
|
||||||
#include <wallet/fees.h>
|
#include <wallet/fees.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace interfaces {
|
namespace interfaces {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -456,8 +463,25 @@ public:
|
||||||
CWallet& m_wallet;
|
CWallet& m_wallet;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WalletClientImpl : public ChainClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WalletClientImpl(Chain& chain, std::vector<std::string> wallet_filenames)
|
||||||
|
: m_chain(chain), m_wallet_filenames(std::move(wallet_filenames))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Chain& m_chain;
|
||||||
|
std::vector<std::string> m_wallet_filenames;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return MakeUnique<WalletImpl>(wallet); }
|
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return MakeUnique<WalletImpl>(wallet); }
|
||||||
|
|
||||||
|
std::unique_ptr<ChainClient> MakeWalletClient(Chain& chain, std::vector<std::string> wallet_filenames)
|
||||||
|
{
|
||||||
|
return MakeUnique<WalletClientImpl>(chain, std::move(wallet_filenames));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace interfaces
|
} // namespace interfaces
|
||||||
|
|
Loading…
Reference in a new issue