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) Publish(key string, data interface{})
- 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) Subscribe(key string, c chan interface{})
- func (s *Service) SubscribeCashOut(peers []boson.Address) (c <-chan interface{}, unsub func())
- func (s *Service) SubscribeHeader() (c <-chan interface{}, unsub func())
- func (s *Service) SubscribeTrafficCheque(addresses []common.Address) (c <-chan interface{}, unsub func())
- 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) UnSubscribe(key string, ch chan interface{})
- 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 ¶ added in v1.3.0
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) 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) PublishHeader ¶ added in v1.3.0
func (s *Service) PublishHeader()
func (*Service) PublishTrafficCheque ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 (*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 ¶
func (*Service) UnSubscribe ¶ added in v1.3.0
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.