Documentation ¶
Overview ¶
Package accounting provides functionalities needed to do per-peer accounting.
Index ¶
- Variables
- type Accounting
- func (a *Accounting) AsyncNotifyPayment(peer boson.Address, traffic *big.Int) error
- func (a *Accounting) Credit(ctx context.Context, peer boson.Address, traffic uint64) error
- func (a *Accounting) Debit(peer boson.Address, traffic uint64) error
- func (a *Accounting) Metrics() []prometheus.Collector
- func (a *Accounting) NotifyPayment(peer boson.Address, traffic *big.Int) error
- func (a *Accounting) Reserve(peer boson.Address, traffic uint64) (err error)
- type Interface
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDisconnectThresholdExceeded denotes a peer has exceeded the disconnect threshold. ErrDisconnectThresholdExceeded = errors.New("disconnect threshold exceeded") ErrLowAvailableExceeded = errors.New("low available balance") )
Functions ¶
This section is empty.
Types ¶
type Accounting ¶
type Accounting struct {
// contains filtered or unexported fields
}
Accounting is the main implementation of the accounting interface.
func NewAccounting ¶
func NewAccounting( paymentTolerance, paymentThreshold *big.Int, logger logging.Logger, store storage.StateStorer, settlement settlement.Interface, ) *Accounting
NewAccounting creates a new Accounting instance with the provided options.
func (*Accounting) AsyncNotifyPayment ¶
func (*Accounting) Credit ¶
Credit increases the amount of credit we have with the given peer (and decreases existing debt).
func (*Accounting) Debit ¶
func (a *Accounting) Debit(peer boson.Address, traffic uint64) error
Debit increases the amount of debt we have with the given peer (and decreases existing credit).
func (*Accounting) Metrics ¶
func (a *Accounting) Metrics() []prometheus.Collector
Metrics returns the prometheus Collector for the accounting service.
func (*Accounting) NotifyPayment ¶
type Interface ¶
type Interface interface { Reserve(peer boson.Address, traffic uint64) error // Credit increases the balance the peer has with us (we "pay" the peer). Credit(ctx context.Context, peer boson.Address, traffic uint64) error // Debit increases the balance we have with the peer (we get "paid" back). Debit(peer boson.Address, traffic uint64) error }
Interface is the Accounting interface.
Click to show internal directories.
Click to hide internal directories.