set status every block, discord doesn't rate limit until 50 req/sec
This commit is contained in:
parent
5c3e1fdd6a
commit
4f5812c2b8
@ -20,19 +20,19 @@ export const subToBlockHeaders = (setDiscordStatus: () => Promise<void>) => {
|
||||
web3.eth.subscribe('newBlockHeaders', (error, blockHeader) => {
|
||||
if (error) console.error(error);
|
||||
|
||||
// Set status every 10 blocks
|
||||
const shouldSetStatus = blockHeader.number % 10 === 0;
|
||||
const shouldLogWei = blockHeader.number % 10 === 0;
|
||||
|
||||
// Get the gas price for this block
|
||||
web3.eth.getGasPrice((error, gasPrice) => {
|
||||
if (error) console.error(error);
|
||||
|
||||
if (shouldSetStatus) console.log('Gas price in wei:', gasPrice);
|
||||
if (shouldLogWei) console.log('Gas price in wei:', gasPrice);
|
||||
|
||||
redisClient.set('gas-price', Math.round(Number(gasPrice)))
|
||||
});
|
||||
|
||||
if (shouldSetStatus) setDiscordStatus()
|
||||
// Set status every block
|
||||
setDiscordStatus()
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user