github.com/intfoundation/intchain@v0.0.0-20220727031208-4316ad31ca73/consensus/ipbft/types/api_types.go (about)

     1  package types
     2  
     3  import (
     4  	. "github.com/intfoundation/go-common"
     5  	"github.com/intfoundation/go-crypto"
     6  	"github.com/intfoundation/intchain/common"
     7  	"github.com/intfoundation/intchain/common/hexutil"
     8  	"time"
     9  )
    10  
    11  type EpochApi struct {
    12  	Number         hexutil.Uint64    `json:"number"`
    13  	RewardPerBlock *hexutil.Big      `json:"rewardPerBlock"`
    14  	StartBlock     hexutil.Uint64    `json:"startBlock"`
    15  	EndBlock       hexutil.Uint64    `json:"endBlock"`
    16  	StartTime      time.Time         `json:"startTime"`
    17  	EndTime        time.Time         `json:"endTime"`
    18  	Validators     []*EpochValidator `json:"validators"`
    19  }
    20  
    21  type EpochVotesApi struct {
    22  	EpochNumber hexutil.Uint64           `json:"voteForEpoch"`
    23  	StartBlock  hexutil.Uint64           `json:"startBlock"`
    24  	EndBlock    hexutil.Uint64           `json:"endBlock"`
    25  	Votes       []*EpochValidatorVoteApi `json:"votes"`
    26  }
    27  
    28  type EpochValidatorVoteApi struct {
    29  	EpochValidator
    30  	Salt     string      `json:"salt"`
    31  	VoteHash common.Hash `json:"voteHash"` // VoteHash = Keccak256(Epoch Number + PubKey + Amount + Salt)
    32  	TxHash   common.Hash `json:"txHash"`
    33  }
    34  
    35  type EpochValidator struct {
    36  	Address        common.Address `json:"address"`
    37  	PubKey         string         `json:"publicKey"`
    38  	Amount         *hexutil.Big   `json:"votingPower"`
    39  	RemainingEpoch hexutil.Uint64 `json:"remainEpoch"`
    40  }
    41  
    42  type EpochCandidate struct {
    43  	Address common.Address `json:"address"`
    44  }
    45  
    46  type TendermintExtraApi struct {
    47  	ChainID         string         `json:"chainId"`
    48  	Height          hexutil.Uint64 `json:"height"`
    49  	Time            time.Time      `json:"time"`
    50  	NeedToSave      bool           `json:"needToSave"`
    51  	NeedToBroadcast bool           `json:"needToBroadcast"`
    52  	EpochNumber     hexutil.Uint64 `json:"epochNumber"`
    53  	SeenCommitHash  string         `json:"lastCommitHash"` // commit from validators from the last block
    54  	ValidatorsHash  string         `json:"validatorsHash"` // validators for the current block
    55  	SeenCommit      *CommitApi     `json:"seenCommit"`
    56  	EpochBytes      []byte         `json:"epochBytes"`
    57  }
    58  
    59  type CommitApi struct {
    60  	BlockID BlockIDApi     `json:"blockID"`
    61  	Height  hexutil.Uint64 `json:"height"`
    62  	Round   int            `json:"round"`
    63  
    64  	// BLS signature aggregation to be added here
    65  	SignAggr crypto.BLSSignature `json:"signAggr"`
    66  	BitArray *BitArray           `json:"bitArray"`
    67  
    68  	//// Volatile
    69  	//hash []byte
    70  }
    71  
    72  type BlockIDApi struct {
    73  	Hash        string           `json:"hash"`
    74  	PartsHeader PartSetHeaderApi `json:"parts"`
    75  }
    76  
    77  type PartSetHeaderApi struct {
    78  	Total hexutil.Uint64 `json:"total"`
    79  	Hash  string         `json:"hash"`
    80  }
    81  
    82  type ConsensusAggr struct {
    83  	PublicKeys []string         `json:"publicKey"`
    84  	Addresses  []common.Address `json:"address"`
    85  }
    86  
    87  //type ValidatorStatus struct {
    88  //	IsForbidden bool `json:"isForbidden"`
    89  //}
    90  
    91  //type CandidateApi struct {
    92  //	CandidateList []string `json:"candidateList"`
    93  //}
    94  
    95  //type ForbiddenApi struct {
    96  //	ForbiddenList []string `json:"forbiddenList"`
    97  //}