fix txcounts loading

This commit is contained in:
Jeffrey Picard 2022-03-09 18:09:03 +00:00
parent 7d492948ce
commit c66d07e8cc
2 changed files with 9 additions and 26 deletions

View file

@ -779,7 +779,7 @@ func InitTxCounts(db *ReadOnlyDBColumnFamily) error {
db.TxCounts = db_stack.NewSliceBackedStack(1200000) db.TxCounts = db_stack.NewSliceBackedStack(1200000)
options := NewIterateOptions().WithPrefix([]byte{prefixes.TxCount}).WithCfHandle(handle) 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) 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("len(db.TxCounts), cap(db.TxCounts):", db.TxCounts.Len(), db.TxCounts.Cap())
log.Println("Time to get txCounts:", duration) log.Println("Time to get txCounts:", duration)
// This needs to be len-1 because we start loading with the zero block // whjy not needs to be len-1 because we start loading with the zero block
// and the txcounts start at one. // and the txcounts start at one???
if db.TxCounts.Len() > 0 { db.Height = db.TxCounts.Len()
db.Height = db.TxCounts.Len() - 1 // if db.TxCounts.Len() > 0 {
} else { // db.Height = db.TxCounts.Len() - 1
log.Println("db.TxCounts.Len() == 0 ???") // } else {
} // log.Println("db.TxCounts.Len() == 0 ???")
// }
return nil return nil
} }

View file

@ -100,24 +100,6 @@ type PrefixRowKV struct {
Value interface{} 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 { type DBStateKey struct {
Prefix []byte `json:"prefix"` Prefix []byte `json:"prefix"`
} }