delivery

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NonceSize is the default NonceSize
	NonceSize = 24
)

Variables

View Source
var (
	ErrComm      = errors.New("communication issue")
	StartGenesis = &ab.SeekPosition{
		Type: &ab.SeekPosition_Oldest{
			Oldest: &ab.SeekOldest{},
		},
	}
)

Functions

func CreateDeliverEnvelope

func CreateDeliverEnvelope(channelID string, signingIdentity SigningIdentity, cert *tls.Certificate, hasher Hasher, start *ab.SeekPosition) (*common.Envelope, error)

CreateDeliverEnvelope creates a signed envelope with SeekPosition_Newest for block

func CreateEnvelope

func CreateEnvelope(data []byte, header *common.Header, signingIdentity SigningIdentity) (*common.Envelope, error)

CreateEnvelope creates a common.Envelope with given tx bytes, header, and SigningIdentity

func CreateHeader

func CreateHeader(txType common.HeaderType, channelID string, creator []byte, tlsCertHash []byte) (string, *common.Header, error)

CreateHeader creates common.Header for a token transaction tlsCertHash is for client TLS cert, only applicable when ClientAuthRequired is true

func DeliverReceive

func DeliverReceive(df DeliverFiltered, address string, txid string, eventCh chan<- TxEvent) error

func DeliverSend

func DeliverSend(df DeliverStream, envelope *common.Envelope) error

func DeliverWaitForResponse

func DeliverWaitForResponse(ctx context.Context, eventCh <-chan TxEvent, txid string) (bool, uint64, int, error)

DeliverWaitForResponse waits for either eventChan has value (i.e., response has been received) or ctx is timed out This function assumes that the eventCh is only for the specified txid If an eventCh is shared by multiple transactions, a loop should be used to listen to events from multiple transactions

func GetRandomBytes

func GetRandomBytes(len int) ([]byte, error)

GetRandomBytes returns len random looking bytes

func GetRandomNonce

func GetRandomNonce() ([]byte, error)

GetRandomNonce returns a random byte array of length NonceSize

Types

type Callback

type Callback func(block *common.Block) (bool, error)

Callback is the callback function prototype to alert the rest of the stack about the availability of a new block. The function returns two argument a boolean to signal if delivery should be stopped, and an error to signal an issue during the processing of the block. In case of an error, the same block is re-processed after a delay.

type DeliverClient

type DeliverClient interface {

	// NewDeliverFiltered returns a DeliverFiltered
	NewDeliverFiltered(ctx context.Context, opts ...grpc.CallOption) (DeliverFiltered, error)

	// NewDeliver returns a DeliverStream
	NewDeliver(ctx context.Context, opts ...grpc.CallOption) (DeliverStream, error)

	// Certificate returns tls certificate for the deliver client to peer
	Certificate() *tls.Certificate
}

DeliverClient defines the interface to create a DeliverStream client

func NewDeliverClient

func NewDeliverClient(client peer.Client) (DeliverClient, error)

type DeliverFiltered

type DeliverFiltered interface {
	Send(*common.Envelope) error
	Recv() (*pb.DeliverResponse, error)
	CloseSend() error
}

DeliverFiltered defines the interface that abstracts deliver filtered grpc calls to peer

type DeliverStream

type DeliverStream interface {
	Send(*common.Envelope) error
	Recv() (*pb.DeliverResponse, error)
	CloseSend() error
}

DeliverStream defines the interface that abstracts deliver grpc calls to peer

type Delivery

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

func New

func New(channel string, sp view2.ServiceProvider, network Network, callback Callback, vault Vault, waitForEventTimeout time.Duration) (*Delivery, error)

func (*Delivery) GetStartPosition

func (d *Delivery) GetStartPosition() *ab.SeekPosition

func (*Delivery) Run

func (d *Delivery) Run(ctx context.Context) error

func (*Delivery) Start

func (d *Delivery) Start(ctx context.Context)

Start runs the delivery service in a goroutine

func (*Delivery) Stop

func (d *Delivery) Stop()

type Hasher

type Hasher interface {
	Hash(msg []byte) (hash []byte, err error)
}

type Network

type Network interface {
	Channel(name string) (driver.Channel, error)
	PickPeer() *grpc.ConnectionConfig
	LocalMembership() driver.LocalMembership
}

type SigningIdentity

type SigningIdentity interface {
	Serialize() ([]byte, error)
	Sign(msg []byte) ([]byte, error)
}

type TxEvent

type TxEvent struct {
	Txid         string
	Committed    bool
	Block        uint64
	IndexInBlock int
	CommitPeer   string
	Err          error
}

TxEvent contains information for token transaction commit

type Vault

type Vault interface {
	// GetLastTxID returns the last transaction id committed
	GetLastTxID() (string, error)
}

Vault models a key-value store that can be updated by committing rwsets

Jump to

Keyboard shortcuts

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