@@ -24,7 +24,7 @@ use amaru_kernel::{
24
24
Slot , StakeCredential , TransactionInput , TransactionOutput , STAKE_CREDENTIAL_DEPOSIT ,
25
25
} ;
26
26
use std:: {
27
- collections:: { BTreeMap , BTreeSet } ,
27
+ collections:: { BTreeMap , BTreeSet , HashMap } ,
28
28
vec,
29
29
} ;
30
30
use tracing:: { trace, trace_span, Span } ;
@@ -84,6 +84,7 @@ pub fn apply(
84
84
& mut state. pools ,
85
85
& mut state. accounts ,
86
86
& mut state. dreps ,
87
+ & mut state. committee ,
87
88
certificate,
88
89
CertificatePointer {
89
90
slot : absolute_slot,
@@ -211,6 +212,7 @@ fn apply_certificate(
211
212
pools : & mut DiffEpochReg < PoolId , PoolParams > ,
212
213
accounts : & mut DiffBind < StakeCredential , PoolId , ( DRep , CertificatePointer ) , Lovelace > ,
213
214
dreps : & mut DiffBind < StakeCredential , Anchor , Empty , ( Lovelace , CertificatePointer ) > ,
215
+ committee : & mut HashMap < StakeCredential , StakeCredential > ,
214
216
certificate : Certificate ,
215
217
pointer : CertificatePointer ,
216
218
) {
@@ -264,29 +266,41 @@ fn apply_certificate(
264
266
}
265
267
Certificate :: StakeVoteDeleg ( credential, pool, drep) => {
266
268
let drep_deleg = Certificate :: VoteDeleg ( credential. clone ( ) , drep) ;
267
- apply_certificate ( parent, pools, accounts, dreps, drep_deleg, pointer) ;
269
+ apply_certificate (
270
+ parent, pools, accounts, dreps, committee, drep_deleg, pointer,
271
+ ) ;
268
272
let pool_deleg = Certificate :: StakeDelegation ( credential, pool) ;
269
- apply_certificate ( parent, pools, accounts, dreps, pool_deleg, pointer) ;
273
+ apply_certificate (
274
+ parent, pools, accounts, dreps, committee, pool_deleg, pointer,
275
+ ) ;
270
276
}
271
277
Certificate :: StakeRegDeleg ( credential, pool, coin) => {
272
278
let reg = Certificate :: Reg ( credential. clone ( ) , coin) ;
273
- apply_certificate ( parent, pools, accounts, dreps, reg, pointer) ;
279
+ apply_certificate ( parent, pools, accounts, dreps, committee , reg, pointer) ;
274
280
let pool_deleg = Certificate :: StakeDelegation ( credential, pool) ;
275
- apply_certificate ( parent, pools, accounts, dreps, pool_deleg, pointer) ;
281
+ apply_certificate (
282
+ parent, pools, accounts, dreps, committee, pool_deleg, pointer,
283
+ ) ;
276
284
}
277
285
Certificate :: StakeVoteRegDeleg ( credential, pool, drep, coin) => {
278
286
let reg = Certificate :: Reg ( credential. clone ( ) , coin) ;
279
- apply_certificate ( parent, pools, accounts, dreps, reg, pointer) ;
287
+ apply_certificate ( parent, pools, accounts, dreps, committee , reg, pointer) ;
280
288
let pool_deleg = Certificate :: StakeDelegation ( credential. clone ( ) , pool) ;
281
- apply_certificate ( parent, pools, accounts, dreps, pool_deleg, pointer) ;
289
+ apply_certificate (
290
+ parent, pools, accounts, dreps, committee, pool_deleg, pointer,
291
+ ) ;
282
292
let drep_deleg = Certificate :: VoteDeleg ( credential, drep) ;
283
- apply_certificate ( parent, pools, accounts, dreps, drep_deleg, pointer) ;
293
+ apply_certificate (
294
+ parent, pools, accounts, dreps, committee, drep_deleg, pointer,
295
+ ) ;
284
296
}
285
297
Certificate :: VoteRegDeleg ( credential, drep, coin) => {
286
298
let reg = Certificate :: Reg ( credential. clone ( ) , coin) ;
287
- apply_certificate ( parent, pools, accounts, dreps, reg, pointer) ;
299
+ apply_certificate ( parent, pools, accounts, dreps, committee , reg, pointer) ;
288
300
let drep_deleg = Certificate :: VoteDeleg ( credential, drep) ;
289
- apply_certificate ( parent, pools, accounts, dreps, drep_deleg, pointer) ;
301
+ apply_certificate (
302
+ parent, pools, accounts, dreps, committee, drep_deleg, pointer,
303
+ ) ;
290
304
}
291
305
Certificate :: RegDRepCert ( drep, deposit, anchor) => {
292
306
trace ! ( target: EVENT_TARGET , parent: parent, drep = ?drep, deposit = ?deposit, anchor = ?anchor, "certificate.drep.registration" ) ;
@@ -308,7 +322,13 @@ fn apply_certificate(
308
322
. bind_right ( credential, Some ( ( drep, pointer) ) )
309
323
. unwrap ( ) ;
310
324
}
311
- // FIXME: Process other types of certificates
312
- Certificate :: AuthCommitteeHot { .. } | Certificate :: ResignCommitteeCold { .. } => { }
325
+ Certificate :: AuthCommitteeHot ( cold_credential, hot_credential) => {
326
+ trace ! ( name: "committee.hot_key" , target: EVENT_TARGET , parent: parent, cold_credential = ?cold_credential, hot_credential = ?hot_credential) ;
327
+ committee. insert ( cold_credential, hot_credential) ;
328
+ }
329
+ Certificate :: ResignCommitteeCold ( cold_credential, anchor) => {
330
+ trace ! ( name: "committee.hot_key" , target: EVENT_TARGET , parent: parent, cold_credential = ?cold_credential, anchor = ?anchor) ;
331
+ committee. remove ( & cold_credential) ;
332
+ }
313
333
}
314
334
}
0 commit comments