diff --git a/gossip/service.go b/gossip/service.go index e3129cfb1..267c2b135 100644 --- a/gossip/service.go +++ b/gossip/service.go @@ -210,6 +210,7 @@ func newService(config Config, store *Store, blockProc BlockProc, engine lachesi svc.store.GetLastEVs() svc.store.GetLlrState() svc.store.GetUpgradeHeights() + svc.store.GetGenesisID() netVerStore := verwatcher.NewStore(store.table.NetworkVersion) netVerStore.GetNetworkVersion() netVerStore.GetMissedVersion() diff --git a/gossip/store.go b/gossip/store.go index 8c71884ef..1da5fe89f 100644 --- a/gossip/store.go +++ b/gossip/store.go @@ -79,6 +79,7 @@ type Store struct { LlrState atomic.Value // store by value KvdbEvmSnap atomic.Value // store by pointer UpgradeHeights atomic.Value // store by pointer + Genesis atomic.Value // store by value } mutex struct { diff --git a/gossip/store_block.go b/gossip/store_block.go index 6841da1db..7f81c5f6b 100644 --- a/gossip/store_block.go +++ b/gossip/store_block.go @@ -14,6 +14,10 @@ import ( ) func (s *Store) GetGenesisID() *hash.Hash { + if v := s.cache.Genesis.Load(); v != nil { + val := v.(hash.Hash) + return &val + } valBytes, err := s.table.Genesis.Get([]byte("g")) if err != nil { s.Log.Crit("Failed to get key-value", "err", err) @@ -22,6 +26,7 @@ func (s *Store) GetGenesisID() *hash.Hash { return nil } val := hash.BytesToHash(valBytes) + s.cache.Genesis.Store(val) return &val } @@ -38,6 +43,7 @@ func (s *Store) SetGenesisID(val hash.Hash) { if err != nil { s.Log.Crit("Failed to put key-value", "err", err) } + s.cache.Genesis.Store(val) } // SetBlock stores chain block.