Skip to content

Commit ef87d5a

Browse files
authored
Merge branch 'blockworks-foundation:main' into main
2 parents 6367487 + 8bf6fdb commit ef87d5a

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

scripts/api.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,24 @@ export async function getGovernanceAccounts<TAccount extends GovernanceAccount>(
6969
)
7070
}
7171

72-
const promises: Promise<Record<string, ParsedAccount<TAccount>>>[] = []
73-
// workaround for preventing getting rate limited by public node
74-
// 1/ for of instead of map +
75-
// 2/ sleep a bit
72+
let accounts: Record<string, ParsedAccount<TAccount>> = {}
73+
7674
for (const at of accountTypes) {
77-
await new Promise((r) => setTimeout(r, 3000))
78-
promises.push(
79-
getGovernanceAccountsImpl<TAccount>(
75+
accounts = {
76+
...accounts,
77+
...(await getGovernanceAccountsImpl(
8078
programId,
8179
endpoint,
8280
accountClass,
8381
at,
8482
filters
85-
)
86-
)
83+
)),
84+
}
85+
// XXX: sleep to prevent public RPC rate limits
86+
await new Promise((r) => setTimeout(r, 3_000))
8787
}
8888

89-
const all = await Promise.all(promises)
90-
91-
return all.reduce((res, r) => ({ ...res, ...r }), {})
89+
return accounts
9290
}
9391

9492
async function getGovernanceAccountsImpl<TAccount extends GovernanceAccount>(

scripts/governance-notifier.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,7 @@ async function runNotifier() {
109109
)
110110
}
111111

112+
// start notifier immediately
113+
errorWrapper()
114+
112115
setInterval(errorWrapper, fiveMinutesSeconds * 1000)

0 commit comments

Comments
 (0)