Documentation ¶
Index ¶
- Variables
- func GetReward(blockNumber uint64) (*big.Int, error)
- func IsValidVerifier(address string) bool
- func MarshalProtoBlock(b *ProtoBlock) ([]byte, error)
- func SetBlockVerifiers(v Verifier)
- type Block
- func (b Block) GetAndValidateCoinbaseTransaction() (transaction.Transaction, error)
- func (b Block) GetBlockHash() ([]byte, error)
- func (b Block) GetMerkleHash() ([]byte, error)
- func (b *Block) Sign(key crypto.PrivKey) error
- func (b Block) Validate() (bool, error)
- func (b Block) VerifyWithPublicKey(key crypto.PubKey) error
- type ProtoBlock
- func (*ProtoBlock) Descriptor() ([]byte, []int)deprecated
- func (x *ProtoBlock) GetData() []byte
- func (x *ProtoBlock) GetHash() []byte
- func (x *ProtoBlock) GetMerkleHash() []byte
- func (x *ProtoBlock) GetNumber() uint64
- func (x *ProtoBlock) GetPreviousBlockHash() []byte
- func (x *ProtoBlock) GetSignature() []byte
- func (x *ProtoBlock) GetTimestamp() int64
- func (x *ProtoBlock) GetTransactions() []*transaction.ProtoTransaction
- func (*ProtoBlock) ProtoMessage()
- func (x *ProtoBlock) ProtoReflect() protoreflect.Message
- func (x *ProtoBlock) Reset()
- func (x *ProtoBlock) String() string
- type Verifier
Constants ¶
This section is empty.
Variables ¶
var File_block_block_proto protoreflect.FileDescriptor
Functions ¶
func IsValidVerifier ¶
IsValidVerifier verifies if an address is a validator
func MarshalProtoBlock ¶
func MarshalProtoBlock(b *ProtoBlock) ([]byte, error)
MarshalProtoTransaction serializes a block to a protobuf message.
func SetBlockVerifiers ¶
func SetBlockVerifiers(v Verifier)
SetBlockVerifiers adds a verifier to the block verifiers.
Types ¶
type Block ¶
type Block struct { Hash []byte MerkleHash []byte Signature []byte Timestamp int64 Data []byte PreviousBlockHash []byte Transactions []transaction.Transaction Number uint64 }
Block represents a block.
func GetGenesisBlock ¶
GetGenesisBlock returns the genesis block.
func ProtoBlockToBlock ¶
func ProtoBlockToBlock(pblock *ProtoBlock) Block
ProtoBlockToBlock returns a domain block.
func (Block) GetAndValidateCoinbaseTransaction ¶
func (b Block) GetAndValidateCoinbaseTransaction() (transaction.Transaction, error)
GetCoinbaseTransaction gets the coinbase transaction. A coinbase transaction is the first transaction and the public key of the transaction should match the block signer. coinbase should have zero fees in transaction fees.
func (Block) GetBlockHash ¶
GetBlockHash hashes the block.
func (Block) GetMerkleHash ¶
GetMerkleHash gets the merkle tree hash of all transactions.
type ProtoBlock ¶
type ProtoBlock struct { // hash represents the block hash. Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` // merkle_hash represents the block merkle hash. MerkleHash []byte `protobuf:"bytes,2,opt,name=merkle_hash,json=merkleHash,proto3" json:"merkle_hash,omitempty"` // signature of the block. Signature []byte `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"` // timestamp represents the block time. Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // data includes arbitrary data from the sealer. Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` // previous_block_hash is the hash of the previous block. PreviousBlockHash []byte `protobuf:"bytes,6,opt,name=previous_block_hash,json=previousBlockHash,proto3" json:"previous_block_hash,omitempty"` // transactions contain a list of transactions in the block. Transactions []*transaction.ProtoTransaction `protobuf:"bytes,7,rep,name=transactions,proto3" json:"transactions,omitempty"` // number represents the block number. Number uint64 `protobuf:"varint,8,opt,name=number,proto3" json:"number,omitempty"` // contains filtered or unexported fields }
ProtoBlock is the proto representation of a block.
func ToProtoBlock ¶
func ToProtoBlock(block Block) *ProtoBlock
ToProtoBlock returns a proto representation of a block.
func UnmarshalProtoBlock ¶
func UnmarshalProtoBlock(data []byte) (*ProtoBlock, error)
UnmarshalProtoBlock unserializes a byte array to a protobuf block.
func (*ProtoBlock) Descriptor
deprecated
func (*ProtoBlock) Descriptor() ([]byte, []int)
Deprecated: Use ProtoBlock.ProtoReflect.Descriptor instead.
func (*ProtoBlock) GetData ¶
func (x *ProtoBlock) GetData() []byte
func (*ProtoBlock) GetHash ¶
func (x *ProtoBlock) GetHash() []byte
func (*ProtoBlock) GetMerkleHash ¶
func (x *ProtoBlock) GetMerkleHash() []byte
func (*ProtoBlock) GetNumber ¶
func (x *ProtoBlock) GetNumber() uint64
func (*ProtoBlock) GetPreviousBlockHash ¶
func (x *ProtoBlock) GetPreviousBlockHash() []byte
func (*ProtoBlock) GetSignature ¶
func (x *ProtoBlock) GetSignature() []byte
func (*ProtoBlock) GetTimestamp ¶
func (x *ProtoBlock) GetTimestamp() int64
func (*ProtoBlock) GetTransactions ¶
func (x *ProtoBlock) GetTransactions() []*transaction.ProtoTransaction
func (*ProtoBlock) ProtoMessage ¶
func (*ProtoBlock) ProtoMessage()
func (*ProtoBlock) ProtoReflect ¶
func (x *ProtoBlock) ProtoReflect() protoreflect.Message
func (*ProtoBlock) Reset ¶
func (x *ProtoBlock) Reset()
func (*ProtoBlock) String ¶
func (x *ProtoBlock) String() string
type Verifier ¶
type Verifier struct { Address string `json:"address"` PublicKey string `json:"public_key"` DataVerifier bool `json:"data_verifier"` PublicKeyCrypto crypto.PubKey }
Verifier represents a block verifier/sealer
func GetBlockVerifiers ¶
func GetBlockVerifiers() []Verifier
GetBlockVerifiers returns a list of verifiers.