Skip to content

Commit

Permalink
Add new config option for caddr_time_version
Browse files Browse the repository at this point in the history
  • Loading branch information
joeuhren committed May 18, 2020
1 parent 261f2c2 commit fb9d90b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ sudo rm -rf python-cloudflare
- **protocol_version (Required):** This is the current protocol version that should be used by the seeder app to crawl your network and connect to other nodes. **Ex:** 70015. Typically you can find the protocol version in your coins `version.h` file.
- **init_proto_version (Required):** This is the protocol version that should be used as a starting value to communicate with nodes on the blockahin. **Ex:** 209. Typically you can find the init protocol version in your coins `version.h` file.
- **min_peer_proto_version (Optional):** This is the oldest/lowest protocol version that is allowed to communicate with nodes on the blockchain network. **Ex:** 70015. Typically you can find the minimum peer protocol version in your coins `version.h` file. Leave this value blank or set it to the same value as `protocol_version` if this setting does not exist in your blockchain.
- **caddr_time_version (Required):** This is the nTime value that is used to serialize CAddress data for the blockchain. **Ex:** 31402. Typically you can find the `caddr_time_version` in your coins `version.h` file.
- **pchMessageStart_0 (Required):** The first byte of the "magic bytes" that are unique to the blockchain you are configuring. Must be prefixed with 0x followed by the two digits to make up the full byte. **Ex:** 0x11. Typically you can find the 4 pchMessageStart values in your coins `main.cpp` or `chainparams.cpp` file.
- **pchMessageStart_1 (Required):** The second byte of the "magic bytes" that are unique to the blockchain you are configuring. Must be prefixed with 0x followed by the two digits to make up the full byte. **Ex:** 0x22. Typically you can find the 4 pchMessageStart values in your coins `main.cpp` or `chainparams.cpp` file.
- **pchMessageStart_2 (Required):** The third byte of the "magic bytes" that are unique to the blockchain you are configuring. Must be prefixed with 0x followed by the two digits to make up the full byte. **Ex:** 0x33. Typically you can find the 4 pchMessageStart values in your coins `main.cpp` or `chainparams.cpp` file.
Expand Down
8 changes: 8 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ int nDefaultBlockHeight = -1;
int cfg_protocol_version;
int cfg_init_proto_version;
int cfg_min_peer_proto_version;
int cfg_caddr_time_version;
unsigned char cfg_message_start[4];
int cfg_wallet_port;
string cfg_explorer_url;
Expand Down Expand Up @@ -622,6 +623,13 @@ int main(int argc, char **argv) {
cfg_min_peer_proto_version = cfg_protocol_version;
}

try {
cfg_caddr_time_version = std::stoi(cfg.lookup("caddr_time_version").c_str());
} catch(const SettingNotFoundException &nfex) {
cerr << "Error: Missing 'caddr_time_version' setting in configuration file." << endl;
return(EXIT_FAILURE);
}

for (int i=0; i<4; i++) {
try {
cfg_message_start[i] = static_cast<char>(hex_string_to_int(cfg.lookup("pchMessageStart_" + std::to_string(i)).c_str()));
Expand Down
3 changes: 2 additions & 1 deletion protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
// (4) size
// (4) checksum

extern int cfg_caddr_time_version;
extern unsigned char cfg_message_start[4];

class CMessageHeader
Expand Down Expand Up @@ -75,7 +76,7 @@ class CAddress : public CService
pthis->Init();
if (nType & SER_DISK)
READWRITE(nVersion);
if ((nType & SER_DISK) || (nVersion >= 31402 && !(nType & SER_GETHASH)))
if ((nType & SER_DISK) || (nVersion >= cfg_caddr_time_version && !(nType & SER_GETHASH)))
READWRITE(nTime);
READWRITE(nServices);
READWRITE(*pip);
Expand Down
1 change: 1 addition & 0 deletions settings.conf.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
protocol_version="70015" // Typically you can find the protocol version in your coins version.h file
init_proto_version="209" // Typically you can find the init protocol version in your coins version.h file
min_peer_proto_version="70015" // Typically you can find the minimum peer protocol version in your coins version.h file. Leave this value blank or set it to the same value as protocol_version if this setting does not exist in your blockchain
caddr_time_version="31402" // Typically you can find the caddr_time_version in your coins version.h file
pchMessageStart_0 = "0x11" // Typically you can find the 4 pchMessageStart values in your coins main.cpp or chainparams.cpp file
pchMessageStart_1 = "0x22"
pchMessageStart_2 = "0x33"
Expand Down

0 comments on commit fb9d90b

Please sign in to comment.