@@ -140,29 +140,34 @@ export async function link(chainInfos: Ctx[]) {
140
140
const registrations : [ string , string , VAA < "Ntt:TransceiverRegistration" > ] [ ] =
141
141
[ ] ;
142
142
143
- for ( const targetInfo of chainInfos ) {
144
- const toRegister = chainInfos . filter (
145
- ( peerInfo ) => peerInfo . context . chain !== targetInfo . context . chain
146
- ) ;
147
-
148
- console . log (
149
- "Registering peers for " ,
150
- targetInfo . context . chain ,
151
- ": " ,
152
- toRegister . map ( ( x ) => x . context . chain )
153
- ) ;
154
-
155
- for ( const peerInfo of toRegister ) {
156
- const vaa = await setupPeer ( targetInfo , peerInfo ) ;
157
- if ( ! vaa ) throw new Error ( "No VAA found" ) ;
158
- // Add to registrations by PEER chain so we can register hub first
159
- registrations . push ( [
160
- targetInfo . context . chain ,
161
- peerInfo . context . chain ,
162
- vaa ,
163
- ] ) ;
164
- }
165
- }
143
+ // register each chain in parallel
144
+ await Promise . all (
145
+ chainInfos . map ( ( targetInfo ) =>
146
+ ( async ( ) => {
147
+ const toRegister = chainInfos . filter (
148
+ ( peerInfo ) => peerInfo . context . chain !== targetInfo . context . chain
149
+ ) ;
150
+
151
+ console . log (
152
+ "Registering peers for " ,
153
+ targetInfo . context . chain ,
154
+ ": " ,
155
+ toRegister . map ( ( x ) => x . context . chain )
156
+ ) ;
157
+
158
+ for ( const peerInfo of toRegister ) {
159
+ const vaa = await setupPeer ( targetInfo , peerInfo ) ;
160
+ if ( ! vaa ) throw new Error ( "No VAA found" ) ;
161
+ // Add to registrations by PEER chain so we can register hub first
162
+ registrations . push ( [
163
+ targetInfo . context . chain ,
164
+ peerInfo . context . chain ,
165
+ vaa ,
166
+ ] ) ;
167
+ }
168
+ } ) ( )
169
+ )
170
+ ) ;
166
171
167
172
// Push Hub to Spoke registrations
168
173
const hubToSpokeRegistrations = registrations . filter (
0 commit comments