github.com/vantum/vantum@v0.0.0-20180815184342-fe37d5f7a990/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/vantum/vantum/common"
    10  	"github.com/vantum/vantum/common/math"
    11  )
    12  
    13  var _ = (*difficultyTestMarshaling)(nil)
    14  
    15  func (d DifficultyTest) MarshalJSON() ([]byte, error) {
    16  	type DifficultyTest struct {
    17  		ParentTimestamp    *math.HexOrDecimal256 `json:"parentTimestamp"`
    18  		ParentDifficulty   *math.HexOrDecimal256 `json:"parentDifficulty"`
    19  		UncleHash          common.Hash           `json:"parentUncles"`
    20  		CurrentTimestamp   *math.HexOrDecimal256 `json:"currentTimestamp"`
    21  		CurrentBlockNumber math.HexOrDecimal64   `json:"currentBlockNumber"`
    22  		CurrentDifficulty  *math.HexOrDecimal256 `json:"currentDifficulty"`
    23  	}
    24  	var enc DifficultyTest
    25  	enc.ParentTimestamp = (*math.HexOrDecimal256)(d.ParentTimestamp)
    26  	enc.ParentDifficulty = (*math.HexOrDecimal256)(d.ParentDifficulty)
    27  	enc.UncleHash = d.UncleHash
    28  	enc.CurrentTimestamp = (*math.HexOrDecimal256)(d.CurrentTimestamp)
    29  	enc.CurrentBlockNumber = math.HexOrDecimal64(d.CurrentBlockNumber)
    30  	enc.CurrentDifficulty = (*math.HexOrDecimal256)(d.CurrentDifficulty)
    31  	return json.Marshal(&enc)
    32  }
    33  
    34  func (d *DifficultyTest) UnmarshalJSON(input []byte) error {
    35  	type DifficultyTest struct {
    36  		ParentTimestamp    *math.HexOrDecimal256 `json:"parentTimestamp"`
    37  		ParentDifficulty   *math.HexOrDecimal256 `json:"parentDifficulty"`
    38  		UncleHash          *common.Hash          `json:"parentUncles"`
    39  		CurrentTimestamp   *math.HexOrDecimal256 `json:"currentTimestamp"`
    40  		CurrentBlockNumber *math.HexOrDecimal64  `json:"currentBlockNumber"`
    41  		CurrentDifficulty  *math.HexOrDecimal256 `json:"currentDifficulty"`
    42  	}
    43  	var dec DifficultyTest
    44  	if err := json.Unmarshal(input, &dec); err != nil {
    45  		return err
    46  	}
    47  	if dec.ParentTimestamp != nil {
    48  		d.ParentTimestamp = (*big.Int)(dec.ParentTimestamp)
    49  	}
    50  	if dec.ParentDifficulty != nil {
    51  		d.ParentDifficulty = (*big.Int)(dec.ParentDifficulty)
    52  	}
    53  	if dec.UncleHash != nil {
    54  		d.UncleHash = *dec.UncleHash
    55  	}
    56  	if dec.CurrentTimestamp != nil {
    57  		d.CurrentTimestamp = (*big.Int)(dec.CurrentTimestamp)
    58  	}
    59  	if dec.CurrentBlockNumber != nil {
    60  		d.CurrentBlockNumber = uint64(*dec.CurrentBlockNumber)
    61  	}
    62  	if dec.CurrentDifficulty != nil {
    63  		d.CurrentDifficulty = (*big.Int)(dec.CurrentDifficulty)
    64  	}
    65  	return nil
    66  }