traffic

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: BSD-3-Clause Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownBeneficary = errors.New("unknown beneficiary for peer")
	ErrInsufficientFunds = errors.New("insufficient token balance")
)

Functions

This section is empty.

Types

type Addressbook

type Addressbook interface {
	// Beneficiary returns the beneficiary for the given peer.
	Beneficiary(peer boson.Address) (beneficiary common.Address, known bool)
	// BeneficiaryPeer returns the peer for a beneficiary.
	BeneficiaryPeer(beneficiary common.Address) (peer boson.Address, known bool)
	// PutBeneficiary stores the beneficiary for the given peer.
	PutBeneficiary(peer boson.Address, beneficiary common.Address) error

	InitAddressBook() 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(peer boson.Address) (*chequePkg.Cheque, error)

	LastReceivedCheque(peer boson.Address) (*chequePkg.SignedCheque, error)

	CashCheque(ctx context.Context, peer boson.Address) (common.Hash, error)

	TrafficCheques() ([]*TrafficCheque, error)

	Address() common.Address

	TrafficInfo() (*TrafficInfo, error)

	TrafficInit() error
}

type SendChequeFunc

type SendChequeFunc func(cheque *chequePkg.SignedCheque) error

type Service

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

func New

func New(logger logging.Logger, chainAddress common.Address, store storage.StateStorer, trafficChainService chain.Traffic,
	chequeStore chequePkg.ChequeStore, cashout chequePkg.CashoutService, p2pService p2p.Service, addressBook Addressbook,
	chequeSigner chequePkg.ChequeSigner, protocol trafficprotocol.Interface, chainID int64) *Service

func (*Service) Address

func (s *Service) Address() common.Address

func (*Service) AvailableBalance

func (s *Service) AvailableBalance() (*big.Int, error)

AvailableBalance Get actual available balance

func (*Service) Balance

func (s *Service) Balance() (*big.Int, error)

Balance Get chain balance

func (*Service) CashCheque

func (s *Service) CashCheque(ctx context.Context, peer boson.Address) (common.Hash, error)

CashCheque sends a cashing transaction for the last cheque of the peer

func (*Service) GetPeerBalance

func (s *Service) GetPeerBalance(peer boson.Address) (*big.Int, error)

func (*Service) GetUnPaidBalance

func (s *Service) GetUnPaidBalance(peer boson.Address) (*big.Int, error)

func (*Service) Handshake

func (s *Service) Handshake(peer boson.Address, recipient common.Address, signedCheque *chequePkg.SignedCheque) error

func (*Service) Init

func (s *Service) Init() error

func (*Service) Issue

func (s *Service) Issue(ctx context.Context, peer boson.Address, recipient, beneficiary common.Address, traffic *big.Int) error

func (*Service) LastReceivedCheque

func (s *Service) LastReceivedCheque(peer boson.Address) (*chequePkg.SignedCheque, error)

LastReceivedCheque returns the list of last received cheques for all peers

func (*Service) LastSentCheque

func (s *Service) LastSentCheque(peer boson.Address) (*chequePkg.Cheque, error)

LastSentCheque returns the last sent cheque for the peer

func (*Service) Metrics

func (s *Service) Metrics() []prometheus.Collector

func (*Service) Pay

func (s *Service) Pay(ctx context.Context, peer boson.Address, paymentThreshold *big.Int) error

func (*Service) PutRetrieveTraffic

func (s *Service) PutRetrieveTraffic(peer boson.Address, traffic *big.Int) error

func (*Service) PutTransferTraffic

func (s *Service) PutTransferTraffic(peer boson.Address, traffic *big.Int) error

func (*Service) ReceiveCheque

func (s *Service) ReceiveCheque(ctx context.Context, peer boson.Address, cheque *chequePkg.SignedCheque) error

func (*Service) RetrieveTraffic

func (s *Service) RetrieveTraffic(peer boson.Address) (traffic *big.Int, err error)

func (*Service) SetNotifyPaymentFunc

func (s *Service) SetNotifyPaymentFunc(notifyPaymentFunc settlement.NotifyPaymentFunc)

func (*Service) TotalReceived

func (s *Service) TotalReceived(peer boson.Address) (totalReceived *big.Int, err error)

TotalReceived returns the total amount received from a peer

func (*Service) TotalSent

func (s *Service) TotalSent(peer boson.Address) (totalSent *big.Int, err error)

TotalSent returns the total amount sent to a peer

func (*Service) TrafficCheques

func (s *Service) TrafficCheques() ([]*TrafficCheque, error)

func (*Service) TrafficInfo

func (s *Service) TrafficInfo() (*TrafficInfo, error)

func (*Service) TrafficInit

func (s *Service) TrafficInit() error

func (*Service) TransferTraffic

func (s *Service) TransferTraffic(peer boson.Address) (traffic *big.Int, err error)

func (*Service) UpdatePeerBalance

func (s *Service) UpdatePeerBalance(peer boson.Address) error

type Traffic

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

type TrafficCheque

type TrafficCheque struct {
	Peer                boson.Address
	OutstandingTraffic  *big.Int
	SentSettlements     *big.Int
	ReceivedSettlements *big.Int
	Total               *big.Int
	Uncashed            *big.Int
}

type TrafficInfo

type TrafficInfo struct {
	Balance          *big.Int
	AvailableBalance *big.Int
	TotalSendTraffic *big.Int
	ReceivedTraffic  *big.Int
}

func NewTrafficInfo

func NewTrafficInfo() *TrafficInfo

type TrafficPeer

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

Directories

Path Synopsis
pb
Package pb holds only Protocol Buffer definitions and generated code.
Package pb holds only Protocol Buffer definitions and generated code.

Jump to

Keyboard shortcuts

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