From 8c65750d087058c97f9e0b63a7224bd9ee405e1e Mon Sep 17 00:00:00 2001 From: Kacper Sawicki Date: Tue, 9 Apr 2024 10:53:05 +0200 Subject: [PATCH] Rename atx received field to cReceived --- model/atx.go | 2 +- storage/atx.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/model/atx.go b/model/atx.go index 09b7aac..61d463f 100644 --- a/model/atx.go +++ b/model/atx.go @@ -19,7 +19,7 @@ type Activation struct { TickCount uint64 `json:"tickCount" bson:"tickCount"` Weight uint64 `json:"weight" bson:"weight"` EffectiveNumUnits uint32 `json:"effectiveNumUnits" bson:"effectiveNumUnits"` - Received map[string]int64 `json:"received" bson:"received"` + Received map[string]int64 `json:"received" bson:"cReceived"` } type ActivationService interface { diff --git a/storage/atx.go b/storage/atx.go index 6df4b63..2a1b7bd 100644 --- a/storage/atx.go +++ b/storage/atx.go @@ -41,7 +41,7 @@ func (s *Storage) GetActivation(parent context.Context, query *bson.D) (*model.A } doc := cursor.Current var received map[string]int64 - err = doc.Lookup("received").Unmarshal(&received) + err = doc.Lookup("cReceived").Unmarshal(&received) if err != nil { return nil, err } @@ -107,7 +107,7 @@ func (s *Storage) SaveActivation(parent context.Context, in *model.Activation) e {Key: "prevAtx", Value: in.PrevAtx}, {Key: "numunits", Value: in.NumUnits}, {Key: "commitmentSize", Value: int64(in.NumUnits) * int64(s.postUnitSize)}, - {Key: "received", Value: in.Received}, + {Key: "cReceived", Value: in.Received}, {Key: "publishEpoch", Value: in.PublishEpoch}, {Key: "targetEpoch", Value: in.TargetEpoch}, {Key: "tickCount", Value: in.TickCount}, @@ -131,7 +131,7 @@ func (s *Storage) SaveOrUpdateActivation(parent context.Context, atx *model.Acti {Key: "prevAtx", Value: atx.PrevAtx}, {Key: "numunits", Value: atx.NumUnits}, {Key: "commitmentSize", Value: int64(atx.NumUnits) * int64(s.postUnitSize)}, - {Key: "received." + s.collectorName, Value: atx.Received[s.collectorName]}, + {Key: "cReceived." + s.collectorName, Value: atx.Received[s.collectorName]}, {Key: "publishEpoch", Value: atx.PublishEpoch}, {Key: "targetEpoch", Value: atx.TargetEpoch}, {Key: "tickCount", Value: atx.TickCount}, @@ -151,8 +151,8 @@ func (s *Storage) SaveOrUpdateActivation(parent context.Context, atx *model.Acti func (s *Storage) GetLastActivationReceived() int64 { cursor, err := s.db.Collection("activations").Find(context.Background(), - bson.M{"received." + s.collectorName: bson.M{"$exists": true}}, - options.Find().SetSort(bson.D{{Key: "received." + s.collectorName, Value: -1}}).SetLimit(1)) + bson.M{"cReceived." + s.collectorName: bson.M{"$exists": true}}, + options.Find().SetSort(bson.D{{Key: "cReceived." + s.collectorName, Value: -1}}).SetLimit(1)) if err != nil { log.Info("GetLastActivationReceived: %v", err) return 0 @@ -164,7 +164,7 @@ func (s *Storage) GetLastActivationReceived() int64 { doc := cursor.Current var received map[string]int64 - err = doc.Lookup("received").Unmarshal(&received) + err = doc.Lookup("cReceived").Unmarshal(&received) if err != nil { log.Info("GetLastActivationReceived: %v", err) return 0