@@ -37,18 +37,25 @@ pub struct CommitteeInfo {
37
37
38
38
impl CommitteeInfo {
39
39
/// Fetch the committee info for `committee_id` from `key_manager_addr` on chain
40
- pub async fn fetch ( rpc : Url , key_manager_addr : Address , committee_id : u64 ) -> Result < Self > {
40
+ pub async fn fetch (
41
+ rpc : Url ,
42
+ key_manager_addr : Address ,
43
+ committee_id : CommitteeId ,
44
+ ) -> Result < Self > {
41
45
let provider = ProviderBuilder :: new ( ) . connect_http ( rpc) ;
42
46
Self :: fetch_with ( provider, key_manager_addr, committee_id) . await
43
47
}
44
48
45
49
pub ( crate ) async fn fetch_with (
46
50
provider : impl Provider ,
47
51
key_manager_addr : Address ,
48
- committee_id : u64 ,
52
+ committee_id : CommitteeId ,
49
53
) -> Result < Self > {
50
54
let contract = KeyManager :: new ( key_manager_addr, & provider) ;
51
- let c = contract. getCommitteeById ( committee_id) . call ( ) . await ?;
55
+ let c = contract
56
+ . getCommitteeById ( committee_id. into ( ) )
57
+ . call ( )
58
+ . await ?;
52
59
53
60
let ( signing_keys, dh_keys, dkg_keys, public_addresses) = c
54
61
. members
@@ -69,7 +76,7 @@ impl CommitteeInfo {
69
76
. multiunzip ( ) ;
70
77
71
78
Ok ( Self {
72
- id : committee_id. into ( ) ,
79
+ id : committee_id,
73
80
timestamp : c. effectiveTimestamp . into ( ) ,
74
81
signing_keys,
75
82
dh_keys,
@@ -100,7 +107,7 @@ impl CommitteeInfo {
100
107
)
101
108
}
102
109
103
- pub fn group (
110
+ pub fn address_info (
104
111
& self ,
105
112
) -> impl Iterator < Item = ( multisig:: PublicKey , x25519:: PublicKey , cliquenet:: Address ) > {
106
113
izip ! (
@@ -111,7 +118,7 @@ impl CommitteeInfo {
111
118
}
112
119
113
120
pub fn sailfish_committee ( & self ) -> AddressableCommittee {
114
- AddressableCommittee :: new ( self . committee ( ) , self . group ( ) )
121
+ AddressableCommittee :: new ( self . committee ( ) , self . address_info ( ) )
115
122
}
116
123
117
124
pub fn decrypt_committee ( & self ) -> AddressableCommittee {
@@ -157,7 +164,7 @@ impl CommitteeInfo {
157
164
config : & ParentChain ,
158
165
) -> Result < NewCommitteeStream > {
159
166
let from_block = provider
160
- . get_block_number_by_timestamp ( start_ts. into ( ) )
167
+ . get_block_number_by_timestamp ( start_ts)
161
168
. await ?
162
169
. unwrap_or_default ( ) ;
163
170
let events = provider
@@ -176,11 +183,13 @@ impl CommitteeInfo {
176
183
let s = events. filter_map ( move |log| {
177
184
let provider = provider. clone ( ) ;
178
185
async move {
179
- let id = log. data ( ) . id ;
180
- match CommitteeInfo :: fetch_with ( provider. inner ( ) , key_manager_contract, id) . await {
186
+ let committee_id: CommitteeId = log. data ( ) . id . into ( ) ;
187
+ match CommitteeInfo :: fetch_with ( & * provider, key_manager_contract, committee_id)
188
+ . await
189
+ {
181
190
Ok ( comm_info) => Some ( comm_info) ,
182
- Err ( _ ) => {
183
- error ! ( committee_id = %id , "fail to fetch new CommitteeInfo" ) ;
191
+ Err ( err ) => {
192
+ error ! ( % committee_id, %err , "fail to fetch new ` CommitteeInfo` " ) ;
184
193
None
185
194
}
186
195
}
0 commit comments