github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/micro_block_header.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 strfmt "github.com/go-openapi/strfmt" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/swag" 13 ) 14 15 // MicroBlockHeader micro block header 16 // swagger:model MicroBlockHeader 17 type MicroBlockHeader struct { 18 19 // hash 20 // Required: true 21 Hash EncodedHash `json:"hash"` 22 23 // height 24 // Required: true 25 Height Uint64 `json:"height"` 26 27 // "no_fraud" | api encoded Proof of Fraud hash 28 // Required: true 29 PofHash EncodedHash `json:"pof_hash"` 30 31 // prev hash 32 // Required: true 33 PrevHash EncodedHash `json:"prev_hash"` 34 35 // prev key hash 36 // Required: true 37 PrevKeyHash EncodedHash `json:"prev_key_hash"` 38 39 // signature 40 // Required: true 41 Signature EncodedValue `json:"signature"` 42 43 // state hash 44 // Required: true 45 StateHash EncodedHash `json:"state_hash"` 46 47 // time 48 // Required: true 49 Time Uint64 `json:"time"` 50 51 // txs hash 52 // Required: true 53 TxsHash EncodedHash `json:"txs_hash"` 54 55 // version 56 // Required: true 57 Version Uint32 `json:"version"` 58 } 59 60 // Validate validates this micro block header 61 func (m *MicroBlockHeader) Validate(formats strfmt.Registry) error { 62 var res []error 63 64 if err := m.validateHash(formats); err != nil { 65 res = append(res, err) 66 } 67 68 if err := m.validateHeight(formats); err != nil { 69 res = append(res, err) 70 } 71 72 if err := m.validatePofHash(formats); err != nil { 73 res = append(res, err) 74 } 75 76 if err := m.validatePrevHash(formats); err != nil { 77 res = append(res, err) 78 } 79 80 if err := m.validatePrevKeyHash(formats); err != nil { 81 res = append(res, err) 82 } 83 84 if err := m.validateSignature(formats); err != nil { 85 res = append(res, err) 86 } 87 88 if err := m.validateStateHash(formats); err != nil { 89 res = append(res, err) 90 } 91 92 if err := m.validateTime(formats); err != nil { 93 res = append(res, err) 94 } 95 96 if err := m.validateTxsHash(formats); err != nil { 97 res = append(res, err) 98 } 99 100 if err := m.validateVersion(formats); err != nil { 101 res = append(res, err) 102 } 103 104 if len(res) > 0 { 105 return errors.CompositeValidationError(res...) 106 } 107 return nil 108 } 109 110 func (m *MicroBlockHeader) validateHash(formats strfmt.Registry) error { 111 112 if err := m.Hash.Validate(formats); err != nil { 113 if ve, ok := err.(*errors.Validation); ok { 114 return ve.ValidateName("hash") 115 } 116 return err 117 } 118 119 return nil 120 } 121 122 func (m *MicroBlockHeader) validateHeight(formats strfmt.Registry) error { 123 124 if err := m.Height.Validate(formats); err != nil { 125 if ve, ok := err.(*errors.Validation); ok { 126 return ve.ValidateName("height") 127 } 128 return err 129 } 130 131 return nil 132 } 133 134 func (m *MicroBlockHeader) validatePofHash(formats strfmt.Registry) error { 135 136 if err := m.PofHash.Validate(formats); err != nil { 137 if ve, ok := err.(*errors.Validation); ok { 138 return ve.ValidateName("pof_hash") 139 } 140 return err 141 } 142 143 return nil 144 } 145 146 func (m *MicroBlockHeader) validatePrevHash(formats strfmt.Registry) error { 147 148 if err := m.PrevHash.Validate(formats); err != nil { 149 if ve, ok := err.(*errors.Validation); ok { 150 return ve.ValidateName("prev_hash") 151 } 152 return err 153 } 154 155 return nil 156 } 157 158 func (m *MicroBlockHeader) validatePrevKeyHash(formats strfmt.Registry) error { 159 160 if err := m.PrevKeyHash.Validate(formats); err != nil { 161 if ve, ok := err.(*errors.Validation); ok { 162 return ve.ValidateName("prev_key_hash") 163 } 164 return err 165 } 166 167 return nil 168 } 169 170 func (m *MicroBlockHeader) validateSignature(formats strfmt.Registry) error { 171 172 if err := m.Signature.Validate(formats); err != nil { 173 if ve, ok := err.(*errors.Validation); ok { 174 return ve.ValidateName("signature") 175 } 176 return err 177 } 178 179 return nil 180 } 181 182 func (m *MicroBlockHeader) validateStateHash(formats strfmt.Registry) error { 183 184 if err := m.StateHash.Validate(formats); err != nil { 185 if ve, ok := err.(*errors.Validation); ok { 186 return ve.ValidateName("state_hash") 187 } 188 return err 189 } 190 191 return nil 192 } 193 194 func (m *MicroBlockHeader) validateTime(formats strfmt.Registry) error { 195 196 if err := m.Time.Validate(formats); err != nil { 197 if ve, ok := err.(*errors.Validation); ok { 198 return ve.ValidateName("time") 199 } 200 return err 201 } 202 203 return nil 204 } 205 206 func (m *MicroBlockHeader) validateTxsHash(formats strfmt.Registry) error { 207 208 if err := m.TxsHash.Validate(formats); err != nil { 209 if ve, ok := err.(*errors.Validation); ok { 210 return ve.ValidateName("txs_hash") 211 } 212 return err 213 } 214 215 return nil 216 } 217 218 func (m *MicroBlockHeader) validateVersion(formats strfmt.Registry) error { 219 220 if err := m.Version.Validate(formats); err != nil { 221 if ve, ok := err.(*errors.Validation); ok { 222 return ve.ValidateName("version") 223 } 224 return err 225 } 226 227 return nil 228 } 229 230 // MarshalBinary interface implementation 231 func (m *MicroBlockHeader) MarshalBinary() ([]byte, error) { 232 if m == nil { 233 return nil, nil 234 } 235 return swag.WriteJSON(m) 236 } 237 238 // UnmarshalBinary interface implementation 239 func (m *MicroBlockHeader) UnmarshalBinary(b []byte) error { 240 var res MicroBlockHeader 241 if err := swag.ReadJSON(b, &res); err != nil { 242 return err 243 } 244 *m = res 245 return nil 246 }