diff --git a/blockbook.go b/blockbook.go index 77df065b..d92a4ddc 100644 --- a/blockbook.go +++ b/blockbook.go @@ -178,7 +178,7 @@ func main() { if err != nil { glog.Error("internalState: ", err) } - glog.Info("DB size on disk: ", index.DatabaseSizeOnDisk()) + glog.Info("DB size on disk: ", index.DatabaseSizeOnDisk(), ", DB size as computed: ", internalState.DBSizeTotal()) return } diff --git a/common/internalstate.go b/common/internalstate.go index 4f77470e..24c0b989 100644 --- a/common/internalstate.go +++ b/common/internalstate.go @@ -113,6 +113,16 @@ func (is *InternalState) SetDBColumnStats(c int, rowsDiff int64, keysSumDiff int is.DbColumns[c].ValuesSum = valuesSumDiff } +func (is *InternalState) DBSizeTotal() int64 { + is.mux.Lock() + defer is.mux.Unlock() + total := int64(0) + for _, c := range is.DbColumns { + total += c.KeysSum + c.ValuesSum + } + return total +} + func (is *InternalState) Pack() ([]byte, error) { is.mux.Lock() defer is.mux.Unlock()