|
65 | 65 | C: Client<B, BE, P>,
|
66 | 66 | {
|
67 | 67 | client: Arc<C>,
|
68 |
| - key_store: SyncCryptoStorePtr, |
| 68 | + key_store: Option<SyncCryptoStorePtr>, |
69 | 69 | signed_commitment_sender: notification::BeefySignedCommitmentSender<B, P::Signature>,
|
70 | 70 | gossip_engine: Arc<Mutex<GossipEngine<B>>>,
|
71 | 71 | gossip_validator: Arc<BeefyGossipValidator<B, P>>,
|
@@ -103,7 +103,7 @@ where
|
103 | 103 | /// The BEEFY pallet is needed in order to keep track of the BEEFY authority set.
|
104 | 104 | pub(crate) fn new(
|
105 | 105 | client: Arc<C>,
|
106 |
| - key_store: SyncCryptoStorePtr, |
| 106 | + key_store: Option<SyncCryptoStorePtr>, |
107 | 107 | signed_commitment_sender: notification::BeefySignedCommitmentSender<B, P::Signature>,
|
108 | 108 | gossip_engine: GossipEngine<B>,
|
109 | 109 | gossip_validator: Arc<BeefyGossipValidator<B, P>>,
|
@@ -158,7 +158,12 @@ where
|
158 | 158 | }
|
159 | 159 |
|
160 | 160 | fn sign_commitment(&self, id: &P::Public, commitment: &[u8]) -> Result<P::Signature, error::Crypto<P::Public>> {
|
161 |
| - let sig = SyncCryptoStore::sign_with(&*self.key_store, KEY_TYPE, &id.to_public_crypto_pair(), &commitment) |
| 161 | + let key_store = self |
| 162 | + .key_store |
| 163 | + .clone() |
| 164 | + .ok_or_else(|| error::Crypto::CannotSign((*id).clone(), "Missing KeyStore".into()))?; |
| 165 | + |
| 166 | + let sig = SyncCryptoStore::sign_with(&*key_store, KEY_TYPE, &id.to_public_crypto_pair(), &commitment) |
162 | 167 | .map_err(|e| error::Crypto::CannotSign((*id).clone(), e.to_string()))?
|
163 | 168 | .ok_or_else(|| error::Crypto::CannotSign((*id).clone(), "No key in KeyStore found".into()))?;
|
164 | 169 |
|
@@ -190,10 +195,12 @@ where
|
190 | 195 | ///
|
191 | 196 | /// `None` is returned, if we are not permitted to vote
|
192 | 197 | fn local_id(&self) -> Option<P::Public> {
|
| 198 | + let key_store = self.key_store.clone()?; |
| 199 | + |
193 | 200 | self.rounds
|
194 | 201 | .validators()
|
195 | 202 | .iter()
|
196 |
| - .find(|id| SyncCryptoStore::has_keys(&*self.key_store, &[(id.to_raw_vec(), KEY_TYPE)])) |
| 203 | + .find(|id| SyncCryptoStore::has_keys(&*key_store, &[(id.to_raw_vec(), KEY_TYPE)])) |
197 | 204 | .cloned()
|
198 | 205 | }
|
199 | 206 |
|
|
0 commit comments