code.vegaprotocol.io/vega@v0.79.0/datanode/entities/reward_summary_filter.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package entities 17 18 import v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" 19 20 // RewardSummaryFilter is the filter for the reward summary. 21 type RewardSummaryFilter struct { 22 AssetIDs []AssetID 23 MarketIDs []MarketID 24 FromEpoch *uint64 25 ToEpoch *uint64 26 } 27 28 // RewardSummaryFilterFromProto converts a protobuf v2.RewardSummaryFilter to an entities.RewardSummaryFilter. 29 func RewardSummaryFilterFromProto(pb *v2.RewardSummaryFilter) (filter RewardSummaryFilter) { 30 if pb != nil { 31 filter.AssetIDs = fromStringIDs[AssetID](pb.AssetIds) 32 filter.MarketIDs = fromStringIDs[MarketID](pb.MarketIds) 33 filter.FromEpoch = pb.FromEpoch 34 filter.ToEpoch = pb.ToEpoch 35 } 36 return 37 } 38 39 func fromStringIDs[id ID[typ], typ any](in []string) (ids []id) { 40 if len(in) == 0 { 41 return 42 } 43 ids = make([]id, len(in)) 44 for i, idStr := range in { 45 ids[i] = id(idStr) 46 } 47 return 48 }