Documentation ¶
Index ¶
- Variables
- type Addressbook
- type ApiInterface
- type CashOutStatus
- type CashStatus
- type SendChequeFunc
- type Service
- func (s *Service) API() rpc.API
- func (s *Service) Address() common.Address
- func (s *Service) AvailableBalance() (*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) 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) PublishCashOut(msg CashOutStatus)
- func (s *Service) PublishHeader()
- func (s *Service) PublishTrafficCheque(overlay common.Address)
- 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) SubscribeCashOut(notifier *rpc.Notifier, sub *rpc.Subscription, peers []boson.Address)
- func (s *Service) SubscribeHeader(notifier *rpc.Notifier, sub *rpc.Subscription)
- func (s *Service) SubscribeTrafficCheque(notifier *rpc.Notifier, sub *rpc.Subscription, addresses []common.Address)
- 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) (*big.Int, 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 API() rpc.API }
type CashOutStatus ¶
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, subPub subscribe.SubPub) *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) PublishCashOut ¶
func (s *Service) PublishCashOut(msg CashOutStatus)
func (*Service) PublishHeader ¶
func (s *Service) PublishHeader()
func (*Service) PublishTrafficCheque ¶
func (*Service) PutRetrieveTraffic ¶
func (*Service) PutTransferTraffic ¶
func (*Service) ReceiveCheque ¶
func (*Service) RetrieveTraffic ¶
func (*Service) SetNotifyPaymentFunc ¶
func (s *Service) SetNotifyPaymentFunc(notifyPaymentFunc settlement.NotifyPaymentFunc)
func (*Service) SubscribeCashOut ¶
func (*Service) SubscribeHeader ¶
func (s *Service) SubscribeHeader(notifier *rpc.Notifier, sub *rpc.Subscription)
func (*Service) SubscribeTrafficCheque ¶
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 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
}
Click to show internal directories.
Click to hide internal directories.