Documentation
¶
Overview ¶
Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompletionPromise ¶
type CompletionPromise struct {
// contains filtered or unexported fields
}
func NewCompletionPromise ¶
func NewCompletionPromise(timeout time.Duration) *CompletionPromise
func (*CompletionPromise) Wait ¶
func (s *CompletionPromise) Wait() (*types.TxReceipt, error)
Wait is called in order to wait for synchronous transaction completion, rejection, or timeout. When a transaction is committed, a `TxReceipt` is returned. When a transaction is rejected, an error is returned, for example `NotLeaderError`. When wait times out, `TimeoutErr` is returned.
type OneQueueBarrier ¶
type OneQueueBarrier struct {
// contains filtered or unexported fields
}
OneQueueBarrier is used to synchronize a single producing go-routine and a single consuming go-routine. The producing go-routine enqueues an entry and waits for its consumption to finish. The consuming go-routine dequeues an entry, consumes it, and releases the waiting producing go-routine by sending a reply. Both go-routines are released by closing the OneQueueBarrier.
func NewOneQueueBarrier ¶
func NewOneQueueBarrier(logger *logger.SugarLogger) *OneQueueBarrier
NewOneQueueBarrier creates a new OneQueueBarrier.
func (*OneQueueBarrier) Close ¶
func (qb *OneQueueBarrier) Close() (err error)
Close signals both waiting go-routines to exit and close respective channels.
func (*OneQueueBarrier) Dequeue ¶
func (qb *OneQueueBarrier) Dequeue() (interface{}, error)
Dequeue waits for an entry to be consumed. After consuming the entry is done, the producing go-routine must be release by invoking Reply(). An error is returned if the OneQueueBarrier was closed.
func (*OneQueueBarrier) EnqueueWait ¶
func (qb *OneQueueBarrier) EnqueueWait(entry interface{}) (interface{}, error)
EnqueueWait submits an entry for consumption and ways for a reply, indicating processing had finished. An error is returned if the OneQueueBarrier was closed.
func (*OneQueueBarrier) Reply ¶
func (qb *OneQueueBarrier) Reply(reply interface{}) error
Reply sends a reply to the waiting producing go-routine, thus releasing it. The reply can be nil or an object. An error is returned if the OneQueueBarrier was closed.
type PendingTxs ¶
func NewPendingTxs ¶
func NewPendingTxs(logger *logger.SugarLogger) *PendingTxs
func (*PendingTxs) Add ¶
func (p *PendingTxs) Add(txID string, promise *CompletionPromise)
func (*PendingTxs) DoneWithReceipt ¶
func (p *PendingTxs) DoneWithReceipt(txIDs []string, blockHeader *types.BlockHeader)
DoneWithReceipt is called after the commit of a block. The `txIDs` slice must be in the same order that transactions appear in the block.
func (*PendingTxs) Empty ¶
func (p *PendingTxs) Empty() bool
func (*PendingTxs) Has ¶
func (p *PendingTxs) Has(txID string) bool
func (*PendingTxs) ReleaseWithError ¶
func (p *PendingTxs) ReleaseWithError(txIDs []string, err error)
ReleaseWithError is called when block replication fails with an error, typically NotLeaderError. This may come from the block replicator or the block creator. The `txIDs` slice does not have to be in the same order that transactions appear in the block.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is queue data structure implemented using go channels
func (*Queue) Dequeue ¶
func (q *Queue) Dequeue() interface{}
Dequeue removes and returns an entry from the head of the queue
func (*Queue) DequeueWithWaitLimit ¶
DequeueWithWaitLimit waits for the specified duration to dequeue an entry from the queue. If the queue has been empty for the specified duration, it will return nil