From cfa284ffee724e4007ff08be92d4e96dafd32be8 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 15 Jun 2022 21:07:30 -0700 Subject: [PATCH] fix more compile errors --- cmd/server/main.go | 14 ++++++++------ common/cache.go | 8 ++++++++ frontend/service.go | 4 ---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 39222d3..cff8047 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -212,13 +212,15 @@ func main() { go common.BlockIngestor(rpcClient, cache, log, stopChan, cacheStart) // Compact transaction service initialization - service, err := frontend.NewSQLiteStreamer(rpcClient, cache, log) - if err != nil { - log.WithFields(logrus.Fields{ - "error": err, - }).Fatal("couldn't create SQL backend") + { + service, err := frontend.NewLwdStreamer(cache, chainName, opts.PingEnable) + if err != nil { + common.Log.WithFields(logrus.Fields{ + "error": err, + }).Fatal("couldn't create backend") + } + walletrpc.RegisterCompactTxStreamerServer(server, service) } - defer service.(*frontend.SqlStreamer).GracefulStop() // Register service walletrpc.RegisterCompactTxStreamerServer(server, service) diff --git a/common/cache.go b/common/cache.go index 22acae6..4ec6dc0 100644 --- a/common/cache.go +++ b/common/cache.go @@ -19,6 +19,7 @@ type BlockCache struct { FirstBlock int LastBlock int NextBlock int // height of the first block not in the cache + latestHash []byte // hash of the most recent (highest height) block, for detecting reorgs. m map[int]*BlockCacheEntry @@ -123,6 +124,13 @@ func (c *BlockCache) GetLatestHeight() int { return c.NextBlock - 1 } +// GetLatestHash returns the hash (block ID) of the most recent (highest) known block. +func (c *BlockCache) GetLatestHash() []byte { + c.mutex.RLock() + defer c.mutex.RUnlock() + return c.latestHash +} + func (c *BlockCache) GetLatestBlock() int { c.mutex.RLock() defer c.mutex.RUnlock() diff --git a/frontend/service.go b/frontend/service.go index 392ddfb..7f515bf 100644 --- a/frontend/service.go +++ b/frontend/service.go @@ -47,10 +47,6 @@ type SqlStreamer struct { log *logrus.Entry } -func NewSQLiteStreamer(client *rpcclient.Client, cache *common.BlockCache, log *logrus.Entry) (walletrpc.CompactTxStreamerServer, error) { - return &SqlStreamer{cache, client, log}, nil -} - func (s *SqlStreamer) GracefulStop() error { return nil }