Skip to content

Commit 823bde5

Browse files
committed
Adding min difficulty for both zawy diff alg
1 parent 7ca8281 commit 823bde5

File tree

4 files changed

+92
-20
lines changed

4 files changed

+92
-20
lines changed

extensions/bytecoin-v2/multiply/zawy-difficulty-algorithm.json

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"parameters": {
1818
"text": [
1919
" const command_line::arg_descriptor<uint32_t> arg_ZAWY_DIFFICULTY_BLOCK_INDEX = {\"ZAWY_DIFFICULTY_BLOCK_INDEX\", \"uint32_t\", 0};",
20-
" const command_line::arg_descriptor<uint32_t> arg_ZAWY_DIFFICULTY_LAST_BLOCK = {\"ZAWY_DIFFICULTY_LAST_BLOCK\", \"uint32_t\", 0};"
20+
" const command_line::arg_descriptor<uint32_t> arg_ZAWY_DIFFICULTY_LAST_BLOCK = {\"ZAWY_DIFFICULTY_LAST_BLOCK\", \"uint32_t\", 0};",
21+
" const command_line::arg_descriptor<uint64_t> arg_ZAWY_DIFFICULTY_MIN = {\"ZAWY_DIFFICULTY_MIN\", \"uint64_t\", 1};"
2122
]
2223
}
2324
},
@@ -27,7 +28,8 @@
2728
"parameters": {
2829
"text": [
2930
" command_line::add_arg(desc_cmd_sett, arg_ZAWY_DIFFICULTY_BLOCK_INDEX);",
30-
" command_line::add_arg(desc_cmd_sett, arg_ZAWY_DIFFICULTY_LAST_BLOCK);"
31+
" command_line::add_arg(desc_cmd_sett, arg_ZAWY_DIFFICULTY_LAST_BLOCK);",
32+
" command_line::add_arg(desc_cmd_sett, arg_ZAWY_DIFFICULTY_MIN);"
3133
]
3234
}
3335
},
@@ -37,7 +39,8 @@
3739
"parameters": {
3840
"text": [
3941
" currencyBuilder.zawyDifficultyBlockIndex(command_line::get_arg(vm, arg_ZAWY_DIFFICULTY_BLOCK_INDEX));",
40-
" currencyBuilder.zawyDifficultyLastBlock(command_line::get_arg(vm, arg_ZAWY_DIFFICULTY_LAST_BLOCK));"
42+
" currencyBuilder.zawyDifficultyLastBlock(command_line::get_arg(vm, arg_ZAWY_DIFFICULTY_LAST_BLOCK));",
43+
" currencyBuilder.zawyDifficultyMin(command_line::get_arg(vm, arg_ZAWY_DIFFICULTY_MIN));"
4144
]
4245
}
4346
}
@@ -52,7 +55,8 @@
5255
"parameters": {
5356
"text": [
5457
" uint32_t ZAWY_DIFFICULTY_BLOCK_INDEX;",
55-
" uint32_t ZAWY_DIFFICULTY_LAST_BLOCK;"
58+
" uint32_t ZAWY_DIFFICULTY_LAST_BLOCK;",
59+
" uint64_t ZAWY_DIFFICULTY_MIN;"
5660
]
5761
}
5862
}
@@ -67,7 +71,8 @@
6771
"parameters": {
6872
"text": [
6973
" ZAWY_DIFFICULTY_BLOCK_INDEX=CryptoNote::parameters::ZAWY_DIFFICULTY_BLOCK_INDEX;",
70-
" ZAWY_DIFFICULTY_LAST_BLOCK=CryptoNote::parameters::ZAWY_DIFFICULTY_LAST_BLOCK;"
74+
" ZAWY_DIFFICULTY_LAST_BLOCK=CryptoNote::parameters::ZAWY_DIFFICULTY_LAST_BLOCK;",
75+
" ZAWY_DIFFICULTY_MIN=CryptoNote::parameters::ZAWY_DIFFICULTY_MIN;"
7176
]
7277
}
7378
},
@@ -77,7 +82,8 @@
7782
"parameters": {
7883
"text": [
7984
" (\"ZAWY_DIFFICULTY_BLOCK_INDEX\", po::value<uint32_t>()->default_value(0), \"uint32_t\")",
80-
" (\"ZAWY_DIFFICULTY_LAST_BLOCK\", po::value<uint32_t>()->default_value(0), \"uint32_t\")"
85+
" (\"ZAWY_DIFFICULTY_LAST_BLOCK\", po::value<uint32_t>()->default_value(0), \"uint32_t\")",
86+
" (\"ZAWY_DIFFICULTY_MIN\", po::value<uint64_t>()->default_value(0), \"uint64_t\")"
8187
]
8288
}
8389
},
@@ -91,6 +97,9 @@
9197
" }",
9298
" if (options.count(\"ZAWY_DIFFICULTY_LAST_BLOCK\")) {",
9399
" ZAWY_DIFFICULTY_LAST_BLOCK = options[\"ZAWY_DIFFICULTY_LAST_BLOCK\"].as<uint32_t>();",
100+
" }",
101+
" if (options.count(\"ZAWY_DIFFICULTY_MIN\")) {",
102+
" ZAWY_DIFFICULTY_MIN = options[\"ZAWY_DIFFICULTY_MIN\"].as<uint64_t>();",
94103
" }"
95104
]
96105
}
@@ -106,7 +115,8 @@
106115
"parameters": {
107116
"text": [
108117
" currencyBuilder.zawyDifficultyBlockIndex(config.coinBaseConfig.ZAWY_DIFFICULTY_BLOCK_INDEX);",
109-
" currencyBuilder.zawyDifficultyLastBlock(config.coinBaseConfig.ZAWY_DIFFICULTY_LAST_BLOCK);"
118+
" currencyBuilder.zawyDifficultyLastBlock(config.coinBaseConfig.ZAWY_DIFFICULTY_LAST_BLOCK);",
119+
" currencyBuilder.zawyDifficultyMin(config.coinBaseConfig.ZAWY_DIFFICULTY_MIN);"
110120
]
111121
}
112122
}
@@ -123,7 +133,8 @@
123133
"parameters": {
124134
"text": [
125135
" uint32_t ZAWY_DIFFICULTY_BLOCK_INDEX;",
126-
" uint32_t ZAWY_DIFFICULTY_LAST_BLOCK;"
136+
" uint32_t ZAWY_DIFFICULTY_LAST_BLOCK;",
137+
" uint64_t ZAWY_DIFFICULTY_MIN;"
127138
]
128139
}
129140
},
@@ -133,7 +144,8 @@
133144
"parameters": {
134145
"text": [
135146
" KV_MEMBER(ZAWY_DIFFICULTY_BLOCK_INDEX)",
136-
" KV_MEMBER(ZAWY_DIFFICULTY_LAST_BLOCK)"
147+
" KV_MEMBER(ZAWY_DIFFICULTY_LAST_BLOCK)",
148+
" KV_MEMBER(ZAWY_DIFFICULTY_MIN)"
137149
]
138150
}
139151
}
@@ -160,7 +172,8 @@
160172
"parameters": {
161173
"text": [
162174
" res.core.ZAWY_DIFFICULTY_BLOCK_INDEX = m_core.getCurrency().zawyDifficultyBlockIndex();",
163-
" res.core.ZAWY_DIFFICULTY_LAST_BLOCK = m_core.getCurrency().zawyDifficultyLastBlock();"
175+
" res.core.ZAWY_DIFFICULTY_LAST_BLOCK = m_core.getCurrency().zawyDifficultyLastBlock();",
176+
" res.core.ZAWY_DIFFICULTY_MIN = m_core.getCurrency().zawyDifficultyMin();"
164177
]
165178
}
166179
}

extensions/bytecoin-v2/multiply/zawy-lwma-difficulty-algorithm.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"text": [
1919
" const command_line::arg_descriptor<uint32_t> arg_ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX = {\"ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX\", \"uint32_t\", 0};",
2020
" const command_line::arg_descriptor<uint32_t> arg_ZAWY_LWMA_DIFFICULTY_LAST_BLOCK = {\"ZAWY_LWMA_DIFFICULTY_LAST_BLOCK\", \"uint32_t\", 0};",
21+
" const command_line::arg_descriptor<uint64_t> arg_ZAWY_LWMA_DIFFICULTY_MIN = {\"ZAWY_LWMA_DIFFICULTY_MIN\", \"uint64_t\", 1};",
2122
" const command_line::arg_descriptor<size_t> arg_ZAWY_LWMA_DIFFICULTY_N = {\"ZAWY_LWMA_DIFFICULTY_N\", \"size_t\", 0};"
2223
]
2324
}
@@ -29,6 +30,7 @@
2930
"text": [
3031
" command_line::add_arg(desc_cmd_sett, arg_ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX);",
3132
" command_line::add_arg(desc_cmd_sett, arg_ZAWY_LWMA_DIFFICULTY_LAST_BLOCK);",
33+
" command_line::add_arg(desc_cmd_sett, arg_ZAWY_LWMA_DIFFICULTY_MIN);",
3234
" command_line::add_arg(desc_cmd_sett, arg_ZAWY_LWMA_DIFFICULTY_N);"
3335
]
3436
}
@@ -40,6 +42,7 @@
4042
"text": [
4143
" currencyBuilder.zawyLWMADifficultyBlockIndex(command_line::get_arg(vm, arg_ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX));",
4244
" currencyBuilder.zawyLWMADifficultyLastBlock(command_line::get_arg(vm, arg_ZAWY_LWMA_DIFFICULTY_LAST_BLOCK));",
45+
" currencyBuilder.zawyLWMADifficultyMin(command_line::get_arg(vm, arg_ZAWY_LWMA_DIFFICULTY_MIN));",
4346
" currencyBuilder.zawyLWMADifficultyN(command_line::get_arg(vm, arg_ZAWY_LWMA_DIFFICULTY_N));"
4447
]
4548
}
@@ -56,6 +59,7 @@
5659
"text": [
5760
" uint32_t ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX;",
5861
" uint32_t ZAWY_LWMA_DIFFICULTY_LAST_BLOCK;",
62+
" uint64_t ZAWY_LWMA_DIFFICULTY_MIN;",
5963
" size_t ZAWY_LWMA_DIFFICULTY_N;"
6064
]
6165
}
@@ -72,6 +76,7 @@
7276
"text": [
7377
" ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX=CryptoNote::parameters::ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX;",
7478
" ZAWY_LWMA_DIFFICULTY_LAST_BLOCK=CryptoNote::parameters::ZAWY_LWMA_DIFFICULTY_LAST_BLOCK;",
79+
" ZAWY_LWMA_DIFFICULTY_MIN=CryptoNote::parameters::ZAWY_LWMA_DIFFICULTY_MIN;",
7580
" ZAWY_LWMA_DIFFICULTY_N=CryptoNote::parameters::ZAWY_LWMA_DIFFICULTY_N;"
7681
]
7782
}
@@ -83,6 +88,7 @@
8388
"text": [
8489
" (\"ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX\", po::value<uint32_t>()->default_value(0), \"uint32_t\")",
8590
" (\"ZAWY_LWMA_DIFFICULTY_LAST_BLOCK\", po::value<uint32_t>()->default_value(0), \"uint32_t\")",
91+
" (\"ZAWY_LWMA_DIFFICULTY_MIN\", po::value<uint64_t>()->default_value(1), \"uint64_t\")",
8692
" (\"ZAWY_LWMA_DIFFICULTY_N\", po::value<size_t>()->default_value(0), \"size_t\")"
8793
]
8894
}
@@ -98,6 +104,9 @@
98104
" if (options.count(\"ZAWY_LWMA_DIFFICULTY_LAST_BLOCK\")) {",
99105
" ZAWY_LWMA_DIFFICULTY_LAST_BLOCK = options[\"ZAWY_LWMA_DIFFICULTY_LAST_BLOCK\"].as<uint32_t>();",
100106
" }",
107+
" if (options.count(\"ZAWY_LWMA_DIFFICULTY_MIN\")) {",
108+
" ZAWY_LWMA_DIFFICULTY_MIN = options[\"ZAWY_LWMA_DIFFICULTY_MIN\"].as<uint64_t>();",
109+
" }",
101110
" if (options.count(\"ZAWY_LWMA_DIFFICULTY_N\")) {",
102111
" ZAWY_LWMA_DIFFICULTY_N = options[\"ZAWY_LWMA_DIFFICULTY_N\"].as<size_t>();",
103112
" }"
@@ -116,6 +125,7 @@
116125
"text": [
117126
" currencyBuilder.zawyLWMADifficultyBlockIndex(config.coinBaseConfig.ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX);",
118127
" currencyBuilder.zawyLWMADifficultyLastBlock(config.coinBaseConfig.ZAWY_LWMA_DIFFICULTY_LAST_BLOCK);",
128+
" currencyBuilder.zawyLWMADifficultyMin(config.coinBaseConfig.ZAWY_LWMA_DIFFICULTY_MIN);",
119129
" currencyBuilder.zawyLWMADifficultyN(config.coinBaseConfig.ZAWY_LWMA_DIFFICULTY_N);"
120130
]
121131
}
@@ -134,7 +144,8 @@
134144
"text": [
135145
" uint32_t ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX;",
136146
" uint32_t ZAWY_LWMA_DIFFICULTY_LAST_BLOCK;",
137-
" uint32_t ZAWY_LWMA_DIFFICULTY_N;"
147+
" uint64_t ZAWY_LWMA_DIFFICULTY_MIN;",
148+
" size_t ZAWY_LWMA_DIFFICULTY_N;"
138149
]
139150
}
140151
},
@@ -145,6 +156,7 @@
145156
"text": [
146157
" KV_MEMBER(ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX)",
147158
" KV_MEMBER(ZAWY_LWMA_DIFFICULTY_LAST_BLOCK)",
159+
" KV_MEMBER(ZAWY_LWMA_DIFFICULTY_MIN)",
148160
" KV_MEMBER(ZAWY_LWMA_DIFFICULTY_N)"
149161
]
150162
}
@@ -173,6 +185,7 @@
173185
"text": [
174186
" res.core.ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX = m_core.getCurrency().zawyLWMADifficultyBlockIndex();",
175187
" res.core.ZAWY_LWMA_DIFFICULTY_LAST_BLOCK = m_core.getCurrency().zawyLWMADifficultyLastBlock();",
188+
" res.core.ZAWY_LWMA_DIFFICULTY_MIN = m_core.getCurrency().zawyLWMADifficultyMin();",
176189
" res.core.ZAWY_LWMA_DIFFICULTY_N = m_core.getCurrency().zawyLWMADifficultyN();"
177190
]
178191
}

extensions/bytecoin-v2/zawy-difficulty-algorithm.json

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"parameters": {
1616
"text": [
1717
" uint32_t m_zawyDifficultyBlockIndex;",
18-
" uint32_t m_zawyDifficultyLastBlock;"
18+
" uint32_t m_zawyDifficultyLastBlock;",
19+
" uint64_t m_zawyDifficultyMin;"
1920
]
2021
}
2122
},
@@ -25,7 +26,8 @@
2526
"parameters": {
2627
"text": [
2728
" CurrencyBuilder& zawyDifficultyBlockIndex(uint32_t val) { m_currency.m_zawyDifficultyBlockIndex = val; return *this; }",
28-
" CurrencyBuilder& zawyDifficultyLastBlock(uint32_t val) { m_currency.m_zawyDifficultyLastBlock = val; return *this; }"
29+
" CurrencyBuilder& zawyDifficultyLastBlock(uint32_t val) { m_currency.m_zawyDifficultyLastBlock = val; return *this; }",
30+
" CurrencyBuilder& zawyDifficultyMin(uint64_t val) { m_currency.m_zawyDifficultyMin = val; return *this; }"
2931
]
3032
}
3133
},
@@ -35,7 +37,8 @@
3537
"parameters": {
3638
"text": [
3739
" uint32_t zawyDifficultyBlockIndex() const { return m_zawyDifficultyBlockIndex; }",
38-
" uint32_t zawyDifficultyLastBlock() const { return m_zawyDifficultyLastBlock; }"
40+
" uint32_t zawyDifficultyLastBlock() const { return m_zawyDifficultyLastBlock; }",
41+
" uint64_t zawyDifficultyMin() const { return m_zawyDifficultyMin; }"
3942
]
4043
}
4144
}
@@ -50,7 +53,8 @@
5053
"parameters": {
5154
"text": [
5255
"zawyDifficultyBlockIndex(parameters::ZAWY_DIFFICULTY_BLOCK_INDEX);",
53-
"zawyDifficultyLastBlock(parameters::ZAWY_DIFFICULTY_LAST_BLOCK);"
56+
"zawyDifficultyLastBlock(parameters::ZAWY_DIFFICULTY_LAST_BLOCK);",
57+
"zawyDifficultyMin(parameters::ZAWY_DIFFICULTY_MIN);"
5458
]
5559
}
5660
},
@@ -60,7 +64,8 @@
6064
"parameters": {
6165
"text": [
6266
"m_zawyDifficultyBlockIndex(currency.m_zawyDifficultyBlockIndex),",
63-
"m_zawyDifficultyLastBlock(currency.m_zawyDifficultyLastBlock),"
67+
"m_zawyDifficultyLastBlock(currency.m_zawyDifficultyLastBlock),",
68+
"m_zawyDifficultyMin(currency.m_zawyDifficultyMin),"
6469
]
6570
}
6671
}
@@ -102,6 +107,24 @@
102107
}
103108
]
104109
},
110+
{
111+
"path": "/src/CryptoNoteConfig.h",
112+
"changes": [
113+
{
114+
"action": "add_above",
115+
"marker": "const unsigned EMISSION_SPEED_FACTOR",
116+
"parameters": {
117+
"text": [
118+
"const uint64_t ZAWY_DIFFICULTY_MIN = %s;"
119+
],
120+
"replace_text_alt": [
121+
"const uint64_t ZAWY_DIFFICULTY_MIN = 1;"
122+
],
123+
"var": "ZAWY_DIFFICULTY_MIN"
124+
}
125+
}
126+
]
127+
},
105128
{
106129
"path": "/src/CryptoNoteCore/Currency.h",
107130
"changes": [
@@ -193,8 +216,8 @@
193216
" }",
194217

195218
" uint64_t nextDiffZ = low / timeSpan;",
196-
" if (nextDiffZ <= 1) {",
197-
" nextDiffZ = 1;",
219+
" if (nextDiffZ <= m_zawyDifficultyMin) {",
220+
" nextDiffZ = m_zawyDifficultyMin;",
198221
" }",
199222
" return nextDiffZ;",
200223
"}",

extensions/bytecoin-v2/zawy-lwma-difficulty-algorithm.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"text": [
1818
" uint32_t m_zawyLWMADifficultyBlockIndex;",
1919
" uint32_t m_zawyLWMADifficultyLastBlock;",
20+
" uint64_t m_zawyLWMADifficultyMin;",
2021
" size_t m_zawyLWMADifficultyN;"
2122
]
2223
}
@@ -28,6 +29,7 @@
2829
"text": [
2930
" CurrencyBuilder& zawyLWMADifficultyBlockIndex(uint32_t val) { m_currency.m_zawyLWMADifficultyBlockIndex = val; return *this; }",
3031
" CurrencyBuilder& zawyLWMADifficultyLastBlock(uint32_t val) { m_currency.m_zawyLWMADifficultyLastBlock = val; return *this; }",
32+
" CurrencyBuilder& zawyLWMADifficultyMin(uint64_t val) { m_currency.m_zawyLWMADifficultyMin = val; return *this; }",
3133
" CurrencyBuilder& zawyLWMADifficultyN(size_t val) { m_currency.m_zawyLWMADifficultyN = val; return *this; }"
3234
]
3335
}
@@ -39,6 +41,7 @@
3941
"text": [
4042
" uint32_t zawyLWMADifficultyBlockIndex() const { return m_zawyLWMADifficultyBlockIndex; }",
4143
" uint32_t zawyLWMADifficultyLastBlock() const { return m_zawyLWMADifficultyLastBlock; }",
44+
" uint64_t zawyLWMADifficultyMin() const { return m_zawyLWMADifficultyMin; }",
4245
" size_t zawyLWMADifficultyN() const { return m_zawyLWMADifficultyN; }"
4346
]
4447
}
@@ -55,6 +58,7 @@
5558
"text": [
5659
"zawyLWMADifficultyBlockIndex(parameters::ZAWY_LWMA_DIFFICULTY_BLOCK_INDEX);",
5760
"zawyLWMADifficultyLastBlock(parameters::ZAWY_LWMA_DIFFICULTY_LAST_BLOCK);",
61+
"zawyLWMADifficultyMin(parameters::ZAWY_LWMA_DIFFICULTY_MIN);",
5862
"zawyLWMADifficultyN(parameters::ZAWY_LWMA_DIFFICULTY_N);"
5963
]
6064
}
@@ -66,6 +70,7 @@
6670
"text": [
6771
"m_zawyLWMADifficultyBlockIndex(currency.m_zawyLWMADifficultyBlockIndex),",
6872
"m_zawyLWMADifficultyLastBlock(currency.m_zawyLWMADifficultyLastBlock),",
73+
"m_zawyLWMADifficultyMin(currency.m_zawyLWMADifficultyMin),",
6974
"m_zawyLWMADifficultyN(currency.m_zawyLWMADifficultyN),"
7075
]
7176
}
@@ -108,6 +113,24 @@
108113
}
109114
]
110115
},
116+
{
117+
"path": "/src/CryptoNoteConfig.h",
118+
"changes": [
119+
{
120+
"action": "add_above",
121+
"marker": "const unsigned EMISSION_SPEED_FACTOR",
122+
"parameters": {
123+
"text": [
124+
"const uint64_t ZAWY_LWMA_DIFFICULTY_MIN = %s;"
125+
],
126+
"replace_text_alt": [
127+
"const uint64_t ZAWY_LWMA_DIFFICULTY_MIN = 1;"
128+
],
129+
"var": "ZAWY_LWMA_DIFFICULTY_MIN"
130+
}
131+
}
132+
]
133+
},
111134
{
112135
"path": "/src/CryptoNoteConfig.h",
113136
"changes": [
@@ -222,8 +245,8 @@
222245
" next_difficulty = static_cast<uint64_t>(nextDifficulty);",
223246
" ",
224247
" // minimum limit",
225-
" if (next_difficulty < 1) {",
226-
" next_difficulty = 1;",
248+
" if (next_difficulty < m_zawyLWMADifficultyMin) {",
249+
" next_difficulty = m_zawyLWMADifficultyMin;",
227250
" }",
228251
"",
229252

0 commit comments

Comments
 (0)