traffic

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: BSD-3-Clause Imports: 19 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

	API() rpc.API
}

type CashOutStatus added in v1.3.0

type CashOutStatus struct {
	Overlay boson.Address `json:"overlay"`
	Status  bool          `json:"status"`
}

type CashStatus added in v1.3.0

type CashStatus = int
const (
	UnOperation CashStatus = iota
	Operation
)

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) API added in v1.3.0

func (s *Service) API() rpc.API

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) 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) 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) Publish added in v1.3.0

func (s *Service) Publish(key string, data interface{})

func (*Service) PublishHeader added in v1.3.0

func (s *Service) PublishHeader()

func (*Service) PublishTrafficCheque added in v1.3.0

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

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) Subscribe added in v1.3.0

func (s *Service) Subscribe(key string, c chan interface{})

func (*Service) SubscribeCashOut added in v1.3.0

func (s *Service) SubscribeCashOut(peers []boson.Address) (c <-chan interface{}, unsub func())

func (*Service) SubscribeHeader added in v1.3.0

func (s *Service) SubscribeHeader() (c <-chan interface{}, unsub func())

func (*Service) SubscribeTrafficCheque added in v1.3.0

func (s *Service) SubscribeTrafficCheque(addresses []common.Address) (c <-chan interface{}, unsub func())

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) (*big.Int, error)

func (*Service) UnSubscribe added in v1.3.0

func (s *Service) UnSubscribe(key string, ch chan interface{})

func (*Service) UpdatePeerBalance

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

type Traffic

type Traffic struct {
	sync.Mutex
	// contains filtered or unexported fields
}

type TrafficCheque

type TrafficCheque struct {
	Peer                boson.Address `json:"peer"`
	OutstandingTraffic  *big.Int      `json:"outstandingTraffic"`
	SentSettlements     *big.Int      `json:"sentSettlements"`
	ReceivedSettlements *big.Int      `json:"receivedSettlements"`
	Total               *big.Int      `json:"total"`
	Uncashed            *big.Int      `json:"unCashed"`
	Status              CashStatus    `json:"status"`
}

type TrafficInfo

type TrafficInfo struct {
	Balance          *big.Int `json:"balance"`
	AvailableBalance *big.Int `json:"availableBalance"`
	TotalSendTraffic *big.Int `json:"totalSendTraffic"`
	ReceivedTraffic  *big.Int `json:"receivedTraffic"`
}

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