@@ -49,10 +49,10 @@ Whash_context_holder base_contexts;
49
49
50
50
void init_whirlcoin_hash_contexts ()
51
51
{
52
- sph_whirlpool1_init (& base_contexts .whirlpool1 );
53
- sph_whirlpool1_init (& base_contexts .whirlpool2 );
54
- sph_whirlpool1_init (& base_contexts .whirlpool3 );
55
- sph_whirlpool1_init (& base_contexts .whirlpool4 );
52
+ sph_whirlpool1_init (& base_contexts .whirlpool1 );
53
+ sph_whirlpool1_init (& base_contexts .whirlpool2 );
54
+ sph_whirlpool1_init (& base_contexts .whirlpool3 );
55
+ sph_whirlpool1_init (& base_contexts .whirlpool4 );
56
56
}
57
57
58
58
/*
@@ -62,10 +62,10 @@ void init_whirlcoin_hash_contexts()
62
62
static inline void
63
63
be32enc_vect (uint32_t * dst , const uint32_t * src , uint32_t len )
64
64
{
65
- uint32_t i ;
65
+ uint32_t i ;
66
66
67
- for (i = 0 ; i < len ; i ++ )
68
- dst [i ] = htobe32 (src [i ]);
67
+ for (i = 0 ; i < len ; i ++ )
68
+ dst [i ] = htobe32 (src [i ]);
69
69
}
70
70
71
71
@@ -74,33 +74,32 @@ static
74
74
#endif
75
75
inline void whirlcoin_hash (void * state , const void * input )
76
76
{
77
- init_whirlcoin_hash_contexts ();
77
+ init_whirlcoin_hash_contexts ();
78
78
79
- Whash_context_holder ctx ;
80
- uint32_t hashA [16 ], hashB [16 ];
79
+ Whash_context_holder ctx ;
80
+ uint32_t hashA [16 ], hashB [16 ];
81
81
82
- memcpy (& ctx , & base_contexts , sizeof (base_contexts ));
82
+ memcpy (& ctx , & base_contexts , sizeof (base_contexts ));
83
83
84
- sph_whirlpool1 (& ctx .whirlpool1 , input , 80 );
85
- sph_whirlpool1_close (& ctx .whirlpool1 , hashA );
84
+ sph_whirlpool1 (& ctx .whirlpool1 , input , 80 );
85
+ sph_whirlpool1_close (& ctx .whirlpool1 , hashA );
86
86
87
- sph_whirlpool1 (& ctx .whirlpool2 , hashA , 64 );
88
- sph_whirlpool1_close (& ctx .whirlpool2 , hashB );
87
+ sph_whirlpool1 (& ctx .whirlpool2 , hashA , 64 );
88
+ sph_whirlpool1_close (& ctx .whirlpool2 , hashB );
89
89
90
- sph_whirlpool1 (& ctx .whirlpool3 , hashB , 64 );
91
- sph_whirlpool1_close (& ctx .whirlpool3 , hashA );
90
+ sph_whirlpool1 (& ctx .whirlpool3 , hashB , 64 );
91
+ sph_whirlpool1_close (& ctx .whirlpool3 , hashA );
92
92
93
- sph_whirlpool1 (& ctx .whirlpool4 , hashA , 64 );
94
- sph_whirlpool1_close (& ctx .whirlpool4 , hashB );
93
+ sph_whirlpool1 (& ctx .whirlpool4 , hashA , 64 );
94
+ sph_whirlpool1_close (& ctx .whirlpool4 , hashB );
95
95
96
- memcpy (state , hashB , 32 );
96
+ memcpy (state , hashB , 32 );
97
97
}
98
98
99
99
static const uint32_t diff1targ = 0x0000ffff ;
100
100
101
-
102
101
/* Used externally as confirmation of correct OCL code */
103
- int whirlcoin_test (unsigned char * pdata , const unsigned char * ptarget , uint32_t nonce )
102
+ int whirlcoin_test_old (unsigned char * pdata , const unsigned char * ptarget , uint32_t nonce )
104
103
{
105
104
uint32_t tmp_hash7 , Htarg = le32toh (((const uint32_t * )ptarget )[7 ]);
106
105
uint32_t data [20 ], ohash [8 ];
@@ -124,51 +123,52 @@ int whirlcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t
124
123
125
124
void whirlcoin_regenhash (struct work * work )
126
125
{
127
- uint32_t data [20 ];
128
- uint32_t * nonce = (uint32_t * )(work -> data + 76 );
129
- uint32_t * ohash = (uint32_t * )(work -> hash );
126
+ uint32_t data [20 ];
127
+ uint32_t * nonce = (uint32_t * )(work -> data + 76 );
128
+ uint32_t * ohash = (uint32_t * )(work -> hash );
130
129
131
- be32enc_vect (data , (const uint32_t * )work -> data , 19 );
132
- data [19 ] = htobe32 (* nonce );
133
- whirlcoin_hash (ohash , data );
130
+ be32enc_vect (data , (const uint32_t * )work -> data , 19 );
131
+ data [19 ] = htobe32 (* nonce );
132
+ whirlcoin_hash (ohash , data );
134
133
}
135
-
134
+ /*
136
135
bool scanhash_whirlcoin(struct thr_info *thr, const unsigned char __maybe_unused *pmidstate,
137
- unsigned char * pdata , unsigned char __maybe_unused * phash1 ,
138
- unsigned char __maybe_unused * phash , const unsigned char * ptarget ,
139
- uint32_t max_nonce , uint32_t * last_nonce , uint32_t n )
136
+ unsigned char *pdata, unsigned char __maybe_unused *phash1,
137
+ unsigned char __maybe_unused *phash, const unsigned char *ptarget,
138
+ uint32_t max_nonce, uint32_t *last_nonce, uint32_t n)
140
139
{
141
- uint32_t * nonce = (uint32_t * )(pdata + 76 );
142
- uint32_t data [20 ];
143
- uint32_t tmp_hash7 ;
144
- uint32_t Htarg = le32toh (((const uint32_t * )ptarget )[7 ]);
145
- bool ret = false;
146
-
147
- be32enc_vect (data , (const uint32_t * )pdata , 19 );
148
-
149
- while (1 ) {
150
- uint32_t ostate [8 ];
151
-
152
- * nonce = ++ n ;
153
- data [19 ] = (n );
154
- whirlcoin_hash (ostate , data );
155
- tmp_hash7 = (ostate [7 ]);
156
-
157
- applog (LOG_INFO , "data7 %08lx" ,
158
- (long unsigned int )data [7 ]);
159
-
160
- if (unlikely (tmp_hash7 <= Htarg )) {
161
- ((uint32_t * )pdata )[19 ] = htobe32 (n );
162
- * last_nonce = n ;
163
- ret = true;
164
- break ;
165
- }
166
-
167
- if (unlikely ((n >= max_nonce ) || thr -> work_restart )) {
168
- * last_nonce = n ;
169
- break ;
170
- }
171
- }
172
-
173
- return ret ;
140
+ uint32_t *nonce = (uint32_t *)(pdata + 76);
141
+ uint32_t data[20];
142
+ uint32_t tmp_hash7;
143
+ uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]);
144
+ bool ret = false;
145
+
146
+ be32enc_vect(data, (const uint32_t *)pdata, 19);
147
+
148
+ while (1) {
149
+ uint32_t ostate[8];
150
+
151
+ *nonce = ++n;
152
+ data[19] = (n);
153
+ whirlcoin_hash(ostate, data);
154
+ tmp_hash7 = (ostate[7]);
155
+
156
+ applog(LOG_INFO, "data7 %08lx",
157
+ (long unsigned int)data[7]);
158
+
159
+ if (unlikely(tmp_hash7 <= Htarg)) {
160
+ ((uint32_t *)pdata)[19] = htobe32(n);
161
+ *last_nonce = n;
162
+ ret = true;
163
+ break;
164
+ }
165
+
166
+ if (unlikely((n >= max_nonce) || thr->work_restart)) {
167
+ *last_nonce = n;
168
+ break;
169
+ }
170
+ }
171
+
172
+ return ret;
174
173
}
174
+ */
0 commit comments