Last active
July 9, 2019 08:20
-
-
Save qianbin/4e44bf9e8dde997c04c58fef461b95ee to your computer and use it in GitHub Desktop.
calculate block number according to given time
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
// require connex-repl env | |
// calculate block number according to given time | |
async function whichBlock(targetTime) { | |
if(typeof targetTime === 'string') { | |
targetTime = new Date(targetTime).getTime() | |
} | |
return (await connex.thor.block().get()).number + Math.round((targetTime - Date.now()) / 1000 / 10) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment