Documentation
¶
Index ¶
- Variables
- func IsStatusStoredInDB(status committerpb.Status) bool
- func MalformedTxTestCases(txb *workload.TxBuilder) (txs []*servicepb.LoadGenTx, expectedStatuses []committerpb.Status)
- func RequireNotifications(t *testing.T, ...)
- func RequireStreamBlocks(t *testing.T, stream committerpb.SidecarService_StreamBlocksClient, ...)
- type Config
- type LedgerConfig
- type NotificationServiceConfig
- type Service
- func (s *Service) Deliver(srv peer.Deliver_DeliverServer) error
- func (*Service) DeliverFiltered(peer.Deliver_DeliverFilteredServer) errordeprecated
- func (*Service) DeliverWithPrivateData(peer.Deliver_DeliverWithPrivateDataServer) errordeprecated
- func (s *Service) GetBlockByNumber(_ context.Context, req *committerpb.BlockNumber) (*common.Block, error)
- func (s *Service) GetBlockByTxID(_ context.Context, req *committerpb.TxID) (*common.Block, error)
- func (s *Service) GetBlockchainInfo(_ context.Context, _ *emptypb.Empty) (*common.BlockchainInfo, error)
- func (s *Service) GetTxByID(_ context.Context, req *committerpb.TxID) (*common.Envelope, error)
- func (n Service) OpenNotificationStream(stream committerpb.SidecarService_OpenNotificationStreamServer) error
- func (s *Service) RegisterService(srv serve.Servers)
- func (s *Service) Run(ctx context.Context) error
- func (n Service) StreamBlocks(req *committerpb.StreamBlocksRequest, ...) error
- func (s *Service) WaitForReady(ctx context.Context) bool
- type TxParsingConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyTxID is returned when a transaction ID query is called with an empty tx_id. ErrEmptyTxID = errors.New("tx_id must not be empty") )
Functions ¶
func IsStatusStoredInDB ¶ added in v0.1.5
func IsStatusStoredInDB(status committerpb.Status) bool
IsStatusStoredInDB returns true if the given status code can be stored in the state DB.
func MalformedTxTestCases ¶ added in v0.1.5
func MalformedTxTestCases(txb *workload.TxBuilder) ( txs []*servicepb.LoadGenTx, expectedStatuses []committerpb.Status, )
MalformedTxTestCases are valid and invalid TXs due to malformed.
func RequireNotifications ¶ added in v0.1.5
func RequireNotifications( t *testing.T, notifyStream committerpb.SidecarService_OpenNotificationStreamClient, expectedBlockNumber uint64, txIDs []string, status []committerpb.Status, )
RequireNotifications verifies that the expected notification were received.
func RequireStreamBlocks ¶ added in v1.0.6
func RequireStreamBlocks( t *testing.T, stream committerpb.SidecarService_StreamBlocksClient, expectedHeader *common.BlockHeader, txIDs []string, status []committerpb.Status, )
RequireStreamBlocks verifies that the expected transactions were received from the StreamBlocks stream.
Types ¶
type Config ¶
type Config struct {
Committer *connection.ClientConfig `mapstructure:"committer"`
Orderer ordererdial.Config `mapstructure:"orderer" default:"suspicion-grace-period-per-block=1s"`
Ledger LedgerConfig `mapstructure:"ledger"`
// LastCommittedBlockSetInterval is the interval at which the sidecar updates
// the coordinator with the last committed block.
LastCommittedBlockSetInterval time.Duration `mapstructure:"last-committed-block-set-interval" default:"5s" validate:"gt=0"` //nolint:lll,revive
WaitingTxsLimit int `mapstructure:"waiting-txs-limit" default:"100000" validate:"gt=0"`
// CheckpointHoldRetryInterval is the wait before fetching a held checkpoint block again.
// The pause gives the snapshot hasher time to finish computing the local hash.
CheckpointHoldRetryInterval time.Duration `mapstructure:"checkpoint-hold-retry-interval" default:"1m" validate:"gt=0"` //nolint:lll,revive
// ChannelBufferSize is the buffer size that will be used to queue blocks, requests, and statuses.
ChannelBufferSize int `mapstructure:"channel-buffer-size" default:"100" validate:"gt=0"`
Notification NotificationServiceConfig `mapstructure:"notification"`
TxParsing TxParsingConfig `mapstructure:",squash"`
}
Config holds the configuration of the sidecar service. This includes sidecar endpoint, committer endpoint to which the sidecar pushes the block and pulls statuses, and the config of ledger service, and the orderer setup. It may contain the orderer endpoint from which the sidecar pulls blocks.
type LedgerConfig ¶
type LedgerConfig struct {
Path string `mapstructure:"path" default:"./ledger/"`
// SyncInterval controls how often the block store fsyncs to durable storage.
// A value of N means every Nth block triggers a full sync; intermediate
// blocks are written without fsync. A value of 0 or 1 means every block is synced.
SyncInterval uint64 `mapstructure:"sync-interval"`
}
LedgerConfig holds the ledger path.
type NotificationServiceConfig ¶ added in v0.1.5
type NotificationServiceConfig struct {
// MaxTimeout is an upper limit on the request's timeout to prevent resource exhaustion.
// If a request doesn't specify a timeout, this value will be used.
MaxTimeout time.Duration `mapstructure:"max-timeout" default:"1m" validate:"gt=0"`
// MaxActiveTxIDs is the global limit on total active txID subscriptions across all streams.
MaxActiveTxIDs int `mapstructure:"max-active-tx-ids" default:"100000" validate:"gt=0"`
// MaxTxIDsPerRequest is the maximum number of txIDs allowed in a single notification request.
MaxTxIDsPerRequest int `mapstructure:"max-tx-ids-per-request" default:"1000" validate:"gt=0"`
// StreamWriteTimeout is the timeout for writing notifications to the stream.
// If a client cannot consume notifications within this timeout, it will be disconnected.
StreamWriteTimeout time.Duration `mapstructure:"stream-write-timeout" default:"30s" validate:"gt=0"`
}
NotificationServiceConfig holds the parameters for notifications.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a relay service which relays the block from orderer to committer. Further, it aggregates the transaction status and forwards the validated block to clients who have registered on the ledger server.
- Implements peer.DeliverServer by streaming blocks from a blockStore.
- Implements committerpb.SidecarServiceServer: block-store reads are served here, event streams by the embedded notifier, and RPCs the sidecar does not implement yet fall through to the notifier's UnimplementedSidecarServiceServer.
func (*Service) Deliver ¶ added in v1.0.1
func (s *Service) Deliver(srv peer.Deliver_DeliverServer) error
Deliver delivers the requested blocks.
func (*Service) DeliverFiltered
deprecated
added in
v1.0.1
func (*Service) DeliverFiltered(peer.Deliver_DeliverFilteredServer) error
DeliverFiltered implements an API in peer.DeliverServer.
Deprecated: this method is implemented to have compatibility with Fabric so that the fabric smart client can easily integrate with both FabricX and Fabric. Eventually, this method will be removed.
func (*Service) DeliverWithPrivateData
deprecated
added in
v1.0.1
func (*Service) DeliverWithPrivateData(peer.Deliver_DeliverWithPrivateDataServer) error
DeliverWithPrivateData implements an API in peer.DeliverServer.
Deprecated: this method is implemented to have compatibility with Fabric so that the fabric smart client can easily integrate with both FabricX and Fabric. Eventually, this method will be removed.
func (*Service) GetBlockByNumber ¶ added in v1.0.1
func (s *Service) GetBlockByNumber(_ context.Context, req *committerpb.BlockNumber) (*common.Block, error)
GetBlockByNumber retrieves a block by its sequence number.
func (*Service) GetBlockByTxID ¶ added in v1.0.1
GetBlockByTxID retrieves the block that contains the specified transaction.
func (*Service) GetBlockchainInfo ¶ added in v1.0.1
func (s *Service) GetBlockchainInfo(_ context.Context, _ *emptypb.Empty) (*common.BlockchainInfo, error)
GetBlockchainInfo returns the current blockchain height and hash metadata.
func (*Service) GetTxByID ¶ added in v1.0.1
GetTxByID retrieves the transaction envelope for the specified transaction ID.
func (Service) OpenNotificationStream ¶ added in v1.0.6
func (n Service) OpenNotificationStream(stream committerpb.SidecarService_OpenNotificationStreamServer) error
OpenNotificationStream implements the committerpb.SidecarServiceServer API.
func (*Service) RegisterService ¶ added in v0.1.5
RegisterService registers the sidecar's gRPC services and monitoring server.
func (*Service) Run ¶
Run starts the sidecar service. The call to Run blocks until an error occurs or the context is canceled.
func (Service) StreamBlocks ¶ added in v1.0.6
func (n Service) StreamBlocks( req *committerpb.StreamBlocksRequest, stream committerpb.SidecarService_StreamBlocksServer, ) error
StreamBlocks implements the committerpb.SidecarServiceServer API. It streams all committed transactions to the client, with optional filtering by namespace and transaction status.
type TxParsingConfig ¶ added in v1.0.6
type TxParsingConfig struct {
// MaxWorkers is the most goroutines one block's parsing is split across. Parsing is CPU
// bound, so more workers than the cores left over by the sidecar's other stages cannot help.
MaxWorkers int `mapstructure:"max-workers-for-tx-parsing" default:"1" validate:"gt=0"`
// MinBatchSize is the smallest share of a block worth giving a goroutine of its own; below
// it, handing the share over costs more than parsing it in place.
MinBatchSize int `mapstructure:"min-tx-parsing-batch-size" default:"256" validate:"gt=0"`
}
TxParsingConfig controls how many goroutines parse a block's transactions before the sidecar sends the block to the coordinator. Its fields sit at the top level of the sidecar's config.