Documentation ¶
Index ¶
- Variables
- type Addressbook
- type ApiInterface
- type Service
- func (s *Service) CashCheque(ctx context.Context, peer swarm.Address) (common.Hash, error)
- func (s *Service) CashoutStatus(ctx context.Context, peer swarm.Address) (*chequebook.CashoutStatus, error)
- func (s *Service) Handshake(peer swarm.Address, beneficiary common.Address) error
- func (s *Service) LastReceivedCheque(peer swarm.Address) (*chequebook.SignedCheque, error)
- func (s *Service) LastReceivedCheques() (map[string]*chequebook.SignedCheque, error)
- func (s *Service) LastSentCheque(peer swarm.Address) (*chequebook.SignedCheque, error)
- func (s *Service) LastSentCheques() (map[string]*chequebook.SignedCheque, error)
- func (s *Service) Metrics() []prometheus.Collector
- func (s *Service) Pay(ctx context.Context, peer swarm.Address, amount *big.Int) error
- func (s *Service) ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque) (err error)
- func (s *Service) SetNotifyPaymentFunc(notifyPaymentFunc settlement.NotifyPaymentFunc)
- func (s *Service) SettlementsReceived() (map[string]*big.Int, error)
- func (s *Service) SettlementsSent() (map[string]*big.Int, error)
- func (s *Service) TotalReceived(peer swarm.Address) (totalReceived *big.Int, err error)
- func (s *Service) TotalSent(peer swarm.Address) (totalSent *big.Int, err error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWrongChequebook is the error if a peer uses a different chequebook from before. ErrWrongChequebook = errors.New("wrong chequebook") // ErrWrongBeneficiary is the error if a peer uses a different beneficiary than expected. ErrWrongBeneficiary = errors.New("wrong beneficiary") // ErrUnknownBeneficary is the error if a peer has never announced a beneficiary. ErrUnknownBeneficary = errors.New("unknown beneficiary for peer") )
Functions ¶
This section is empty.
Types ¶
type Addressbook ¶
type Addressbook interface { // Beneficiary returns the beneficiary for the given peer. Beneficiary(peer swarm.Address) (beneficiary common.Address, known bool, err error) // Chequebook returns the chequebook for the given peer. Chequebook(peer swarm.Address) (chequebookAddress common.Address, known bool, err error) // BeneficiaryPeer returns the peer for a beneficiary. BeneficiaryPeer(beneficiary common.Address) (peer swarm.Address, known bool, err error) // ChequebookPeer returns the peer for a beneficiary. ChequebookPeer(chequebook common.Address) (peer swarm.Address, known bool, err error) // PutBeneficiary stores the beneficiary for the given peer. PutBeneficiary(peer swarm.Address, beneficiary common.Address) error // PutChequebook stores the chequebook for the given peer. PutChequebook(peer swarm.Address, chequebook common.Address) error }
Addressbook maps peers to beneficaries, chequebooks and in reverse.
func NewAddressbook ¶
func NewAddressbook(store storage.StateStorer) Addressbook
NewAddressbook creates a new addressbook using the store.
type ApiInterface ¶
type ApiInterface interface { // LastSentCheque returns the last sent cheque for the peer LastSentCheque(peer swarm.Address) (*chequebook.SignedCheque, error) // LastSentCheques returns the list of last sent cheques for all peers LastSentCheques() (map[string]*chequebook.SignedCheque, error) // LastReceivedCheque returns the last received cheque for the peer LastReceivedCheque(peer swarm.Address) (*chequebook.SignedCheque, error) // LastReceivedCheques returns the list of last received cheques for all peers LastReceivedCheques() (map[string]*chequebook.SignedCheque, error) // CashCheque sends a cashing transaction for the last cheque of the peer CashCheque(ctx context.Context, peer swarm.Address) (common.Hash, error) // CashoutStatus gets the status of the latest cashout transaction for the peers chequebook CashoutStatus(ctx context.Context, peer swarm.Address) (*chequebook.CashoutStatus, error) }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the implementation of the swap settlement layer.
func New ¶
func New(proto swapprotocol.Interface, logger logging.Logger, store storage.StateStorer, chequebook chequebook.Service, chequeStore chequebook.ChequeStore, addressbook Addressbook, networkID uint64, cashout chequebook.CashoutService, p2pService p2p.Service) *Service
New creates a new swap Service.
func (*Service) CashCheque ¶
CashCheque sends a cashing transaction for the last cheque of the peer
func (*Service) CashoutStatus ¶
func (s *Service) CashoutStatus(ctx context.Context, peer swarm.Address) (*chequebook.CashoutStatus, error)
CashoutStatus gets the status of the latest cashout transaction for the peers chequebook
func (*Service) LastReceivedCheque ¶
func (s *Service) LastReceivedCheque(peer swarm.Address) (*chequebook.SignedCheque, error)
LastReceivedCheque returns the last received cheque for the peer
func (*Service) LastReceivedCheques ¶
func (s *Service) LastReceivedCheques() (map[string]*chequebook.SignedCheque, error)
LastReceivedCheques returns the list of last received cheques for all peers
func (*Service) LastSentCheque ¶
func (s *Service) LastSentCheque(peer swarm.Address) (*chequebook.SignedCheque, error)
LastSentCheque returns the last sent cheque for the peer
func (*Service) LastSentCheques ¶
func (s *Service) LastSentCheques() (map[string]*chequebook.SignedCheque, error)
LastSentCheques returns the list of last sent cheques for all peers
func (*Service) Metrics ¶
func (s *Service) Metrics() []prometheus.Collector
func (*Service) ReceiveCheque ¶
func (s *Service) ReceiveCheque(ctx context.Context, peer swarm.Address, cheque *chequebook.SignedCheque) (err error)
ReceiveCheque is called by the swap protocol if a cheque is received.
func (*Service) SetNotifyPaymentFunc ¶
func (s *Service) SetNotifyPaymentFunc(notifyPaymentFunc settlement.NotifyPaymentFunc)
SetNotifyPaymentFunc sets the NotifyPaymentFunc to notify
func (*Service) SettlementsReceived ¶
SettlementsReceived returns received settlements for each individual known peer.
func (*Service) SettlementsSent ¶
SettlementsSent returns sent settlements for each individual known peer
func (*Service) TotalReceived ¶
TotalReceived returns the total amount received from a peer