-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathblock-delay.py
executable file
·34 lines (28 loc) · 1.09 KB
/
block-delay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
#******************************************************************************
# Copyright (C) 2020 potuz <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
import sys
from systemd import journal
from datetime import datetime
beacon_service = "beacon-chain.service"
genesis = 1606824023
def main(argv):
j = journal.Reader()
j.log_level(journal.LOG_INFO)
j.add_match(_SYSTEMD_UNIT=beacon_service)
j.add_match(MESSAGE="Synced new block")
j.add_match(SLOT=int(argv[1]))
msg = j.get_next()
ts = msg['_SOURCE_REALTIME_TIMESTAMP']
tg = datetime.fromtimestamp(genesis)
delta = ts - tg
print("Delay: {} seconds".format(delta.total_seconds()-12*int(argv[1])))
if __name__ == "__main__":
main(sys.argv)