You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To sync clocks effectively for real-time games, it would be really helpful to be able to get the unix wall time in ms when the last block was created. What I've been doing up until now is start anvil with a script like this:
function checkTimestamp() {
const timestamp = Date.now();
if ((timestamp + 25) % 1000 === 0) {
console.log(`Timestamp ${timestamp} is divisible by 1000.`);
process.exit(0); // Stop the program
} else {
setImmediate(checkTimestamp);
}
}
console.log("Waiting for a timestamp divisible by 1000...");
checkTimestamp();
// startup anvil
But the interval between anvil's blocks sometimes drifts a little, resulting in timestamps drifting backwards or ahead of real time. Having an rpc method to get the exact offset would allow clients to adjust to any minor timestamp offset without the need for anvil to robustly sync to wall time.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Component
Anvil
Describe the feature you would like
To sync clocks effectively for real-time games, it would be really helpful to be able to get the unix wall time in ms when the last block was created. What I've been doing up until now is start anvil with a script like this:
But the interval between anvil's blocks sometimes drifts a little, resulting in timestamps drifting backwards or ahead of real time. Having an rpc method to get the exact offset would allow clients to adjust to any minor timestamp offset without the need for anvil to robustly sync to wall time.
Additional context
No response
The text was updated successfully, but these errors were encountered: