Skip to content

Commit

Permalink
fix: retry Filecoin.StateMinerInfo requests
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <[email protected]>
  • Loading branch information
bajtos committed Sep 23, 2024
1 parent 22bdec7 commit 914800c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/miner-info.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { retry } from '../vendor/deno-deps.js'
import { RPC_URL, RPC_AUTH } from './constants.js'

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

0 comments on commit 914800c

Please sign in to comment.