From c66d07e8cc580a91f69a5cdcc52a6ac99acf6200 Mon Sep 17 00:00:00 2001 From: Jeffrey Picard Date: Wed, 9 Mar 2022 18:09:03 +0000 Subject: [PATCH] fix txcounts loading --- db/db.go | 17 +++++++++-------- db/prefixes/prefixes.go | 18 ------------------ 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/db/db.go b/db/db.go index ad4dfe2..4c8ea78 100644 --- a/db/db.go +++ b/db/db.go @@ -779,7 +779,7 @@ func InitTxCounts(db *ReadOnlyDBColumnFamily) error { db.TxCounts = db_stack.NewSliceBackedStack(1200000) options := NewIterateOptions().WithPrefix([]byte{prefixes.TxCount}).WithCfHandle(handle) - options = options.WithIncludeKey(false).WithIncludeValue(true) + options = options.WithIncludeKey(false).WithIncludeValue(true).WithIncludeStop(true) ch := IterCF(db.DB, options) @@ -791,13 +791,14 @@ func InitTxCounts(db *ReadOnlyDBColumnFamily) error { log.Println("len(db.TxCounts), cap(db.TxCounts):", db.TxCounts.Len(), db.TxCounts.Cap()) log.Println("Time to get txCounts:", duration) - // This needs to be len-1 because we start loading with the zero block - // and the txcounts start at one. - if db.TxCounts.Len() > 0 { - db.Height = db.TxCounts.Len() - 1 - } else { - log.Println("db.TxCounts.Len() == 0 ???") - } + // whjy not needs to be len-1 because we start loading with the zero block + // and the txcounts start at one??? + db.Height = db.TxCounts.Len() + // if db.TxCounts.Len() > 0 { + // db.Height = db.TxCounts.Len() - 1 + // } else { + // log.Println("db.TxCounts.Len() == 0 ???") + // } return nil } diff --git a/db/prefixes/prefixes.go b/db/prefixes/prefixes.go index ff6ac9e..fafeb14 100644 --- a/db/prefixes/prefixes.go +++ b/db/prefixes/prefixes.go @@ -100,24 +100,6 @@ type PrefixRowKV struct { Value interface{} } -/* -class DBState(typing.NamedTuple): - genesis: bytes - height: int - tx_count: int - tip: bytes - utxo_flush_count: int - wall_time: int - first_sync: bool - db_version: int - hist_flush_count: int - comp_flush_count: int - comp_cursor: int - es_sync_height: int - - -*/ - type DBStateKey struct { Prefix []byte `json:"prefix"` }