code.vegaprotocol.io/vega@v0.79.0/protos/vega/data/v1/spec.go (about) 1 package v1 2 3 import ( 4 "encoding/hex" 5 6 "code.vegaprotocol.io/vega/libs/crypto" 7 ) 8 9 func NewID(signers []*Signer, filters []*Filter) string { 10 buf := []byte{} 11 for _, filter := range filters { 12 s := filter.Key.Name + filter.Key.Type.String() 13 for _, c := range filter.Conditions { 14 s += c.Operator.String() + c.Value 15 } 16 17 buf = append(buf, []byte(s)...) 18 } 19 20 return hex.EncodeToString(crypto.Hash(buf)) 21 } 22 23 func (p PropertyKey) DeepClone() *PropertyKey { 24 return &PropertyKey{ 25 Name: p.Name, 26 Type: p.Type, 27 } 28 } 29 30 func (p Property) DeepClone() *Property { 31 return &p 32 } 33 34 func (c Condition) DeepClone() *Condition { 35 return &Condition{ 36 Value: c.Value, 37 Operator: c.Operator, 38 } 39 } 40 41 func (s Signer) DeepClone() *Signer { 42 return &Signer{ 43 Signer: s.Signer, 44 } 45 } 46 47 func (f Filter) DeepClone() *Filter { 48 if f.Key != nil { 49 f.Key = f.Key.DeepClone() 50 } 51 52 if len(f.Conditions) > 0 { 53 conditions := f.Conditions 54 f.Conditions = make([]*Condition, len(conditions)) 55 for i, c := range conditions { 56 f.Conditions[i] = c.DeepClone() 57 } 58 } 59 return &f 60 }