Skip to content

Commit 914800c

Browse files
committed
fix: retry Filecoin.StateMinerInfo requests
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
1 parent 22bdec7 commit 914800c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/miner-info.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { retry } from '../vendor/deno-deps.js'
12
import { RPC_URL, RPC_AUTH } from './constants.js'
23

34
/**
@@ -6,7 +7,14 @@ import { RPC_URL, RPC_AUTH } from './constants.js'
67
*/
78
export async function getMinerPeerId (minerId) {
89
try {
9-
const res = await rpc('Filecoin.StateMinerInfo', minerId, null)
10+
const res = await retry(() => rpc('Filecoin.StateMinerInfo', minerId, null), {
11+
// The maximum amount of attempts until failure.
12+
maxAttempts: 5,
13+
// The initial and minimum amount of milliseconds between attempts.
14+
minTimeout: 5_000,
15+
// How much to backoff after each retry.
16+
multiplier: 1.5
17+
})
1018
return res.PeerId
1119
} catch (err) {
1220
err.message = `Cannot obtain miner info for ${minerId}: ${err.message}`

0 commit comments

Comments
 (0)