blockv0

package
v1.3.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version01a = "0.1a"
	Version03  = "0.3"
	Version04  = "0.4"
	Version05  = "0.5"
)

Variables

This section is empty.

Functions

func CalcMerkleRootOfReceiptList

func CalcMerkleRootOfReceiptList(
	receipts module.ReceiptList,
	txs module.TransactionList,
	height int64,
) []byte

func CalcMerkleRootOfReceiptSlice

func CalcMerkleRootOfReceiptSlice(
	receipts []txresult.Receipt,
	txs []module.Transaction,
	height int64,
) []byte

func CalcOriginalReceiptHash

func CalcOriginalReceiptHash(
	r module.Receipt,
	txHash []byte,
	height int64,
	txIndex int,
) []byte

func TransactionRootForBlockV03 added in v0.9.10

func TransactionRootForBlockV03(txs []Transaction) []byte

Types

type Block

type Block interface {
	Version() string
	ID() []byte
	Height() int64
	Timestamp() int64
	PrevID() []byte
	Votes() *BlockVoteList
	Proposer() module.Address
	Validators() *RepsList
	NextValidators() *RepsList
	NormalTransactions() []module.Transaction
	LogsBloom() module.LogsBloom
	Verify(prev Block) error
	ToJSON(version module.JSONVersion) (interface{}, error)
	TransactionRoot() []byte
}

func NewBlockV01a added in v0.9.10

func NewBlockV01a(jsn *BlockV01aJSON) Block

func NewBlockV03 added in v0.9.10

func NewBlockV03(jso *BlockV03JSON, lc Store) (Block, error)

func ParseBlock

func ParseBlock(b []byte, lc Store) (Block, error)

func ParseBlockV01a

func ParseBlockV01a(b []byte) (Block, error)

func ParseBlockV03

func ParseBlockV03(b []byte, lc Store) (Block, error)

type BlockV01a

type BlockV01a struct {
	*BlockV01aJSON
	// contains filtered or unexported fields
}

func (*BlockV01a) Height

func (b *BlockV01a) Height() int64

func (*BlockV01a) ID

func (b *BlockV01a) ID() []byte

func (*BlockV01a) LogsBloom

func (b *BlockV01a) LogsBloom() module.LogsBloom

func (*BlockV01a) NextValidators

func (b *BlockV01a) NextValidators() *RepsList

func (*BlockV01a) NormalTransactions

func (b *BlockV01a) NormalTransactions() []module.Transaction

func (*BlockV01a) PrevID

func (b *BlockV01a) PrevID() []byte

func (*BlockV01a) Proposer

func (b *BlockV01a) Proposer() module.Address

func (*BlockV01a) String

func (b *BlockV01a) String() string

func (*BlockV01a) Timestamp

func (b *BlockV01a) Timestamp() int64

func (*BlockV01a) ToJSON

func (b *BlockV01a) ToJSON(version module.JSONVersion) (interface{}, error)

func (*BlockV01a) TransactionRoot added in v0.9.10

func (b *BlockV01a) TransactionRoot() []byte

func (*BlockV01a) Validators

func (b *BlockV01a) Validators() *RepsList

func (*BlockV01a) Verify

func (b *BlockV01a) Verify(prev Block) error

func (*BlockV01a) Version

func (b *BlockV01a) Version() string

func (*BlockV01a) Votes

func (b *BlockV01a) Votes() *BlockVoteList

type BlockV01aJSON added in v0.9.10

type BlockV01aJSON struct {
	Version            string             `json:"version"`
	PrevBlockHash      common.RawHexBytes `json:"prev_block_hash,omitempty"`
	MerkleTreeRootHash common.RawHexBytes `json:"merkle_tree_root_hash"`
	Transactions       []Transaction      `json:"confirmed_transaction_list,omitempty"`
	BlockHash          common.RawHexBytes `json:"block_hash"`
	Height             int64              `json:"height"`
	PeerID             *common.Address    `json:"peer_id"`
	TimeStamp          uint64             `json:"time_stamp"`
	Signature          common.Signature   `json:"signature,omitempty"`
}

func (*BlockV01aJSON) CalcHash added in v0.9.10

func (b *BlockV01aJSON) CalcHash() []byte

type BlockV03

type BlockV03 struct {
	// contains filtered or unexported fields
}

func (*BlockV03) GetNextLeader added in v0.9.7

func (b *BlockV03) GetNextLeader() module.Address

func (*BlockV03) Height

func (b *BlockV03) Height() int64

func (*BlockV03) ID

func (b *BlockV03) ID() []byte

func (*BlockV03) IsVotedLeaderByComplain added in v0.9.8

func (b *BlockV03) IsVotedLeaderByComplain(leader module.Address) bool

func (*BlockV03) LeaderVotes added in v0.9.7

func (b *BlockV03) LeaderVotes() *LeaderVoteList

func (*BlockV03) LogsBloom

func (b *BlockV03) LogsBloom() module.LogsBloom

func (*BlockV03) NextLeader added in v0.9.7

func (b *BlockV03) NextLeader() common.Address

func (*BlockV03) NextRepsHash added in v0.9.8

func (b *BlockV03) NextRepsHash() []byte

func (*BlockV03) NextValidators

func (b *BlockV03) NextValidators() *RepsList

func (*BlockV03) NormalTransactions

func (b *BlockV03) NormalTransactions() []module.Transaction

func (*BlockV03) PrevID

func (b *BlockV03) PrevID() []byte

func (*BlockV03) PrevVotes added in v0.9.7

func (b *BlockV03) PrevVotes() *BlockVoteList

func (*BlockV03) Proposer

func (b *BlockV03) Proposer() module.Address

func (*BlockV03) ReceiptsHash

func (b *BlockV03) ReceiptsHash() []byte

func (*BlockV03) RepsChanged added in v0.9.10

func (b *BlockV03) RepsChanged() bool

func (*BlockV03) RepsHash added in v0.9.7

func (b *BlockV03) RepsHash() []byte

func (*BlockV03) Signature added in v0.9.7

func (b *BlockV03) Signature() common.Signature

func (*BlockV03) StateHash added in v0.9.7

func (b *BlockV03) StateHash() []byte

func (*BlockV03) Timestamp

func (b *BlockV03) Timestamp() int64

func (*BlockV03) ToJSON

func (b *BlockV03) ToJSON(rcpVersion module.JSONVersion) (interface{}, error)

func (*BlockV03) TransactionRoot added in v0.9.10

func (b *BlockV03) TransactionRoot() []byte

func (*BlockV03) Validators

func (b *BlockV03) Validators() *RepsList

func (*BlockV03) Verify

func (b *BlockV03) Verify(prev Block) error

func (*BlockV03) Version

func (b *BlockV03) Version() string

func (*BlockV03) Votes

func (b *BlockV03) Votes() *BlockVoteList

type BlockV03JSON

type BlockV03JSON struct {
	Hash             common.HexBytes    `json:"hash"`
	Version          string             `json:"version"`
	PrevHash         common.HexHash     `json:"prevHash"`
	TransactionsHash common.HexHash     `json:"transactionsHash"`
	StateHash        common.HexHash     `json:"stateHash"`
	ReceiptsHash     common.HexHash     `json:"receiptsHash"`
	RepsHash         common.HexHash     `json:"repsHash"`
	NextRepsHash     common.HexHash     `json:"nextRepsHash"`
	LeaderVotesHash  common.HexHash     `json:"leaderVotesHash"`
	PrevVotesHash    common.HexHash     `json:"prevVotesHash"`
	LogsBloom        txresult.LogsBloom `json:"logsBloom"`
	Timestamp        common.HexInt64    `json:"timestamp"`
	Transactions     []Transaction      `json:"transactions"`
	LeaderVotes      *LeaderVoteList    `json:"leaderVotes"`
	PrevVotes        *BlockVoteList     `json:"prevVotes"`
	Height           common.HexInt64    `json:"height"`
	Leader           common.Address     `json:"leader"`
	NextLeader       common.Address     `json:"nextLeader"`
	Signature        common.Signature   `json:"signature"`
}

func (*BlockV03JSON) CalcHash added in v0.9.10

func (jsn *BlockV03JSON) CalcHash() []byte

type BlockVote

type BlockVote struct {
	// contains filtered or unexported fields
}

func NewBlockVote added in v0.9.10

func NewBlockVote(
	w module.Wallet,
	height int64, round int64, blockHash []byte, ts int64,
) *BlockVote

func (*BlockVote) Hash

func (v *BlockVote) Hash() []byte

func (*BlockVote) MarshalJSON added in v0.9.7

func (v *BlockVote) MarshalJSON() ([]byte, error)

func (*BlockVote) Round

func (v *BlockVote) Round() int

func (*BlockVote) Sign added in v0.9.10

func (v *BlockVote) Sign(w module.Wallet) error

Sign updates Signature field

func (*BlockVote) UnmarshalJSON

func (v *BlockVote) UnmarshalJSON(b []byte) error

func (*BlockVote) Verify

func (v *BlockVote) Verify() error

type BlockVoteJSON

type BlockVoteJSON struct {
	BlockVoteJSONSharable
	BlockVoteJSONIndividual
}

type BlockVoteJSONIndividual added in v0.9.7

type BlockVoteJSONIndividual struct {
	Rep       common.Address   `json:"rep"`
	Timestamp common.HexInt64  `json:"timestamp"`
	Signature common.Signature `json:"signature"`
}

type BlockVoteJSONSharable added in v0.9.7

type BlockVoteJSONSharable struct {
	BlockHeight common.HexInt64  `json:"blockHeight"`
	Round_      *int             `json:"round_,omitempty"`
	Round       *common.HexInt64 `json:"round,omitempty"`
	BlockHash   common.HexHash   `json:"blockHash"`
}

func (*BlockVoteJSONSharable) Equal added in v0.9.7

type BlockVoteList

type BlockVoteList struct {
	// contains filtered or unexported fields
}

func NewBlockVoteList added in v0.9.10

func NewBlockVoteList(votes ...*BlockVote) *BlockVoteList

func NewBlockVotesFromBytes added in v0.9.10

func NewBlockVotesFromBytes(bs []byte) (*BlockVoteList, error)

func (*BlockVoteList) Add added in v0.9.10

func (s *BlockVoteList) Add(idx int, vote interface{}) bool

func (*BlockVoteList) BlockVoteSetBytes added in v1.3.0

func (s *BlockVoteList) BlockVoteSetBytes() []byte

func (*BlockVoteList) Bytes added in v0.9.8

func (s *BlockVoteList) Bytes() []byte

func (*BlockVoteList) CheckVoters

func (s *BlockVoteList) CheckVoters(reps *RepsList, voted []bool) error

func (*BlockVoteList) CommitVoteSet added in v0.9.10

func (*BlockVoteList) Copy added in v1.2.14

func (s *BlockVoteList) Copy() *BlockVoteList

func (*BlockVoteList) Hash

func (s *BlockVoteList) Hash() []byte

func (*BlockVoteList) MarshalJSON

func (s *BlockVoteList) MarshalJSON() ([]byte, error)

func (*BlockVoteList) NTSDProofAt added in v1.3.0

func (s *BlockVoteList) NTSDProofAt(i int) []byte

func (*BlockVoteList) NTSDProofCount added in v1.3.0

func (s *BlockVoteList) NTSDProofCount() int

func (*BlockVoteList) NTSDProves added in v1.3.0

func (s *BlockVoteList) NTSDProves() [][]byte

func (*BlockVoteList) Quorum

func (s *BlockVoteList) Quorum() []byte

func (*BlockVoteList) RLPDecodeSelf added in v0.9.7

func (s *BlockVoteList) RLPDecodeSelf(d codec.Decoder) error

func (*BlockVoteList) RLPEncodeSelf added in v0.9.7

func (s *BlockVoteList) RLPEncodeSelf(e codec.Encoder) error

func (*BlockVoteList) Root added in v0.9.7

func (s *BlockVoteList) Root() []byte

func (BlockVoteList) String added in v0.9.10

func (s BlockVoteList) String() string

func (*BlockVoteList) Timestamp added in v0.9.10

func (s *BlockVoteList) Timestamp() int64

func (*BlockVoteList) UnmarshalJSON

func (s *BlockVoteList) UnmarshalJSON(b []byte) error

func (*BlockVoteList) Verify

func (s *BlockVoteList) Verify(reps *RepsList) error

func (*BlockVoteList) VerifyBlock added in v0.9.8

func (s *BlockVoteList) VerifyBlock(block module.BlockData, validators module.ValidatorList) ([]bool, error)

func (*BlockVoteList) VoteRound added in v1.3.0

func (s *BlockVoteList) VoteRound() int32

type LeaderVote

type LeaderVote struct {
	LeaderVoteSharable
	LeaderVoteIndividual
	// contains filtered or unexported fields
}

func (*LeaderVote) GetRound added in v0.9.8

func (v *LeaderVote) GetRound() int

func (*LeaderVote) Hash

func (v *LeaderVote) Hash() []byte

func (*LeaderVote) Verify

func (v *LeaderVote) Verify() error

type LeaderVoteIndividual added in v0.9.7

type LeaderVoteIndividual struct {
	Rep       common.Address  `json:"rep"`
	Timestamp common.HexInt64 `json:"timestamp"`
	Signature []byte          `json:"signature"`
}

type LeaderVoteList

type LeaderVoteList struct {
	// contains filtered or unexported fields
}

func (*LeaderVoteList) Bytes added in v0.9.8

func (s *LeaderVoteList) Bytes() []byte

func (*LeaderVoteList) Copy added in v1.2.14

func (s *LeaderVoteList) Copy() *LeaderVoteList

func (*LeaderVoteList) Hash

func (s *LeaderVoteList) Hash() []byte

func (*LeaderVoteList) MarshalJSON

func (s *LeaderVoteList) MarshalJSON() ([]byte, error)

func (*LeaderVoteList) RLPDecodeSelf added in v0.9.7

func (s *LeaderVoteList) RLPDecodeSelf(d codec.Decoder) error

func (*LeaderVoteList) RLPEncodeSelf added in v0.9.7

func (s *LeaderVoteList) RLPEncodeSelf(e codec.Encoder) error

func (*LeaderVoteList) Root added in v0.9.7

func (s *LeaderVoteList) Root() []byte

func (*LeaderVoteList) UnmarshalJSON

func (s *LeaderVoteList) UnmarshalJSON(b []byte) error

func (*LeaderVoteList) Verify

func (s *LeaderVoteList) Verify(reps *RepsList) error

type LeaderVoteSharable added in v0.9.7

type LeaderVoteSharable struct {
	BlockHeight common.HexInt64  `json:"blockHeight"`
	OldLeader   common.Address   `json:"oldLeader"`
	NewLeader   common.Address   `json:"newLeader"`
	Round_      *int             `json:"round_,omitempty"`
	Round       *common.HexInt64 `json:"round,omitempty"`
}

func (*LeaderVoteSharable) Equal added in v0.9.7

type RepJSON

type RepJSON struct {
	Address *common.Address `json:"address,omitempty"`
	ID      *common.Address `json:"id,omitempty"`
	P2P     string          `json:"p2pEndPoint,omitempty"`
}

func (*RepJSON) Normalize added in v0.9.7

func (r *RepJSON) Normalize()

type RepsList

type RepsList struct {
	// contains filtered or unexported fields
}

func NewRepsList added in v0.9.10

func NewRepsList(addresses ...*common.Address) *RepsList

func (*RepsList) Get

func (l *RepsList) Get(i int) module.Address

func (*RepsList) GetNextOf added in v0.9.8

func (l *RepsList) GetNextOf(addr module.Address) module.Address

func (*RepsList) GetValidatorList added in v0.9.7

func (l *RepsList) GetValidatorList(dbase db.Database) (module.ValidatorList, error)

func (*RepsList) Hash

func (l *RepsList) Hash() []byte

func (*RepsList) Size

func (l *RepsList) Size() int

func (*RepsList) ToJSON

func (l *RepsList) ToJSON(version module.JSONVersion) (interface{}, error)

func (*RepsList) UnmarshalJSON

func (l *RepsList) UnmarshalJSON(bs []byte) error

type Store

type Store interface {
	GetRepsByHash(hash []byte) (*RepsList, error)
}

type Transaction

type Transaction struct {
	module.Transaction
}

func (*Transaction) MarshalJSON

func (t *Transaction) MarshalJSON() ([]byte, error)

func (Transaction) String

func (t Transaction) String() string

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL