Documentation ¶
Index ¶
- Constants
- Variables
- type Block
- func (b *Block) AddTx(tx *transactions.Transaction)
- func (b *Block) CalculateHash() ([]byte, error)
- func (b *Block) Clear()
- func (b Block) Copy() payload.Safe
- func (b *Block) Equals(other *Block) bool
- func (b Block) IsEmpty() bool
- func (b Block) IsZero() bool
- func (b *Block) SetPrevBlock(prevHeader *Header)
- func (b *Block) TamperExecutedTransaction(txid []byte, gasSpent uint64, txError *rusk.ExecutedTransaction_Error) error
- func (b Block) Tx(txid []byte) (transactions.ContractCall, error)
- type Certificate
- type Header
Constants ¶
const ( // HeaderHashSize size of a block header hash in bytes. HeaderHashSize = 32 // HeightSize size of a block height field in bytes. HeightSize = 8 )
Variables ¶
var EmptyHash [32]byte
EmptyHash ...
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Header *Header `json:"header"` Txs []transactions.ContractCall `json:"transactions"` }
Block defines a block on the Dusk blockchain.
func NewBlock ¶
func NewBlock() *Block
NewBlock will return an empty Block with an empty BlockHeader.
func (*Block) AddTx ¶
func (b *Block) AddTx(tx *transactions.Transaction)
AddTx will add a transaction to the block.
func (*Block) CalculateHash ¶
CalculateHash will calculate the block hash.
func (Block) Copy ¶ added in v0.4.0
Copy returns a deep copy of the Block safe to publish to multiple subscribers.
func (Block) IsEmpty ¶ added in v0.4.0
IsEmpty tells us if a block is empty. We can check this easily, because an empty block will be created as `block.Block{}`, meaning that the header is always nil. This function basically checks the existence of the block header.
func (*Block) SetPrevBlock ¶
SetPrevBlock will set all the previous block hash field from a header.
func (*Block) TamperExecutedTransaction ¶ added in v0.5.0
func (b *Block) TamperExecutedTransaction(txid []byte, gasSpent uint64, txError *rusk.ExecutedTransaction_Error) error
TamperExecutedTransaction tamper gasSpent and txError of a transaction specified by txid.
func (Block) Tx ¶ added in v0.4.4
func (b Block) Tx(txid []byte) (transactions.ContractCall, error)
Tx returns transaction by id if exists.
type Certificate ¶
type Certificate struct { StepOneBatchedSig []byte `json:"step-one-batched-sig"` // Batched BLS signature of the block reduction phase (33 bytes) StepTwoBatchedSig []byte `json:"step-two-batched-sig"` Step uint8 `json:"step"` // Step the agreement terminated at (1 byte) StepOneCommittee uint64 `json:"step-one-committee"` // Binary representation of the committee members who voted in favor of this block (8 bytes) StepTwoCommittee uint64 `json:"step-two-committee"` }
Certificate defines a block certificate made as a result from the consensus.
func EmptyCertificate ¶
func EmptyCertificate() *Certificate
EmptyCertificate returns an empty Certificate instance.
func (*Certificate) Copy ¶ added in v0.4.0
func (c *Certificate) Copy() *Certificate
Copy complies with message.Safe interface. It returns a deep copy of the message safe to publish to multiple subscribers.
func (*Certificate) Equals ¶
func (c *Certificate) Equals(other *Certificate) bool
Equals returns true if both certificates are equal.
type Header ¶
type Header struct { Version uint8 `json:"version"` // Block version byte Height uint64 `json:"height"` // Block height Timestamp int64 `json:"timestamp"` // Block timestamp GasLimit uint64 `json:"gaslimit"` // Block gas limit PrevBlockHash []byte `json:"prev-hash"` // Hash of previous block (32 bytes) Seed []byte `json:"seed"` // Marshaled BLS signature or hash of the previous block seed (32 bytes) GeneratorBlsPubkey []byte `json:"generator"` // Generator BLS Public Key (96 bytes) StateHash []byte `json:"state-hash"` // Root hash of the Rusk Contract Storage state Hash []byte `json:"hash"` // Hash of all previous fields *Certificate `json:"certificate"` // Block certificate }
Header defines a block header on a Dusk block.
func (*Header) CalculateHash ¶
CalculateHash will calculate and return this block header's hash by encoding all the relevant fields and then hashing the result.