@@ -58,25 +58,25 @@ export class MultipleTracker implements migrator.PresignedMigrationTracker, Conf
58
58
) { }
59
59
60
60
async configOfImageHash ( args : { imageHash : string } ) : Promise < commons . config . Config | undefined > {
61
- const requests = this . trackers . map ( async ( t , i ) => ( { res : await t . configOfImageHash ( args ) , i } ) )
61
+ const requestFactory = this . trackers . map ( ( t , i ) => async ( ) => ( { res : await t . configOfImageHash ( args ) , i } ) )
62
62
63
63
let result1 : { res : commons . config . Config | undefined ; i : number } | undefined
64
64
65
65
if ( this . isSerial ) {
66
- result1 = await serialResolve (
67
- requests . map ( p => ( ) => p ) ,
66
+ result1 = await serialResolve ( requestFactory , undefined , val => {
67
+ if ( val ?. res === undefined ) return false
68
+ return universal . genericCoderFor ( val . res . version ) . config . isComplete ( val . res )
69
+ } )
70
+ } else {
71
+ // We try to find a complete configuration, we race so that we don't wait for all trackers to respond
72
+ result1 = await raceUntil (
73
+ requestFactory . map ( p => p ( ) ) ,
68
74
undefined ,
69
75
val => {
70
76
if ( val ?. res === undefined ) return false
71
77
return universal . genericCoderFor ( val . res . version ) . config . isComplete ( val . res )
72
78
}
73
79
)
74
- } else {
75
- // We try to find a complete configuration, we race so that we don't wait for all trackers to respond
76
- result1 = await raceUntil ( requests , undefined , val => {
77
- if ( val ?. res === undefined ) return false
78
- return universal . genericCoderFor ( val . res . version ) . config . isComplete ( val . res )
79
- } )
80
80
}
81
81
82
82
if ( result1 ?. res ) {
@@ -90,7 +90,10 @@ export class MultipleTracker implements migrator.PresignedMigrationTracker, Conf
90
90
// but we try to combine all results anyway
91
91
const tmptracker = new LocalConfigTracker ( undefined as any ) // TODO: Fix this, provider not needed anyway
92
92
93
- const results = await allSafe ( requests , undefined )
93
+ const results = await allSafe (
94
+ requestFactory . map ( p => p ( ) ) ,
95
+ undefined
96
+ )
94
97
95
98
for ( const r of results ) {
96
99
if ( r ?. res ) await tmptracker . saveWalletConfig ( { config : r . res } )
@@ -114,16 +117,16 @@ export class MultipleTracker implements migrator.PresignedMigrationTracker, Conf
114
117
wallet : string
115
118
} ) : Promise < { imageHash : string ; context : commons . context . WalletContext } | undefined > {
116
119
let imageHash : { imageHash : string ; context : commons . context . WalletContext } | undefined
117
- const requests = this . trackers . map ( t => t . imageHashOfCounterfactualWallet ( args ) )
120
+ const requestFactory = this . trackers . map ( t => ( ) => t . imageHashOfCounterfactualWallet ( args ) )
118
121
119
122
if ( this . isSerial ) {
120
- imageHash = await serialResolve (
121
- requests . map ( p => ( ) => p ) ,
123
+ imageHash = await serialResolve ( requestFactory , undefined , result => Boolean ( result ) )
124
+ } else {
125
+ imageHash = await raceUntil (
126
+ requestFactory . map ( p => p ( ) ) ,
122
127
undefined ,
123
128
result => Boolean ( result )
124
129
)
125
- } else {
126
- imageHash = await raceUntil ( requests , undefined , result => Boolean ( result ) )
127
130
}
128
131
129
132
if ( imageHash ) {
0 commit comments