github.com/n1ghtfa1l/go-vnt@v0.6.4-alpha.6/tests/gen_difficultytest.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package tests
     4  
     5  import (
     6  	"encoding/json"
     7  	"math/big"
     8  
     9  	"github.com/vntchain/go-vnt/common/math"
    10  )
    11  
    12  var _ = (*difficultyTestMarshaling)(nil)
    13  
    14  func (d DifficultyTest) MarshalJSON() ([]byte, error) {
    15  	type DifficultyTest struct {
    16  		ParentTimestamp    *math.HexOrDecimal256 `json:"parentTimestamp"`
    17  		ParentDifficulty   *math.HexOrDecimal256 `json:"parentDifficulty"`
    18  		CurrentTimestamp   *math.HexOrDecimal256 `json:"currentTimestamp"`
    19  		CurrentBlockNumber math.HexOrDecimal64   `json:"currentBlockNumber"`
    20  		CurrentDifficulty  *math.HexOrDecimal256 `json:"currentDifficulty"`
    21  	}
    22  	var enc DifficultyTest
    23  	enc.ParentTimestamp = (*math.HexOrDecimal256)(d.ParentTimestamp)
    24  	enc.ParentDifficulty = (*math.HexOrDecimal256)(d.ParentDifficulty)
    25  	enc.CurrentTimestamp = (*math.HexOrDecimal256)(d.CurrentTimestamp)
    26  	enc.CurrentBlockNumber = math.HexOrDecimal64(d.CurrentBlockNumber)
    27  	enc.CurrentDifficulty = (*math.HexOrDecimal256)(d.CurrentDifficulty)
    28  	return json.Marshal(&enc)
    29  }
    30  
    31  func (d *DifficultyTest) UnmarshalJSON(input []byte) error {
    32  	type DifficultyTest struct {
    33  		ParentTimestamp    *math.HexOrDecimal256 `json:"parentTimestamp"`
    34  		ParentDifficulty   *math.HexOrDecimal256 `json:"parentDifficulty"`
    35  		CurrentTimestamp   *math.HexOrDecimal256 `json:"currentTimestamp"`
    36  		CurrentBlockNumber *math.HexOrDecimal64  `json:"currentBlockNumber"`
    37  		CurrentDifficulty  *math.HexOrDecimal256 `json:"currentDifficulty"`
    38  	}
    39  	var dec DifficultyTest
    40  	if err := json.Unmarshal(input, &dec); err != nil {
    41  		return err
    42  	}
    43  	if dec.ParentTimestamp != nil {
    44  		d.ParentTimestamp = (*big.Int)(dec.ParentTimestamp)
    45  	}
    46  	if dec.ParentDifficulty != nil {
    47  		d.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
    48  	}
    49  	if dec.CurrentTimestamp != nil {
    50  		d.CurrentTimestamp = (*big.Int)(dec.CurrentTimestamp)
    51  	}
    52  	if dec.CurrentBlockNumber != nil {
    53  		d.CurrentBlockNumber = uint64(*dec.CurrentBlockNumber)
    54  	}
    55  	if dec.CurrentDifficulty != nil {
    56  		d.CurrentDifficulty = (*big.Int)(dec.CurrentDifficulty)
    57  	}
    58  	return nil
    59  }