Documentation ¶
Index ¶
- Constants
- func Number(blockID workshare.Bytes32) uint32
- type Block
- func (b *Block) Body() *Body
- func (b *Block) DecodeRLP(s *rlp.Stream) error
- func (b *Block) EncodeRLP(w io.Writer) error
- func (b *Block) Header() *Header
- func (b *Block) Size() metric.StorageSize
- func (b *Block) String() string
- func (b *Block) Transactions() tx.Transactions
- func (b *Block) WithSignature(sig []byte) *Block
- type Body
- type Builder
- func (b *Builder) Alpha(alpha []byte) *Builder
- func (b *Builder) Beneficiary(addr workshare.Address) *Builder
- func (b *Builder) Build() *Block
- func (b *Builder) GasLimit(limit uint64) *Builder
- func (b *Builder) GasUsed(used uint64) *Builder
- func (b *Builder) ParentID(id workshare.Bytes32) *Builder
- func (b *Builder) ReceiptsRoot(hash workshare.Bytes32) *Builder
- func (b *Builder) StateRoot(hash workshare.Bytes32) *Builder
- func (b *Builder) Timestamp(ts uint64) *Builder
- func (b *Builder) TotalScore(score uint64) *Builder
- func (b *Builder) Transaction(tx *tx.Transaction) *Builder
- func (b *Builder) TransactionFeatures(features tx.Features) *Builder
- type ComplexSignature
- type GasLimit
- type Header
- func (h *Header) Alpha() []byte
- func (h *Header) Beneficiary() workshare.Address
- func (h *Header) Beta() (beta []byte, err error)
- func (h *Header) BetterThan(other *Header) bool
- func (h *Header) DecodeRLP(s *rlp.Stream) error
- func (h *Header) EncodeRLP(w io.Writer) error
- func (h *Header) GasLimit() uint64
- func (h *Header) GasUsed() uint64
- func (h *Header) ID() (id workshare.Bytes32)
- func (h *Header) Number() uint32
- func (h *Header) ParentID() workshare.Bytes32
- func (h *Header) ReceiptsRoot() workshare.Bytes32
- func (h *Header) Signature() []byte
- func (h *Header) Signer() (workshare.Address, error)
- func (h *Header) SigningHash() (hash workshare.Bytes32)
- func (h *Header) StateRoot() workshare.Bytes32
- func (h *Header) String() string
- func (h *Header) Timestamp() uint64
- func (h *Header) TotalScore() uint64
- func (h *Header) TxsFeatures() tx.Features
- func (h *Header) TxsRoot() workshare.Bytes32
- type Raw
Constants ¶
const (
ComplexSigSize = 81 + 65
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block is an immutable block type.
func Compose ¶
func Compose(header *Header, txs tx.Transactions) *Block
Compose compose a block with all needed components Note: This method is usually to recover a block by its portions, and the TxsRoot is not verified. To build up a block, use a Builder.
func (*Block) Transactions ¶
func (b *Block) Transactions() tx.Transactions
Transactions returns a copy of transactions.
func (*Block) WithSignature ¶
WithSignature create a new block object with signature set.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder to make it easy to build a block object.
func (*Builder) Beneficiary ¶
Beneficiary set recipient of reward.
func (*Builder) ReceiptsRoot ¶
ReceiptsRoot set receipts root.
func (*Builder) TotalScore ¶
TotalScore set total score.
func (*Builder) Transaction ¶
func (b *Builder) Transaction(tx *tx.Transaction) *Builder
Transaction add a transaction.
type ComplexSignature ¶
type ComplexSignature []byte
ComplexSignature is the signature composed by[ECDSA(Secp256k1) Signature(65 bytes)+VRF Proof(81 bytes)]
func NewComplexSignature ¶
func NewComplexSignature(signature, proof []byte) (ComplexSignature, error)
NewComplexSignature creates a new signature.
func (ComplexSignature) Proof ¶
func (ms ComplexSignature) Proof() []byte
Proof returns the VRF proof.
func (ComplexSignature) Signature ¶
func (ms ComplexSignature) Signature() []byte
Signature returns the ECDSA signature.
type GasLimit ¶
type GasLimit uint64
GasLimit to support block gas limit validation and adjustment.
func (GasLimit) Adjust ¶
Adjust suppose the receiver is parent gas limit, and calculate a valid gas limit value by apply `delta`.
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header contains almost all information about a block, except block body. It's immutable.
func (*Header) Beneficiary ¶
Beneficiary returns reward recipient.
func (*Header) BetterThan ¶
BetterThan return if this block is better than other one.
func (*Header) ID ¶
ID computes id of block. The block ID is defined as: blockNumber + hash(signingHash, signer)[4:].
func (*Header) ReceiptsRoot ¶
ReceiptsRoot returns merkle root of tx receipts.
func (*Header) SigningHash ¶
SigningHash computes hash of all header fields excluding signature.
func (*Header) StateRoot ¶
StateRoot returns account state merkle root just afert this block being applied.
func (*Header) TotalScore ¶
TotalScore returns total score that cumulated from genesis block to this one.
func (*Header) TxsFeatures ¶
TxsFeatures returns supported txs features.