-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update welo and enable bootstrap groups hang test.
- Loading branch information
Showing
5 changed files
with
46 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { CID } from 'multiformats/cid' | ||
import { Address } from 'welo' | ||
import { type Components, Config } from './interface.js' | ||
import type { Loggers } from '@/logger.js' | ||
|
||
type BootstrapComponents = Pick<Components, 'groups' | 'parseConfig' | 'welo'> & { logger: Loggers } | ||
|
||
export default async ({ groups, parseConfig, welo, logger }: BootstrapComponents): Promise<{ stop (): void }> => { | ||
const config = parseConfig(Config) | ||
const controller = new AbortController() | ||
|
||
Promise.allSettled(config.groups.map(async group => { | ||
if (groups.get(CID.parse(group)) != null) { | ||
return | ||
} | ||
|
||
try { | ||
const manifest = await welo.fetch(Address.fromString(`/hldb/${group}`), { | ||
signal: controller.signal | ||
}) | ||
|
||
await groups.add(manifest) | ||
} catch (error) { | ||
logger.warn(`Failed to bootstrap group '${group}'`) | ||
} | ||
})).catch(() => { | ||
// Ignore | ||
}) | ||
|
||
return { | ||
stop () { | ||
controller.abort() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters