Skip to content

Commit 8f2f5ea

Browse files
committed
testnet: add seed nodes, checkpoints, wallet: fix approximation of height
1 parent 66a5e11 commit 8f2f5ea

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

src/checkpoints/checkpoints.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ bool checkpoints::check_for_conflicts(const checkpoints &other) const {
182182

183183
bool checkpoints::init_default_checkpoints(network_type nettype) {
184184
if (nettype == TESTNET) {
185+
ADD_CHECKPOINT2(
186+
10, "a76e3b124834af91af028718e9dc03277bcd08845deecf1e52061b6411b3356c",
187+
"0x25");
188+
ADD_CHECKPOINT2(
189+
15, "325dafccc380a19243c1f5edb3ac16696e65500d8de3d38f77504e7b76bb9a26",
190+
"0x54");
191+
ADD_CHECKPOINT2(
192+
20, "992cf60da2c6a5643bb5bc0674af748473fa2b40ceb4739cde1e9d4a7d35dbbc",
193+
"0x1d4c84")
194+
185195
return true;
186196
}
187197

src/p2p/net_node.inl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,10 @@ namespace nodetool
702702
{
703703
std::set<std::string> full_addrs;
704704
if (m_nettype == cryptonote::TESTNET)
705-
{}
705+
{
706+
full_addrs.insert("65.21.221.2:22822");
707+
full_addrs.insert("65.21.221.3:22822");
708+
}
706709
else if (m_nettype == cryptonote::STAGENET)
707710
{
708711
full_addrs.insert("65.21.221.2:33833");

src/wallet/wallet2.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13404,26 +13404,15 @@ uint64_t wallet2::get_daemon_blockchain_target_height(string &err) {
1340413404
}
1340513405

1340613406
uint64_t wallet2::get_approximate_blockchain_height() const {
13407-
// time of v2 fork
13408-
const time_t fork_time = m_nettype == TESTNET ? 1448285909
13409-
: m_nettype == STAGENET ? 1520937818
13410-
: 1458748658;
13411-
// v2 fork block
13412-
const uint64_t fork_block = m_nettype == TESTNET ? 624634
13413-
: m_nettype == STAGENET ? 32000
13414-
: 1009827;
13415-
// avg seconds per block
13416-
const int seconds_per_block = DIFFICULTY_TARGET_V2;
13417-
// Calculated blockchain height
13407+
const int seconds_per_block = DIFFICULTY_TARGET;
13408+
const time_t epochTimeMiningStarted = 1596258914;
13409+
const time_t currentTime = time(NULL);
1341813410
uint64_t approx_blockchain_height =
13419-
fork_block + (time(NULL) - fork_time) / seconds_per_block;
13420-
// testnet and stagenet got some huge rollbacks, so the estimation is way off
13421-
static const uint64_t approximate_rolled_back_blocks =
13422-
m_nettype == TESTNET ? 342100 : 30000;
13423-
if ((m_nettype == TESTNET || m_nettype == STAGENET) &&
13424-
approx_blockchain_height > approximate_rolled_back_blocks)
13425-
approx_blockchain_height -= approximate_rolled_back_blocks;
13411+
(currentTime < epochTimeMiningStarted)
13412+
? 0
13413+
: (currentTime - epochTimeMiningStarted) / seconds_per_block;
1342613414
LOG_PRINT_L2("Calculated blockchain height: " << approx_blockchain_height);
13415+
1342713416
return approx_blockchain_height;
1342813417
}
1342913418

0 commit comments

Comments
 (0)