forked from goatpig/BitcoinArmory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockDataManagerConfig.h
More file actions
180 lines (140 loc) · 5 KB
/
BlockDataManagerConfig.h
File metadata and controls
180 lines (140 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2011-2015, Armory Technologies, Inc. //
// Distributed under the GNU Affero General Public License (AGPL v3) //
// See LICENSE-ATI or http://www.gnu.org/licenses/agpl.html //
// //
// //
// Copyright (C) 2016, goatpig //
// Distributed under the MIT license //
// See LICENSE-MIT or https://opensource.org/licenses/MIT //
// //
////////////////////////////////////////////////////////////////////////////////
#ifndef BLOCKDATAMANAGERCONFIG_H
#define BLOCKDATAMANAGERCONFIG_H
#include <exception>
#include <thread>
#include "bdmenums.h"
#include "BinaryData.h"
#include <tuple>
#include <list>
#ifdef _WIN32
#include <ShlObj.h>
#else
#include <wordexp.h>
#endif
#define DEFAULT_ZCTHREAD_COUNT 100
#define WEBSOCKET_PORT 7681
////////////////////////////////////////////////////////////////////////////////
struct BlockDataManagerConfig
{
private:
static ARMORY_DB_TYPE armoryDbType_;
static SOCKET_SERVICE service_;
public:
BDM_INIT_MODE initMode_ = INIT_RESUME;
static const string dbDirExtention_;
static const string defaultDataDir_;
static const string defaultBlkFileLocation_;
static const string defaultTestnetDataDir_;
static const string defaultTestnetBlkFileLocation_;
static const string defaultRegtestDataDir_;
static const string defaultRegtestBlkFileLocation_;
string dataDir_;
string blkFileLocation_;
string dbDir_;
bool testnet_ = false;
bool regtest_ = false;
string logFilePath_;
BinaryData genesisBlockHash_;
BinaryData genesisTxHash_;
BinaryData magicBytes_;
NodeType nodeType_ = Node_BTC;
string btcPort_;
string listenPort_;
string rpcPort_;
bool customFcgiPort_ = false;
unsigned ramUsage_ = 4;
unsigned threadCount_ = thread::hardware_concurrency();
unsigned zcThreadCount_ = DEFAULT_ZCTHREAD_COUNT;
exception_ptr exceptionPtr_ = nullptr;
bool reportProgress_ = true;
bool checkChain_ = false;
bool clearMempool_ = false;
const string cookie_;
bool useCookie_ = false;
static uint8_t pubkeyHashPrefix_;
static uint8_t scriptHashPrefix_;
public:
BlockDataManagerConfig();
/////////////
void setGenesisBlockHash(const BinaryData &h)
{
genesisBlockHash_ = h;
}
void setGenesisTxHash(const BinaryData &h)
{
genesisTxHash_ = h;
}
void setMagicBytes(const BinaryData &h)
{
magicBytes_ = h;
}
void selectNetwork(const std::string &netname);
void processArgs(const map<string, string>&, bool);
void parseArgs(int argc, char* argv[]);
void createCookie(void) const;
void printHelp(void);
static string portToString(unsigned);
static void appendPath(string& base, const string& add);
static void expandPath(string& path);
static vector<string> getLines(const string& path);
static map<string, string> getKeyValsFromLines(
const vector<string>&, char delim);
static pair<string, string> getKeyValFromLine(const string&, char delim);
static string stripQuotes(const string& input);
static vector<string> keyValToArgv(const map<string, string>&);
static bool testConnection(const string& ip, const string& port);
static string hasLocalDB(const string& datadir, const string& port);
static string getPortFromCookie(const string& datadir);
static string getCookie(const string& datadir);
static void setDbType(ARMORY_DB_TYPE dbType)
{
armoryDbType_ = dbType;
}
static ARMORY_DB_TYPE getDbType(void)
{
return armoryDbType_;
}
static void setServiceType(SOCKET_SERVICE _type)
{
service_ = _type;
}
static SOCKET_SERVICE getServiceType(void)
{
return service_;
}
static string getDbModeStr(void);
static uint8_t getPubkeyHashPrefix(void) { return pubkeyHashPrefix_; }
static uint8_t getScriptHashPrefix(void) { return scriptHashPrefix_; }
};
////////////////////////////////////////////////////////////////////////////////
struct ConfigFile
{
map<string, string> keyvalMap_;
ConfigFile(const string& path);
static vector<BinaryData> fleshOutArgs(
const string& path, const vector<BinaryData>& argv);
};
////////////////////////////////////////////////////////////////////////////////
struct BDV_Error_Struct
{
string errorStr_;
BDV_ErrorType errType_;
string extraMsg_;
BinaryData serialize(void) const;
void deserialize(const BinaryData&);
static BDV_Error_Struct cast_to_BDVErrorStruct(void* ptr);
};
#endif
// kate: indent-width 3; replace-tabs on;