@@ -73,7 +73,10 @@ impl<T: Config> Pallet<T> {
73
73
// --- 9. Store the updated queue back to storage.
74
74
* maybe_commits = Some ( commits) ;
75
75
76
- // --- 10. Return ok.
76
+ // --- 10. Emit the WeightsCommitted event.
77
+ Self :: deposit_event ( Event :: WeightsCommitted ( who. clone ( ) , netuid, commit_hash) ) ;
78
+
79
+ // --- 11. Return ok.
77
80
Ok ( ( ) )
78
81
} )
79
82
}
@@ -198,9 +201,15 @@ impl<T: Config> Pallet<T> {
198
201
}
199
202
200
203
// --- 12. Proceed to set the revealed weights.
201
- Self :: do_set_weights ( origin, netuid, uids, values, version_key)
204
+ Self :: do_set_weights ( origin, netuid, uids. clone ( ) , values. clone ( ) , version_key) ?;
205
+
206
+ // --- 13. Emit the WeightsRevealed event.
207
+ Self :: deposit_event ( Event :: WeightsRevealed ( who. clone ( ) , netuid, provided_hash) ) ;
208
+
209
+ // --- 14. Return ok.
210
+ Ok ( ( ) )
202
211
} else {
203
- // --- 13 . The provided_hash does not match any non-expired commits.
212
+ // --- 15 . The provided_hash does not match any non-expired commits.
204
213
if expired_hashes. contains ( & provided_hash) {
205
214
Err ( Error :: < T > :: ExpiredWeightCommit . into ( ) )
206
215
} else {
@@ -302,6 +311,7 @@ impl<T: Config> Pallet<T> {
302
311
// --- 6. Prepare to collect all provided hashes and their corresponding reveals.
303
312
let mut provided_hashes = Vec :: new ( ) ;
304
313
let mut reveals = Vec :: new ( ) ;
314
+ let mut revealed_hashes: Vec < H256 > = Vec :: with_capacity ( num_reveals) ;
305
315
306
316
for ( ( uids, values) , ( salt, version_key) ) in uids_list
307
317
. into_iter ( )
@@ -361,6 +371,9 @@ impl<T: Config> Pallet<T> {
361
371
362
372
// --- 8c. Proceed to set the revealed weights.
363
373
Self :: do_set_weights ( origin. clone ( ) , netuid, uids, values, version_key) ?;
374
+
375
+ // --- 8d. Collect the revealed hash.
376
+ revealed_hashes. push ( provided_hash) ;
364
377
} else if expired_hashes. contains ( & provided_hash) {
365
378
return Err ( Error :: < T > :: ExpiredWeightCommit . into ( ) ) ;
366
379
} else {
@@ -373,7 +386,14 @@ impl<T: Config> Pallet<T> {
373
386
* maybe_commits = None ;
374
387
}
375
388
376
- // --- 10. Return ok.
389
+ // --- 10. Emit the WeightsBatchRevealed event with all revealed hashes.
390
+ Self :: deposit_event ( Event :: WeightsBatchRevealed (
391
+ who. clone ( ) ,
392
+ netuid,
393
+ revealed_hashes,
394
+ ) ) ;
395
+
396
+ // --- 11. Return ok.
377
397
Ok ( ( ) )
378
398
} )
379
399
}
0 commit comments