code.vegaprotocol.io/vega@v0.79.0/datanode/entities/network_parameter.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 ( 19 "time" 20 21 v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2" 22 "code.vegaprotocol.io/vega/protos/vega" 23 ) 24 25 type NetworkParameter struct { 26 Key string 27 Value string 28 TxHash TxHash 29 VegaTime time.Time 30 } 31 32 func (np NetworkParameter) ToProto() *vega.NetworkParameter { 33 pnp := vega.NetworkParameter{ 34 Key: np.Key, 35 Value: np.Value, 36 } 37 return &pnp 38 } 39 40 func (np NetworkParameter) Cursor() *Cursor { 41 return NewCursor(np.Key) 42 } 43 44 func (np NetworkParameter) ToProtoEdge(_ ...any) (*v2.NetworkParameterEdge, error) { 45 return &v2.NetworkParameterEdge{ 46 Node: np.ToProto(), 47 Cursor: np.Cursor().Encode(), 48 }, nil 49 } 50 51 func NetworkParameterFromProto(pnp *vega.NetworkParameter, txHash TxHash) (NetworkParameter, error) { 52 np := NetworkParameter{ 53 Key: pnp.Key, 54 Value: pnp.Value, 55 TxHash: txHash, 56 } 57 return np, nil 58 } 59 60 type NetworkParameterCursor struct { 61 Key string 62 } 63 64 func (c *NetworkParameterCursor) Parse(cursorString string) error { 65 c.Key = cursorString 66 return nil 67 }