committer

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 27 Imported by: 5

Documentation

Index

Constants

View Source
const ConfigTXPrefix = "configtx_"

Variables

View Source
var (

	// ErrDiscardTX this error can be used to signal that a valid transaction should be discarded anyway
	ErrDiscardTX = errors.New("discard tx")
)

Functions

func MapValidationCode added in v0.4.0

func MapValidationCode(code int32) (int, string)

func NewParallelDependencyResolver added in v0.4.0

func NewParallelDependencyResolver() *parallelDependencyResolver

func NewSerialDependencyResolver added in v0.4.0

func NewSerialDependencyResolver() *serialDependencyResolver

Types

type ChaincodeEvent

type ChaincodeEvent struct {
	BlockNumber   uint64
	TransactionID string
	ChaincodeID   string
	EventName     string
	Payload       []byte
	Err           error
}

ChaincodeEvent models the chaincode event details.

func (*ChaincodeEvent) Message

func (chaincodeEvent *ChaincodeEvent) Message() interface{}

func (*ChaincodeEvent) Topic

func (chaincodeEvent *ChaincodeEvent) Topic() string

type CommitTx added in v0.4.0

type CommitTx struct {
	BlkNum driver2.BlockNum
	TxNum  driver2.TxNum
	TxID   driver2.TxID
	Type   common.HeaderType

	Raw      []byte
	Envelope *common.Envelope
}

type Committer added in v0.2.0

type Committer struct {
	ConfigService driver.ConfigService
	ChannelConfig driver.ChannelConfig

	Vault              driver.Vault
	EnvelopeService    driver.EnvelopeService
	TransactionFilters *committer.AggregatedTransactionFilter
	ProcessNamespaces  []string
	Ledger             driver.Ledger
	RWSetLoaderService driver.RWSetLoader
	ProcessorManager   driver.ProcessorManager
	MembershipService  driver.MembershipService
	OrderingService    OrderingService
	FabricFinality     FabricFinality

	TransactionManager driver.TransactionManager
	DependencyResolver DependencyResolver

	// events
	FinalityManager *FinalityManager
	EventsPublisher events.Publisher

	Handlers      map[common.HeaderType]TransactionHandler
	QuietNotifier bool
	// contains filtered or unexported fields
}

func New

func New(
	configService driver.ConfigService,
	channelConfig driver.ChannelConfig,
	vault driver.Vault,
	envelopeService driver.EnvelopeService,
	ledger driver.Ledger,
	rwsetLoaderService driver.RWSetLoader,
	processorManager driver.ProcessorManager,
	eventsPublisher events.Publisher,
	channelMembershipService driver.MembershipService,
	orderingService OrderingService,
	fabricFinality FabricFinality,
	transactionManager driver.TransactionManager,
	dependencyResolver DependencyResolver,
	quiet bool,
	listenerManager driver.ListenerManager,
	tracerProvider tracing.Provider,
	metricsProvider metrics.Provider,
) *Committer

func (*Committer) AddFinalityListener added in v0.4.0

func (c *Committer) AddFinalityListener(txID string, listener driver.FinalityListener) error

func (*Committer) AddTransactionFilter added in v0.4.0

func (c *Committer) AddTransactionFilter(sr driver.TransactionFilter) error

func (*Committer) Commit added in v0.2.0

func (c *Committer) Commit(ctx context.Context, block *common.Block) error

Commit commits the transactions in the block passed as argument

func (*Committer) CommitConfig added in v0.4.0

func (c *Committer) CommitConfig(ctx context.Context, blockNumber driver.BlockNum, txNum driver.TxNum, raw []byte, env *common.Envelope) error

CommitConfig is used to validate and apply configuration transactions for a Channel.

func (*Committer) CommitEndorserTransaction added in v0.2.0

func (c *Committer) CommitEndorserTransaction(ctx context.Context, txID string, blockNum driver2.BlockNum, indexInBlock uint64, env *common.Envelope, event *FinalityEvent) (bool, error)

CommitEndorserTransaction commits the transaction to the vault. It returns true, if the transaction was already processed, false otherwise.

func (*Committer) CommitTX added in v0.4.0

func (c *Committer) CommitTX(ctx context.Context, txID string, block driver.BlockNum, indexInBlock driver.TxNum, envelope *common.Envelope) (err error)

func (*Committer) DiscardEndorserTransaction added in v0.2.0

func (c *Committer) DiscardEndorserTransaction(ctx context.Context, txID string, blockNum driver2.BlockNum, envRaw []byte, event *FinalityEvent) error

DiscardEndorserTransaction discards the transaction from the vault

func (*Committer) DiscardTx added in v0.4.0

func (c *Committer) DiscardTx(ctx context.Context, txID string, message string) error

func (*Committer) GetChaincodeEvents added in v0.3.0

func (c *Committer) GetChaincodeEvents(env *common.Envelope, blockNum driver2.BlockNum) error

GetChaincodeEvents reads the chaincode events and notifies the listeners registered to the specific chaincode.

func (*Committer) GetProcessNamespace added in v0.4.0

func (c *Committer) GetProcessNamespace() []string

func (*Committer) HandleConfig added in v0.3.0

func (c *Committer) HandleConfig(ctx context.Context, _ *common.BlockMetadata, tx CommitTx) (*FinalityEvent, error)

func (*Committer) HandleEndorserTransaction added in v0.3.0

func (c *Committer) HandleEndorserTransaction(ctx context.Context, block *common.BlockMetadata, tx CommitTx) (*FinalityEvent, error)

func (*Committer) IsFinal added in v0.2.0

func (c *Committer) IsFinal(ctx context.Context, txID string) error

IsFinal takes in input a transaction id and waits for its confirmation with the respect to the passed context that can be used to set a deadline for the waiting time.

func (*Committer) ProcessNamespace added in v0.4.0

func (c *Committer) ProcessNamespace(nss ...string) error

func (*Committer) ReloadConfigTransactions added in v0.4.0

func (c *Committer) ReloadConfigTransactions() error

func (*Committer) RemoveFinalityListener added in v0.4.0

func (c *Committer) RemoveFinalityListener(txID string, listener driver.FinalityListener) error

func (*Committer) Start added in v0.4.0

func (c *Committer) Start(context context.Context) error

func (*Committer) Status added in v0.4.0

type DependencyResolver added in v0.4.0

type DependencyResolver interface {
	// Resolve returns a two-dimensional array that indicates how commits can be parallelized.
	// The transactions in each SerialExecutable slice have to follow the order indicated.
	// Each slice of the ParallelExecutable slice can be committed independently without waiting on the others.
	// Hence, for each element of the ParallelExecutable slice, a new goroutine can be launched.
	Resolve([]CommitTx) ParallelExecutable[SerialExecutable[CommitTx]]
}

DependencyResolver analyzes the dependencies between the transactions of a block and indicates which commits can take place in parallel and which have to take place serially

type FabricFinality added in v0.4.0

type FabricFinality interface {
	IsFinal(txID string, address string) error
}

type FinalityEvent added in v0.4.0

type FinalityEvent = driver2.FinalityEvent[driver.ValidationCode]

func MapFinalityEvent added in v0.4.0

func MapFinalityEvent(ctx context.Context, block *common.BlockMetadata, txNum driver.TxNum, txID string) (uint8, *FinalityEvent, error)

type FinalityManager added in v0.4.0

type Metrics

type Metrics struct {
	NotifyStatusDuration   metrics.Histogram
	NotifyFinalityDuration metrics.Histogram
	PostFinalityDuration   metrics.Histogram
	HandlerDuration        metrics.Histogram
	EventQueueDuration     metrics.Histogram
	BlockCommitDuration    metrics.Histogram
	EventQueueLength       metrics.Gauge

	Commits trace.Tracer
	Listens trace.Tracer
}

func NewMetrics added in v0.4.0

func NewMetrics(p tracing.Provider, m metrics.Provider) *Metrics

type OrdererConfig added in v0.5.0

type OrdererConfig interface {
	ConsensusType() string
	Endpoints() []*grpc.ConnectionConfig
}

type OrderingService added in v0.4.0

type OrderingService interface {
	Configure(consensusType string, orderers []*grpc.ConnectionConfig) error
}

type ParallelExecutable added in v0.4.0

type ParallelExecutable[V any] []V

ParallelExecutable is a marker type for processes that can take place in parallel

type SerialExecutable added in v0.4.0

type SerialExecutable[V any] []V

SerialExecutable is a marker type for processes that must take place serially

type TransactionHandler added in v0.3.0

type TransactionHandler = func(ctx context.Context, block *common.BlockMetadata, tx CommitTx) (*FinalityEvent, error)

type ValidationFlags

type ValidationFlags []uint8

Jump to

Keyboard shortcuts

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