batcher

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: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBAF

func CreateBAF(signer Signer, id types.PartyID, shard types.ShardID, digest []byte, primary types.PartyID, seq types.BatchSequence) (types.BatchAttestationFragment, error)

func CreateComplaint

func CreateComplaint(signer Signer, id types.PartyID, shard types.ShardID, term uint64, reason string) (*state.Complaint, error)

func GetBatchersEndpointsAndCerts

func GetBatchersEndpointsAndCerts(batchers []config.BatcherInfo) map[types.PartyID]*EndpointAndCerts

func GetBatchersIDs

func GetBatchersIDs(batchers []config.BatcherInfo) []types.PartyID

Types

type Acker added in v0.0.19

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

Acker handles the acks coming from secondaries

func NewAcker added in v0.0.19

func NewAcker(confirmedSeq types.BatchSequence, gap types.BatchSequence, numOfParties uint16, threshold uint16, logger types.Logger) *Acker

NewAcker returns a new acker

func (*Acker) HandleAck added in v0.0.19

func (a *Acker) HandleAck(seq types.BatchSequence, from types.PartyID)

HandleAck handles an ack with a given seq from a specific party

func (*Acker) Stop added in v0.0.19

func (a *Acker) Stop()

Stop stops the acker (the waiting)

func (*Acker) WaitForSecondaries added in v0.0.19

func (a *Acker) WaitForSecondaries(seq types.BatchSequence) chan struct{}

WaitForSecondaries waits for the secondaries to keep up with the primary (to send enough acks)

type BAFCreator added in v0.0.19

type BAFCreator interface {
	CreateBAF(seq types.BatchSequence, primary types.PartyID, shard types.ShardID, digest []byte) types.BatchAttestationFragment
}

BAFCreator creates a baf

type BAFSender added in v0.0.19

type BAFSender interface {
	SendBAF(baf types.BatchAttestationFragment)
}

BAFSender sends the baf to the consenters

type BatchAcker added in v0.0.19

type BatchAcker interface {
	Ack(seq types.BatchSequence, to types.PartyID)
}

BatchAcker sends an ack over a specific batch

type BatchLedgeReader added in v0.0.19

type BatchLedgeReader interface {
	Height(partyID types.PartyID) uint64
	RetrieveBatchByNumber(partyID types.PartyID, seq uint64) types.Batch
}

type BatchLedger added in v0.0.19

type BatchLedger interface {
	BatchLedgerWriter
	BatchLedgeReader
}

type BatchLedgerWriter added in v0.0.19

type BatchLedgerWriter interface {
	Append(partyID types.PartyID, batchSeq types.BatchSequence, batchedRequests types.BatchedRequests)
}

type BatchPuller

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

func NewBatchPuller

func NewBatchPuller(config *config.BatcherNodeConfig, ledger BatchLedger, logger types.Logger) *BatchPuller

func (*BatchPuller) PullBatches

func (bp *BatchPuller) PullBatches(from types.PartyID) <-chan types.Batch

func (*BatchPuller) Stop

func (bp *BatchPuller) Stop()

type BatchedRequestsVerifier added in v0.0.19

type BatchedRequestsVerifier interface {
	VerifyBatchedRequests(types.BatchedRequests) error
}

BatchedRequestsVerifier verifies batched requests

type Batcher

type Batcher struct {
	Net    Net
	Ledger *node_ledger.BatchLedgerArray
	// contains filtered or unexported fields
}

func (*Batcher) Ack

func (b *Batcher) Ack(seq types.BatchSequence, to types.PartyID)

func (*Batcher) Broadcast

func (*Batcher) Complain

func (b *Batcher) Complain(reason string)

func (*Batcher) CreateBAF

func (b *Batcher) CreateBAF(seq types.BatchSequence, primary types.PartyID, shard types.ShardID, digest []byte) types.BatchAttestationFragment

func (*Batcher) Deliver

func (*Batcher) FwdRequestStream

func (*Batcher) GetLatestStateChan

func (b *Batcher) GetLatestStateChan() <-chan *state.State

func (*Batcher) GetPrimaryID

func (b *Batcher) GetPrimaryID() types.PartyID

func (*Batcher) NotifyAck

func (*Batcher) OnFirstStrikeTimeout

func (b *Batcher) OnFirstStrikeTimeout(req []byte)

func (*Batcher) OnSecondStrikeTimeout

func (b *Batcher) OnSecondStrikeTimeout()

func (*Batcher) Run

func (b *Batcher) Run()

func (*Batcher) SendBAF

func (b *Batcher) SendBAF(baf types.BatchAttestationFragment)

func (*Batcher) Stop

func (b *Batcher) Stop()

func (*Batcher) Submit

func (b *Batcher) Submit(ctx context.Context, req *protos.Request) (*protos.SubmitResponse, error)

func (*Batcher) SubmitStream

func (b *Batcher) SubmitStream(stream protos.RequestTransmit_SubmitStreamServer) error

type BatcherDeliverService

type BatcherDeliverService struct {
	LedgerArray *ledger.BatchLedgerArray
	Logger      types.Logger
}

func (*BatcherDeliverService) Broadcast

func (*BatcherDeliverService) Deliver

type BatcherRole added in v0.0.19

type BatcherRole struct {
	Batchers                []types.PartyID
	BatchTimeout            time.Duration
	RequestInspector        RequestInspector
	ID                      types.PartyID
	Shard                   types.ShardID
	Threshold               int
	N                       uint16
	Logger                  types.Logger
	Ledger                  BatchLedger
	BatchPuller             BatchesPuller
	StateProvider           StateProvider
	BAFCreator              BAFCreator
	BAFSender               BAFSender
	BatchAcker              BatchAcker
	Complainer              Complainer
	BatchedRequestsVerifier BatchedRequestsVerifier
	MemPool                 MemPool
	BatchSequenceGap        types.BatchSequence
	// contains filtered or unexported fields
}

func (*BatcherRole) HandleAck added in v0.0.19

func (b *BatcherRole) HandleAck(seq types.BatchSequence, from types.PartyID)

func (*BatcherRole) Start added in v0.0.19

func (b *BatcherRole) Start()

func (*BatcherRole) Stop added in v0.0.19

func (b *BatcherRole) Stop()

func (*BatcherRole) Submit added in v0.0.19

func (b *BatcherRole) Submit(request []byte) error

type BatchesPuller added in v0.0.19

type BatchesPuller interface {
	PullBatches(from types.PartyID) <-chan types.Batch
	Stop()
}

type ClientRequestSigVerifier

type ClientRequestSigVerifier interface {
	VerifyClientRequestSig(req []byte) error
}

ClientRequestSigVerifier verifies a single client's requests (signatures)

type Complainer added in v0.0.19

type Complainer interface {
	Complain(string)
}

type ConsensusStateReplicatorCreator

type ConsensusStateReplicatorCreator interface {
	CreateStateConsensusReplicator(conf *node_config.BatcherNodeConfig, logger types.Logger) StateReplicator
}

type ConsensusStateReplicatorFactory

type ConsensusStateReplicatorFactory struct{}

func (*ConsensusStateReplicatorFactory) CreateStateConsensusReplicator

func (c *ConsensusStateReplicatorFactory) CreateStateConsensusReplicator(config *node_config.BatcherNodeConfig, logger types.Logger) StateReplicator

type ConsenterControlEventSender

type ConsenterControlEventSender interface {
	SendControlEvent(ce state.ControlEvent) error
}

type ConsenterControlEventSenderCreator

type ConsenterControlEventSenderCreator interface {
	CreateConsenterControlEventSender(TLSPrivateKeyFile config.RawBytes, TLSCertificateFile config.RawBytes, consenterInfo config.ConsenterInfo) ConsenterControlEventSender
}

type ConsenterControlEventSenderFactory

type ConsenterControlEventSenderFactory struct{}

func (*ConsenterControlEventSenderFactory) CreateConsenterControlEventSender

func (f *ConsenterControlEventSenderFactory) CreateConsenterControlEventSender(TLSPrivateKey config.RawBytes, TLSCertificate config.RawBytes, consenterInfo config.ConsenterInfo) ConsenterControlEventSender

type ConsenterControlEventStream

type ConsenterControlEventStream struct {
	ConsenterInfo  config.ConsenterInfo
	TLSPrivateKey  config.RawBytes
	TLSCertificate config.RawBytes
	// contains filtered or unexported fields
}

func CreateConsenterControlEventStream

func CreateConsenterControlEventStream(TLSPrivateKey config.RawBytes, TLSCertificate config.RawBytes, consenterInfo config.ConsenterInfo) *ConsenterControlEventStream

func (*ConsenterControlEventStream) SendControlEvent

func (s *ConsenterControlEventStream) SendControlEvent(ce state.ControlEvent) error

type ControlEventBroadcaster

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

func NewControlEventBroadcaster

func NewControlEventBroadcaster(senders []ConsenterControlEventSender, n int, f int, minRetryInterval time.Duration, maxRetryDelay time.Duration, logger types.Logger, ctx context.Context, cancelFunc context.CancelFunc) *ControlEventBroadcaster

func (*ControlEventBroadcaster) BroadcastControlEvent

func (b *ControlEventBroadcaster) BroadcastControlEvent(ce state.ControlEvent) error

func (*ControlEventBroadcaster) Stop

func (b *ControlEventBroadcaster) Stop()

type EndpointAndCerts

type EndpointAndCerts struct {
	Endpoint   string
	TLSCACerts []config.RawBytes
}

type MemPool added in v0.0.19

type MemPool interface {
	NextRequests(ctx context.Context) [][]byte
	RemoveRequests(requests ...string)
	Submit(request []byte) error
	Restart(bool)
	Close()
}

type Net

type Net interface {
	Stop()
}

type NoopClientRequestSigVerifier

type NoopClientRequestSigVerifier struct{}

func (*NoopClientRequestSigVerifier) VerifyClientRequestSig

func (v *NoopClientRequestSigVerifier) VerifyClientRequestSig(req []byte) error

type PrimaryAckConnector

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

func CreatePrimaryAckConnector

func CreatePrimaryAckConnector(primaryID types.PartyID, shardID types.ShardID, logger types.Logger, config *node_config.BatcherNodeConfig, batchers map[types.PartyID]*EndpointAndCerts, ctx context.Context, timeout, minRetryInterval, maxRetryDelay time.Duration) *PrimaryAckConnector

func (*PrimaryAckConnector) ConnectToNewPrimary

func (p *PrimaryAckConnector) ConnectToNewPrimary(primaryID types.PartyID)

func (*PrimaryAckConnector) ConnectToPrimary

func (p *PrimaryAckConnector) ConnectToPrimary()

func (*PrimaryAckConnector) ResetConnection

func (p *PrimaryAckConnector) ResetConnection()

func (*PrimaryAckConnector) SendAck

func (p *PrimaryAckConnector) SendAck(seq types.BatchSequence)

func (*PrimaryAckConnector) Stop

func (p *PrimaryAckConnector) Stop()

type PrimaryReqConnector

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

func CreatePrimaryReqConnector

func CreatePrimaryReqConnector(primaryID types.PartyID, logger types.Logger, config *node_config.BatcherNodeConfig, batchers map[types.PartyID]*EndpointAndCerts, ctx context.Context, timeout, minRetryInterval, maxRetryDelay time.Duration) *PrimaryReqConnector

func (*PrimaryReqConnector) ConnectToNewPrimary

func (p *PrimaryReqConnector) ConnectToNewPrimary(primaryID types.PartyID)

func (*PrimaryReqConnector) ConnectToPrimary

func (p *PrimaryReqConnector) ConnectToPrimary()

func (*PrimaryReqConnector) ResetConnection

func (p *PrimaryReqConnector) ResetConnection()

func (*PrimaryReqConnector) SendReq

func (p *PrimaryReqConnector) SendReq(req []byte)

func (*PrimaryReqConnector) Stop

func (p *PrimaryReqConnector) Stop()

type RequestInspector added in v0.0.19

type RequestInspector interface {
	RequestID(req []byte) string
}

type RequestVerifier

type RequestVerifier interface {
	VerifyRequest(req []byte) error
}

RequestVerifier verifies a single request (format and signatures)

type RequestsInspectorVerifier

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

func NewRequestsInspectorVerifier

func NewRequestsInspectorVerifier(logger types.Logger, config *config.BatcherNodeConfig, clientRequestVerifier ClientRequestSigVerifier, requestVerifier RequestVerifier) *RequestsInspectorVerifier

func (*RequestsInspectorVerifier) RequestID

func (r *RequestsInspectorVerifier) RequestID(req []byte) string

func (*RequestsInspectorVerifier) VerifyBatchedRequests

func (r *RequestsInspectorVerifier) VerifyBatchedRequests(reqs types.BatchedRequests) error

func (*RequestsInspectorVerifier) VerifyRequest

func (r *RequestsInspectorVerifier) VerifyRequest(req []byte) error

type SeqAcker added in v0.0.19

type SeqAcker interface {
	Stop()
	HandleAck(seq types.BatchSequence, from types.PartyID)
	WaitForSecondaries(seq types.BatchSequence) chan struct{}
}

type Signer

type Signer interface {
	Sign([]byte) ([]byte, error)
}

Signer signs messages

type StateProvider added in v0.0.19

type StateProvider interface {
	GetLatestStateChan() <-chan *state.State
}

type StateReplicator

type StateReplicator interface {
	ReplicateState() <-chan *state.State
	Stop()
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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