Version: v2.2.26+incompatible Latest Latest

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

Go to latest
Published: Jan 22, 2019 License: GPL-3.0 Imports: 5 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type InPayment

type InPayment interface {
	Receive(promise Promise) (*big.Int, error)
	AutoCash(cashInterval time.Duration, maxUncashed *big.Int)

interface for the (delayed) incoming payment system with autocash

type OutPayment

type OutPayment interface {
	Issue(amount *big.Int) (promise Promise, err error)
	AutoDeposit(interval time.Duration, threshold, buffer *big.Int)

interface for the (delayed) ougoing payment system with autodeposit

type Params

type Params struct {

Params extends the public profile with private parameters relating to automatic deposit and automatic cashing

type Payment

type Payment struct {
	Out         OutPayment // outgoing payment handler
	In          InPayment  // incoming  payment handler
	Buys, Sells bool

type Profile

type Profile struct {
	BuyAt  *big.Int // accepted max price for chunk
	SellAt *big.Int // offered sale price for chunk
	PayAt  uint     // threshold that triggers payment request
	DropAt uint     // threshold that triggers disconnect

public swap profile public parameters for SWAP, serializable config struct passed in handshake

type Promise

type Promise interface{}

Promise 3rd party Provable Promise of Payment issued by outPayment serialisable to send with Protocol

type Protocol

type Protocol interface {
	Pay(int, Promise) // units, payment proof
	String() string

interface for the peer protocol for testing or external alternative payment

type Strategy

type Strategy struct {
	AutoCashInterval     time.Duration // default interval for autocash
	AutoCashThreshold    *big.Int      // threshold that triggers autocash (wei)
	AutoDepositInterval  time.Duration // default interval for autocash
	AutoDepositThreshold *big.Int      // threshold that triggers autodeposit (wei)
	AutoDepositBuffer    *big.Int      // buffer that is surplus for fork protection etc (wei)

Strategy encapsulates parameters relating to automatic deposit and automatic cashing

type Swap

type Swap struct {
	// contains filtered or unexported fields

swap is the swarm accounting protocol instance * pairwise accounting and payments

func New

func New(local *Params, pm Payment, proto Protocol) (self *Swap, err error)

swap constructor

func (*Swap) Add

func (self *Swap) Add(n int) error

Add(n) n > 0 called when promised/provided n units of service n < 0 called when used/requested n units of service

func (*Swap) Balance

func (self *Swap) Balance() int

func (*Swap) Receive

func (self *Swap) Receive(units int, promise Promise) error

receive(units, promise) is called by the protocol when a payment msg is received returns error if promise is invalid.

func (*Swap) SetParams

func (self *Swap) SetParams(local *Params)

to set strategy dynamically

func (*Swap) SetRemote

func (self *Swap) SetRemote(remote *Profile)

entry point for setting remote swap profile (e.g from handshake or other message)

func (*Swap) Stop

func (self *Swap) Stop()

stop() causes autocash loop to terminate. Called after protocol handle loop terminates.

Source Files

Jump to

Keyboard shortcuts

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