From ac01a172143e8a8c08f1684b6e51fb765e1204e4 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 27 Jun 2022 18:52:37 -0400 Subject: [PATCH] fix estimate_timestamp --- hub/elastic_sync/db.py | 3 ++- hub/scribe/network.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hub/elastic_sync/db.py b/hub/elastic_sync/db.py index 0803383..00bc100 100644 --- a/hub/elastic_sync/db.py +++ b/hub/elastic_sync/db.py @@ -22,7 +22,8 @@ class ElasticSyncDB(SecondaryDB): if height in self.block_timestamp_cache: return self.block_timestamp_cache[height] header = self.prefix_db.header.get(height, deserialize_value=False) - timestamp = int(160.6855883050695 * height) if header else int.from_bytes(header[100:104], byteorder='little') + timestamp = int(self.coin.genesisTime + (self.coin.averageBlockOffset * height)) \ + if not header else int.from_bytes(header[100:104], byteorder='little') self.block_timestamp_cache[height] = timestamp return timestamp diff --git a/hub/scribe/network.py b/hub/scribe/network.py index 851b02b..58466f0 100644 --- a/hub/scribe/network.py +++ b/hub/scribe/network.py @@ -58,6 +58,9 @@ class LBCMainNet: proportionalDelayFactor = 32 maxTakeoverDelay = 4032 + averageBlockOffset = 160.31130145580738 + genesisTime = 1466660400 + @classmethod def sanitize_url(cls, url): # Remove surrounding ws and trailing /s