swapprotocol

package
v0.0.0-...-c9321c3 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// EmitCheque sends a signed cheque to a peer.
	EmitCheque(ctx context.Context, peer penguin.Address, cheque *chequebook.SignedCheque) error
}

Interface is the main interface to send messages over swap protocol.

type Service

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

Service is the main implementation of the swap protocol.

func New

func New(streamer p2p.Streamer, logger logging.Logger, beneficiary common.Address) *Service

New creates a new swap protocol Service.

func (*Service) EmitCheque

func (s *Service) EmitCheque(ctx context.Context, peer penguin.Address, cheque *chequebook.SignedCheque) error

EmitCheque sends a signed cheque to a peer.

func (*Service) Protocol

func (s *Service) Protocol() p2p.ProtocolSpec

func (*Service) SetSwap

func (s *Service) SetSwap(swap Swap)

SetSwap sets the swap to notify.

type Swap

type Swap interface {
	// ReceiveCheque is called by the swap protocol if a cheque is received.
	ReceiveCheque(ctx context.Context, peer penguin.Address, cheque *chequebook.SignedCheque) error
	// Handshake is called by the swap protocol when a handshake is received.
	Handshake(peer penguin.Address, beneficiary common.Address) error
}

Swap is the interface the settlement layer should implement to receive cheques.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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