Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchCutter ¶
type BatchCutter struct {
// contains filtered or unexported fields
}
BatchCutter implements batch cutting.
func New ¶
func New(client protocol.Client, queue OperationQueue) *BatchCutter
New creates a Cutter implementation.
func (*BatchCutter) Add ¶
func (r *BatchCutter) Add(op *operation.QueuedOperation, protocolGenesisTime uint64) (uint, error)
Add adds the given operation to pending batch queue and returns the total number of pending operations.
func (*BatchCutter) Cut ¶
func (r *BatchCutter) Cut(force bool) (Result, error)
Cut returns the current batch along with number of items that should be remaining in the queue after the committer is called. If force is false then the batch will be cut only if it has reached the max batch size (as specified in the protocol) If force is true then the batch will be cut if there is at least one Data in the batch Note that the operations are removed from the queue when Result.Commit is invoked, otherwise they remain in the queue.
type Committer ¶ added in v0.1.3
Committer is invoked to commit a batch Cut. The new number of pending items in the queue is returned.
type OperationQueue ¶ added in v0.1.3
type OperationQueue interface { // Add adds the given operation to the tail of the queue and returns the new length of the queue. Add(data *operation.QueuedOperation, protocolGenesisTime uint64) (uint, error) // Remove removes (up to) the given number of items from the head of the queue. // Returns the actual number of items that were removed and the new length of the queue. Remove(num uint) (uint, uint, error) // Peek returns (up to) the given number of operations from the head of the queue but does not remove them. Peek(num uint) ([]*operation.QueuedOperationAtTime, error) // Len returns the number of operation in the queue. Len() uint }
OperationQueue defines the functions for adding and removing operations from a queue.
type Result ¶ added in v0.1.5
type Result struct { // Operations holds the operations that were cut from the queue Operations []*operation.QueuedOperation // ProtocolGenesisTime is the genesis time of the protocol version that was used to add the operations to the queue ProtocolGenesisTime uint64 // Pending is the number of operations remaining in the queue Pending uint // Commit should be invoked in order to commit the 'Cut' (i.e. the operations will be permanently removed from the queue) // If Commit is not invoked then the operations will remain in the queue. Commit Committer }
Result is the result of a batch 'Cut'.