0xB10C / bademeister-go

Implementation of Bademeister, a mempool watcher and recorder, in Golang.
0 stars 3 forks source link

Use ntp instead of system time #8

Open OttoAllmendinger opened 5 years ago

OttoAllmendinger commented 5 years ago

Just an idea: the system is sometimes inaccurate. Since we don't really care about the system time, we could use NTP directly as a time source: https://github.com/beevik/ntp#querying-time-metadata

0xB10C commented 5 years ago

Agree that a NTP synchronized time could be beneficial. Might not be some to implement for a MVP i.e. is not high priority for me, but is a nice to have.

Some toughs, nothing set in stone yet:

I think it should be on-by-default, but not as a must if a user can't use it for some reason (e.g. behind a firewall and no connectivity to a NTP server). Passing a command line flag e.g. --no-ntp should disable this feature. Without the flag bademeisterd should do the NTP lookup once after startup and before starting the receiving of ZMQ transactions. The time offset can then be added to each transaction. Periodic NTP lookups may result in a different offset and in (sightly) shifted timestamps in the data when a new offset is applied. I think only the initial one is needed.

Open question: How to choose which NTP server to pick? E.g. don't want to pick an Australian NTP Server from Europe and vice versa. This is probably solved somehow, maybe by DNS stuff. Would need some more research.