diff --git a/collector/node.go b/collector/node.go index 868ec21..5cc8a21 100644 --- a/collector/node.go +++ b/collector/node.go @@ -58,7 +58,7 @@ func (c *Collector) syncStatusPump() error { } status := res.GetStatus() -// log.Info("Node sync status: %v", status) + log.Info("Node sync status: %v", status) c.listener.OnNodeStatus( status.GetConnectedPeers(), diff --git a/model/account.go b/model/account.go index 8ad594c..45b1a1c 100644 --- a/model/account.go +++ b/model/account.go @@ -14,11 +14,6 @@ import ( type Account struct { Address string // account public address Balance uint64 // known account balance - Sent uint64 - Received uint64 - Awards uint64 - Fees uint64 - Timestamp uint32 Counter uint64 } diff --git a/storage/account.go b/storage/account.go index ed888d0..d52b443 100644 --- a/storage/account.go +++ b/storage/account.go @@ -17,7 +17,8 @@ import ( func (s *Storage) InitAccountsStorage(ctx context.Context) error { _, err := s.db.Collection("accounts").Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{"address", 1}}, Options: options.Index().SetName("addressIndex").SetUnique(true)}); - _, err = s.db.Collection("accounts").Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{"layer", -1}}, Options: options.Index().SetName("layerIndex").SetUnique(false)}); + _, err = s.db.Collection("accounts").Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{"created", 1}}, Options: options.Index().SetName("createIndex").SetUnique(false)}); + _, err = s.db.Collection("accounts").Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{"layer", -1}}, Options: options.Index().SetName("modifiedIndex").SetUnique(false)}); _, err = s.db.Collection("ledger").Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{"address", 1}}, Options: options.Index().SetName("addressIndex").SetUnique(false)}); _, err = s.db.Collection("ledger").Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{"layer", 1}}, Options: options.Index().SetName("layerIndex").SetUnique(false)}); return err @@ -81,6 +82,7 @@ func (s *Storage) AddAccount(parent context.Context, layer uint32, address strin defer cancel() _, err := s.db.Collection("accounts").InsertOne(ctx, bson.D{ {"address", address}, + {"created", layer}, {"layer", layer}, {"balance", balance}, {"counter", uint64(0)}, @@ -96,6 +98,7 @@ func (s *Storage) SaveAccount(parent context.Context, layer uint32, in *model.Ac defer cancel() _, err := s.db.Collection("accounts").InsertOne(ctx, bson.D{ {"address", in.Address}, + {"created", layer}, {"layer", layer}, {"balance", in.Balance}, {"counter", in.Counter}, diff --git a/storage/epoch.go b/storage/epoch.go index 93bcfcb..d74826a 100644 --- a/storage/epoch.go +++ b/storage/epoch.go @@ -288,7 +288,7 @@ func (s *Storage) computeStatistics(epoch *model.Epoch) { a := math.Min(float64(epoch.Stats.Current.Smeshers), 1e4) epoch.Stats.Current.Decentral = int64(100.0 * (0.5 * (a * a) /1e8 + 0.5 * (1.0 - utils.Gini(smeshers)))) } - epoch.Stats.Current.Accounts = s.GetAccountsCount(context.Background(), &bson.D{{"layer", bson.D{{"$lte", layerEnd}}}}) + epoch.Stats.Current.Accounts = s.GetAccountsCount(context.Background(), &bson.D{{"created", bson.D{{"$lte", layerEnd}}}}) epoch.Stats.Cumulative.Circulation, _ = s.GetLayersRewards(context.Background(), 0, layerEnd) epoch.Stats.Current.Rewards, epoch.Stats.Current.RewardsNumber = s.GetLayersRewards(context.Background(), layerStart, layerEnd) } diff --git a/storage/storage.go b/storage/storage.go index 56da062..85e1ae2 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -327,7 +327,8 @@ func (s *Storage) updateEpoch(epochNumber int32, prev *model.Epoch) *model.Epoch if prev != nil { epoch.Stats.Cumulative.Capacity = epoch.Stats.Current.Capacity epoch.Stats.Cumulative.Decentral = prev.Stats.Current.Decentral - epoch.Stats.Cumulative.Smeshers = prev.Stats.Current.Smeshers +// epoch.Stats.Cumulative.Smeshers = prev.Stats.Current.Smeshers + epoch.Stats.Cumulative.Smeshers = epoch.Stats.Current.Smeshers epoch.Stats.Cumulative.Transactions = prev.Stats.Cumulative.Transactions + epoch.Stats.Current.Transactions epoch.Stats.Cumulative.Accounts = epoch.Stats.Current.Accounts epoch.Stats.Cumulative.Rewards = prev.Stats.Cumulative.Rewards + epoch.Stats.Current.Rewards