balance

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PayPerInterval

func PayPerInterval(storeDriver store.BalanceStore, interval time.Duration, creditPerInterval *big.Int) *payPerInterval

PayPerInterval creates a balance Manager which implements a pay-per-interval scheme.

Types

type LowBalanceError added in v0.2.5

type LowBalanceError struct {
	MinBalance     *big.Int
	CurrentBalance *big.Int
}

LowBalanceError is returned when the account's positive balance check fails.

func (LowBalanceError) Error added in v0.2.5

func (err LowBalanceError) Error() string

type Manager

type Manager interface {
	// OnClient is called when a client connects to the pool. If an error is
	// returned, the client is disconnected with the error.
	OnClient(node store.Node) error
	// OnUpdate is called every time the state of a node's peers is updated.
	OnUpdate(node store.Node, peers []store.Node) (store.Balance, error)
}

Manager is the minimal interface required to support a payment scheme. The payment implementation will receive handler calls. TODO: OnConnect, OnDisconnect, etc? OnConnect would be useful for time-based trials. TODO: Support error type that forces a disconnect (eg. trial expired?)

type NoBalance

type NoBalance struct{}

NoBalance always returns an empty balance

func (NoBalance) OnClient added in v0.2.5

func (b NoBalance) OnClient(node store.Node) error

func (NoBalance) OnUpdate

func (b NoBalance) OnUpdate(node store.Node, peers []store.Node) (store.Balance, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL