Documentation ¶
Index ¶
- Variables
- type Addressbook
- type ApiInterface
- type SendChequeFunc
- type Service
- func (s *Service) Address() common.Address
- func (s *Service) AvailableBalance() (*big.Int, error)
- func (s *Service) Balance() (*big.Int, error)
- func (s *Service) CashCheque(ctx context.Context, peer boson.Address) (common.Hash, error)
- func (s *Service) GetPeerBalance(peer boson.Address) (*big.Int, error)
- func (s *Service) GetUnPaidBalance(peer boson.Address) (*big.Int, error)
- func (s *Service) Handshake(peer boson.Address, recipient common.Address, ...) error
- func (s *Service) Init() error
- func (s *Service) Issue(ctx context.Context, peer boson.Address, recipient, beneficiary common.Address, ...) error
- func (s *Service) LastReceivedCheque(peer boson.Address) (*chequePkg.SignedCheque, error)
- func (s *Service) LastSentCheque(peer boson.Address) (*chequePkg.Cheque, error)
- func (s *Service) Metrics() []prometheus.Collector
- func (s *Service) Pay(ctx context.Context, peer boson.Address, paymentThreshold *big.Int) error
- func (s *Service) PutRetrieveTraffic(peer boson.Address, traffic *big.Int) error
- func (s *Service) PutTransferTraffic(peer boson.Address, traffic *big.Int) error
- func (s *Service) ReceiveCheque(ctx context.Context, peer boson.Address, cheque *chequePkg.SignedCheque) error
- func (s *Service) RetrieveTraffic(peer boson.Address) (traffic *big.Int, err error)
- func (s *Service) SetNotifyPaymentFunc(notifyPaymentFunc settlement.NotifyPaymentFunc)
- func (s *Service) TotalReceived(peer boson.Address) (totalReceived *big.Int, err error)
- func (s *Service) TotalSent(peer boson.Address) (totalSent *big.Int, err error)
- func (s *Service) TrafficCheques() ([]*TrafficCheque, error)
- func (s *Service) TrafficInfo() (*TrafficInfo, error)
- func (s *Service) TrafficInit() error
- func (s *Service) TransferTraffic(peer boson.Address) (traffic *big.Int, err error)
- func (s *Service) UpdatePeerBalance(peer boson.Address) error
- type Traffic
- type TrafficCheque
- type TrafficInfo
- type TrafficPeer
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) AvailableBalance ¶
AvailableBalance Get actual available balance
func (*Service) CashCheque ¶
CashCheque sends a cashing transaction for the last cheque of the peer
func (*Service) GetPeerBalance ¶
func (*Service) GetUnPaidBalance ¶
func (*Service) LastReceivedCheque ¶
LastReceivedCheque returns the list of last received cheques for all peers
func (*Service) LastSentCheque ¶
LastSentCheque returns the last sent cheque for the peer
func (*Service) Metrics ¶
func (s *Service) Metrics() []prometheus.Collector
func (*Service) PutRetrieveTraffic ¶
func (*Service) PutTransferTraffic ¶
func (*Service) ReceiveCheque ¶
func (*Service) RetrieveTraffic ¶
func (*Service) SetNotifyPaymentFunc ¶
func (s *Service) SetNotifyPaymentFunc(notifyPaymentFunc settlement.NotifyPaymentFunc)
func (*Service) TotalReceived ¶
TotalReceived returns the total amount received from a peer
func (*Service) TrafficCheques ¶
func (s *Service) TrafficCheques() ([]*TrafficCheque, error)
func (*Service) TrafficInfo ¶
func (s *Service) TrafficInfo() (*TrafficInfo, error)
func (*Service) TrafficInit ¶
func (*Service) TransferTraffic ¶
type TrafficCheque ¶
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
}
Click to show internal directories.
Click to hide internal directories.