types

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchIDEqual added in v0.0.19

func BatchIDEqual(a BatchID, b BatchID) bool

func BatchIDToString

func BatchIDToString(id BatchID) string

func BatchRequestsDataHashWithSerialize

func BatchRequestsDataHashWithSerialize(br BatchedRequests) []byte

BatchRequestsDataHashWithSerialize is a reference implementation for how Digest should work, if computed with serialization. It is used only in tests, as it is slower that the cumulative version implemented in Digest(), above.

Types

type AssemblerConsensusPosition added in v0.0.19

type AssemblerConsensusPosition struct {
	DecisionNum DecisionNum
	BatchIndex  int
}

type Batch added in v0.0.19

type Batch interface {
	BatchID
	Requests() BatchedRequests
}

type BatchAttestation added in v0.0.16

type BatchAttestation interface {
	Fragments() []BatchAttestationFragment
	Digest() []byte
	Seq() BatchSequence
	Primary() PartyID
	Shard() ShardID
	Serialize() []byte
	Deserialize([]byte) error
}

type BatchAttestationFragment added in v0.0.16

type BatchAttestationFragment interface {
	Seq() BatchSequence
	Primary() PartyID
	Shard() ShardID
	Signer() PartyID
	Signature() []byte
	Digest() []byte
	Serialize() []byte
	Deserialize([]byte) error
	ConfigSequence() ConfigSequence
	String() string
}

type BatchID

type BatchID interface {
	// Shard the shard from which this batch was produced.
	Shard() ShardID
	// Primary is the Party ID of the primary batcher which produces this batch.
	Primary() PartyID
	// Seq is the sequence number of this batch.
	Seq() BatchSequence
	// Digest is the digest of the requests in this batch.
	Digest() []byte
}

BatchID is the tuple that identifies a batch.

type BatchSequence

type BatchSequence uint64

BatchSequence is the number a primary batcher assigns to the batches it produces.

type BatchedRequests

type BatchedRequests [][]byte

BatchedRequests are used to represent a batch of requests.

The requests can be: 1. Client TXs - in the batchers and assemblers 2. Consensus requests, .i.e. control events submitted from batchers to consensus.

func (*BatchedRequests) Deserialize

func (br *BatchedRequests) Deserialize(bytes []byte) error

func (*BatchedRequests) Digest

func (br *BatchedRequests) Digest() []byte

Digest calculates a sha256 digest on a safe representation of the BatchedRequests. This is equivalent to BatchRequestsDataHashWithSerialize, yet faster, and consumes less extra memory.

func (*BatchedRequests) Serialize

func (br *BatchedRequests) Serialize() []byte

func (*BatchedRequests) SizeBytes

func (br *BatchedRequests) SizeBytes() int64

SizeBytes counts the cumulative size of the requests. A `nil` and empty slice returns 0.

type ConfigSequence added in v0.0.19

type ConfigSequence uint64

ConfigSequence numbers configuration changes, as delivered by a config TX and the corresponding config block. It starts from 0 (on the genesis block) and increases by 1 with every config change.

type DecisionNum

type DecisionNum uint64

DecisionNum is the number the consensus nodes assign to each decision they produce.

type Logger

type Logger interface {
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Errorf(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Panicf(template string, args ...interface{})
}

type OrderedBatchAttestation added in v0.0.19

type OrderedBatchAttestation interface {
	BatchAttestation() BatchAttestation
	// OrderingInfo is an opaque object that provides extra information on the order of the batch attestation and
	// metadata to be used in the construction of the block.
	OrderingInfo() OrderingInfo
}

OrderedBatchAttestation carries the BatchAttestation and information on the actual order of the batch from the consensus cluster. This information is used when appending to the ledger, and helps the assembler to recover following a shutdown or a failure.

type OrderingInfo added in v0.0.19

type OrderingInfo interface {
	fmt.Stringer
}

OrderingInfo is an opaque object that provides extra information on the order of the batch attestation and metadata to be used in the construction of the block.

type PartyID

type PartyID uint16

PartyID identifies a party, must be >0.

type ShardID

type ShardID uint16

ShardID identifies a shard, should be >0. Value math.MaxUint16 is reserved.

const ShardIDConsensus ShardID = math.MaxUint16

ShardIDConsensus is used to encode a config TX / batch emitted by consensus.

type SimpleBatch

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

func NewSimpleBatch

func NewSimpleBatch(seq BatchSequence, shard ShardID, primary PartyID, requests BatchedRequests) *SimpleBatch

func (*SimpleBatch) Digest

func (sb *SimpleBatch) Digest() []byte

func (*SimpleBatch) Primary

func (sb *SimpleBatch) Primary() PartyID

func (*SimpleBatch) Requests

func (sb *SimpleBatch) Requests() BatchedRequests

func (*SimpleBatch) Seq

func (sb *SimpleBatch) Seq() BatchSequence

func (*SimpleBatch) Shard

func (sb *SimpleBatch) Shard() ShardID

type SimpleBatchAttestationFragment

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

func NewSimpleBatchAttestationFragment

func NewSimpleBatchAttestationFragment(shard ShardID, primary PartyID, seq BatchSequence, digest []byte, signer PartyID, configSqn ConfigSequence) *SimpleBatchAttestationFragment

NewSimpleBatchAttestationFragment creates a new, unsigned, SimpleBatchAttestationFragment.

func (*SimpleBatchAttestationFragment) ConfigSequence added in v0.0.19

func (s *SimpleBatchAttestationFragment) ConfigSequence() ConfigSequence

func (*SimpleBatchAttestationFragment) Deserialize

func (s *SimpleBatchAttestationFragment) Deserialize(bytes []byte) error

Deserialize unmarshalls every field including the signature, using an auxiliary ASN1 struct and asn1.Unmarshal.

func (*SimpleBatchAttestationFragment) Digest

func (s *SimpleBatchAttestationFragment) Digest() []byte

func (*SimpleBatchAttestationFragment) Primary

func (*SimpleBatchAttestationFragment) Seq

func (*SimpleBatchAttestationFragment) Serialize

func (s *SimpleBatchAttestationFragment) Serialize() []byte

Serialize marshals every field including the signature, using an auxiliary ASN1 struct and asn1.Marshal.

func (*SimpleBatchAttestationFragment) SetSignature

func (s *SimpleBatchAttestationFragment) SetSignature(sig []byte)

func (*SimpleBatchAttestationFragment) Shard

func (*SimpleBatchAttestationFragment) Signature

func (s *SimpleBatchAttestationFragment) Signature() []byte

func (*SimpleBatchAttestationFragment) Signer

func (*SimpleBatchAttestationFragment) String

func (*SimpleBatchAttestationFragment) ToBeSigned

func (s *SimpleBatchAttestationFragment) ToBeSigned() []byte

ToBeSigned marshals every field except the signature, using an auxiliary ASN1 struct and asn1.Marshal.

Jump to

Keyboard shortcuts

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