code.vegaprotocol.io/vega@v0.79.0/core/monitor/snapshot.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 monitor 17 18 import ( 19 "code.vegaprotocol.io/vega/core/types" 20 ) 21 22 func NewAuctionStateFromSnapshot(mkt *types.Market, as *types.AuctionState) *AuctionState { 23 s := AuctionState{ 24 mode: as.Mode, 25 defMode: as.DefaultMode, 26 trigger: as.Trigger, 27 end: as.End, 28 start: as.Start, 29 stop: as.Stop, 30 m: mkt, 31 extensionEventSent: as.ExtensionEventSent, 32 } 33 34 if as.Begin.IsZero() { 35 s.begin = nil 36 } else { 37 s.begin = &as.Begin 38 } 39 40 if as.Extension == types.AuctionTriggerUnspecified { 41 s.extension = nil 42 } else { 43 s.extension = &as.Extension 44 } 45 return &s 46 } 47 48 func (a AuctionState) Changed() bool { 49 return true 50 } 51 52 func (a *AuctionState) GetState() *types.AuctionState { 53 as := &types.AuctionState{ 54 Mode: a.mode, 55 DefaultMode: a.defMode, 56 End: a.end, 57 Start: a.start, 58 Stop: a.stop, 59 Trigger: a.trigger, 60 ExtensionEventSent: a.extensionEventSent, 61 } 62 if a.extension != nil { 63 as.Extension = *a.extension 64 } 65 66 if a.begin != nil { 67 as.Begin = *a.begin 68 } 69 70 return as 71 }