github.com/aeternity/aepp-sdk-go/v4@v4.0.1/swagguard/node/models/key_block.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  	"github.com/go-openapi/validate"
    14  )
    15  
    16  // KeyBlock key block
    17  // swagger:model KeyBlock
    18  type KeyBlock struct {
    19  
    20  	// beneficiary
    21  	// Required: true
    22  	Beneficiary *string `json:"beneficiary"`
    23  
    24  	// hash
    25  	// Required: true
    26  	Hash *string `json:"hash"`
    27  
    28  	// height
    29  	// Required: true
    30  	Height *uint64 `json:"height"`
    31  
    32  	// info
    33  	// Required: true
    34  	Info *string `json:"info"`
    35  
    36  	// miner
    37  	// Required: true
    38  	Miner *string `json:"miner"`
    39  
    40  	// nonce
    41  	Nonce uint64 `json:"nonce,omitempty"`
    42  
    43  	// pow
    44  	Pow Pow `json:"pow,omitempty"`
    45  
    46  	// prev hash
    47  	// Required: true
    48  	PrevHash *string `json:"prev_hash"`
    49  
    50  	// prev key hash
    51  	// Required: true
    52  	PrevKeyHash *string `json:"prev_key_hash"`
    53  
    54  	// state hash
    55  	// Required: true
    56  	StateHash *string `json:"state_hash"`
    57  
    58  	// target
    59  	// Required: true
    60  	Target *uint32 `json:"target"`
    61  
    62  	// time
    63  	// Required: true
    64  	Time *uint64 `json:"time"`
    65  
    66  	// version
    67  	// Required: true
    68  	Version *uint32 `json:"version"`
    69  }
    70  
    71  // Validate validates this key block
    72  func (m *KeyBlock) Validate(formats strfmt.Registry) error {
    73  	var res []error
    74  
    75  	if err := m.validateBeneficiary(formats); err != nil {
    76  		res = append(res, err)
    77  	}
    78  
    79  	if err := m.validateHash(formats); err != nil {
    80  		res = append(res, err)
    81  	}
    82  
    83  	if err := m.validateHeight(formats); err != nil {
    84  		res = append(res, err)
    85  	}
    86  
    87  	if err := m.validateInfo(formats); err != nil {
    88  		res = append(res, err)
    89  	}
    90  
    91  	if err := m.validateMiner(formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  
    95  	if err := m.validatePow(formats); err != nil {
    96  		res = append(res, err)
    97  	}
    98  
    99  	if err := m.validatePrevHash(formats); err != nil {
   100  		res = append(res, err)
   101  	}
   102  
   103  	if err := m.validatePrevKeyHash(formats); err != nil {
   104  		res = append(res, err)
   105  	}
   106  
   107  	if err := m.validateStateHash(formats); err != nil {
   108  		res = append(res, err)
   109  	}
   110  
   111  	if err := m.validateTarget(formats); err != nil {
   112  		res = append(res, err)
   113  	}
   114  
   115  	if err := m.validateTime(formats); err != nil {
   116  		res = append(res, err)
   117  	}
   118  
   119  	if err := m.validateVersion(formats); err != nil {
   120  		res = append(res, err)
   121  	}
   122  
   123  	if len(res) > 0 {
   124  		return errors.CompositeValidationError(res...)
   125  	}
   126  	return nil
   127  }
   128  
   129  func (m *KeyBlock) validateBeneficiary(formats strfmt.Registry) error {
   130  
   131  	if err := validate.Required("beneficiary", "body", m.Beneficiary); err != nil {
   132  		return err
   133  	}
   134  
   135  	return nil
   136  }
   137  
   138  func (m *KeyBlock) validateHash(formats strfmt.Registry) error {
   139  
   140  	if err := validate.Required("hash", "body", m.Hash); err != nil {
   141  		return err
   142  	}
   143  
   144  	return nil
   145  }
   146  
   147  func (m *KeyBlock) validateHeight(formats strfmt.Registry) error {
   148  
   149  	if err := validate.Required("height", "body", m.Height); err != nil {
   150  		return err
   151  	}
   152  
   153  	return nil
   154  }
   155  
   156  func (m *KeyBlock) validateInfo(formats strfmt.Registry) error {
   157  
   158  	if err := validate.Required("info", "body", m.Info); err != nil {
   159  		return err
   160  	}
   161  
   162  	return nil
   163  }
   164  
   165  func (m *KeyBlock) validateMiner(formats strfmt.Registry) error {
   166  
   167  	if err := validate.Required("miner", "body", m.Miner); err != nil {
   168  		return err
   169  	}
   170  
   171  	return nil
   172  }
   173  
   174  func (m *KeyBlock) validatePow(formats strfmt.Registry) error {
   175  
   176  	if swag.IsZero(m.Pow) { // not required
   177  		return nil
   178  	}
   179  
   180  	if err := m.Pow.Validate(formats); err != nil {
   181  		if ve, ok := err.(*errors.Validation); ok {
   182  			return ve.ValidateName("pow")
   183  		}
   184  		return err
   185  	}
   186  
   187  	return nil
   188  }
   189  
   190  func (m *KeyBlock) validatePrevHash(formats strfmt.Registry) error {
   191  
   192  	if err := validate.Required("prev_hash", "body", m.PrevHash); err != nil {
   193  		return err
   194  	}
   195  
   196  	return nil
   197  }
   198  
   199  func (m *KeyBlock) validatePrevKeyHash(formats strfmt.Registry) error {
   200  
   201  	if err := validate.Required("prev_key_hash", "body", m.PrevKeyHash); err != nil {
   202  		return err
   203  	}
   204  
   205  	return nil
   206  }
   207  
   208  func (m *KeyBlock) validateStateHash(formats strfmt.Registry) error {
   209  
   210  	if err := validate.Required("state_hash", "body", m.StateHash); err != nil {
   211  		return err
   212  	}
   213  
   214  	return nil
   215  }
   216  
   217  func (m *KeyBlock) validateTarget(formats strfmt.Registry) error {
   218  
   219  	if err := validate.Required("target", "body", m.Target); err != nil {
   220  		return err
   221  	}
   222  
   223  	return nil
   224  }
   225  
   226  func (m *KeyBlock) validateTime(formats strfmt.Registry) error {
   227  
   228  	if err := validate.Required("time", "body", m.Time); err != nil {
   229  		return err
   230  	}
   231  
   232  	return nil
   233  }
   234  
   235  func (m *KeyBlock) validateVersion(formats strfmt.Registry) error {
   236  
   237  	if err := validate.Required("version", "body", m.Version); err != nil {
   238  		return err
   239  	}
   240  
   241  	return nil
   242  }
   243  
   244  // MarshalBinary interface implementation
   245  func (m *KeyBlock) MarshalBinary() ([]byte, error) {
   246  	if m == nil {
   247  		return nil, nil
   248  	}
   249  	return swag.WriteJSON(m)
   250  }
   251  
   252  // UnmarshalBinary interface implementation
   253  func (m *KeyBlock) UnmarshalBinary(b []byte) error {
   254  	var res KeyBlock
   255  	if err := swag.ReadJSON(b, &res); err != nil {
   256  		return err
   257  	}
   258  	*m = res
   259  	return nil
   260  }