@@ -108,23 +108,19 @@ void lowercase_hex_to_bytes(char const * hexDigest, uint8_t * rawDigest) {
108
108
}
109
109
110
110
// DUCO-S1A hasher
111
- uint32_t ducos1a (char const * prevBlockHash, char const * targetBlockHash, uint32_t difficulty ) {
111
+ uint32_t ducos1a () {
112
112
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)
113
113
// If the difficulty is too high for AVR architecture then return 0
114
- if (difficulty > 655 ) return 0 ;
114
+ if (job-> difficulty > 655 ) return 0 ;
115
115
#endif
116
116
117
117
uint8_t target[SHA1_HASH_LEN];
118
- lowercase_hex_to_bytes (targetBlockHash , target);
118
+ lowercase_hex_to_bytes (job-> newBlockHash , target);
119
119
120
- uint32_t const maxNonce = difficulty * 100 + 1 ;
121
- return ducos1a_mine (prevBlockHash, target, maxNonce);
122
- }
123
-
124
- uint32_t ducos1a_mine (char const * prevBlockHash, uint8_t const * target, uint32_t maxNonce) {
125
120
static duco_hash_state_t hash;
126
- duco_hash_init (&hash, prevBlockHash );
121
+ duco_hash_init (&hash, job-> lastBlockHash );
127
122
123
+ uint32_t const maxNonce = job->difficulty * 100 + 1 ;
128
124
char nonceStr[10 + 1 ];
129
125
for (uint32_t nonce = 0 ; nonce < maxNonce; nonce++) {
130
126
ultoa (nonce, nonceStr, 10 );
@@ -187,7 +183,7 @@ void hashEvent() {
187
183
uint32_t startTime = micros ();
188
184
189
185
// Call DUCO-S1A hasher
190
- uint32_t ducos1result = ducos1a (job-> lastBlockHash , job-> newBlockHash , job-> difficulty );
186
+ uint32_t ducos1result = ducos1a ();
191
187
192
188
// Calculate elapsed time
193
189
uint32_t elapsedTime = micros () - startTime;
0 commit comments