Skip to content

Commit

Permalink
Rename atx received field to cReceived
Browse files Browse the repository at this point in the history
  • Loading branch information
kacpersaw committed Apr 9, 2024
1 parent 3890086 commit 8c65750
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion model/atx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions storage/atx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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},
Expand All @@ -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},
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8c65750

Please sign in to comment.