11// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22// SPDX-License-Identifier: Apache-2.0
33
4+ use bip39:: Mnemonic ;
45use std:: collections:: HashMap ;
56use std:: sync:: Arc ;
67use thegraph_core:: { Address , ChainId } ;
@@ -18,12 +19,13 @@ use crate::prelude::{Allocation, AttestationSigner};
1819/// An always up-to-date list of attestation signers, one for each of the indexer's allocations.
1920pub async fn attestation_signers (
2021 mut indexer_allocations_rx : Receiver < HashMap < Address , Allocation > > ,
21- indexer_mnemonic : String ,
22+ indexer_mnemonic : Mnemonic ,
2223 chain_id : ChainId ,
2324 mut dispute_manager_rx : Receiver < Option < Address > > ,
2425) -> Receiver < HashMap < Address , AttestationSigner > > {
2526 let attestation_signers_map: & ' static Mutex < HashMap < Address , AttestationSigner > > =
2627 Box :: leak ( Box :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ) ;
28+ let indexer_mnemonic = indexer_mnemonic. to_string ( ) ;
2729
2830 let starter_signers_map = modify_sigers (
2931 Arc :: new ( indexer_mnemonic. clone ( ) ) ,
@@ -91,14 +93,17 @@ async fn modify_sigers(
9193 if !signers. contains_key ( id) {
9294 let signer =
9395 AttestationSigner :: new ( & indexer_mnemonic, allocation, chain_id, dispute_manager) ;
94- if let Err ( e) = signer {
95- warn ! (
96- "Failed to establish signer for allocation {}, deployment {}, createdAtEpoch {}: {}" ,
97- allocation. id, allocation. subgraph_deployment. id,
98- allocation. created_at_epoch, e
99- ) ;
100- } else {
101- signers. insert ( * id, signer. unwrap ( ) ) ;
96+ match signer {
97+ Ok ( signer) => {
98+ signers. insert ( * id, signer) ;
99+ }
100+ Err ( e) => {
101+ warn ! (
102+ "Failed to establish signer for allocation {}, deployment {}, createdAtEpoch {}: {}" ,
103+ allocation. id, allocation. subgraph_deployment. id,
104+ allocation. created_at_epoch, e
105+ ) ;
106+ }
102107 }
103108 }
104109 }
@@ -108,9 +113,7 @@ async fn modify_sigers(
108113
109114#[ cfg( test) ]
110115mod tests {
111- use crate :: test_vectors:: {
112- DISPUTE_MANAGER_ADDRESS , INDEXER_ALLOCATIONS , INDEXER_OPERATOR_MNEMONIC ,
113- } ;
116+ use crate :: test_vectors:: { DISPUTE_MANAGER_ADDRESS , INDEXER_ALLOCATIONS , INDEXER_MNEMONIC } ;
114117
115118 use super :: * ;
116119
@@ -123,7 +126,7 @@ mod tests {
123126 . unwrap ( ) ;
124127 let mut signers = attestation_signers (
125128 allocations_rx,
126- ( * INDEXER_OPERATOR_MNEMONIC ) . to_string ( ) ,
129+ INDEXER_MNEMONIC . clone ( ) ,
127130 1 ,
128131 dispute_manager_rx,
129132 )
0 commit comments