swap

package
v0.0.0-...-f8b7a73 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InPayment

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

自动刷卡(延迟)入站支付系统的支付接口

type OutPayment

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

自动存款(延迟)出站支付系统的出站支付接口

type Params

type Params struct {
	*Profile
	*Strategy
}

params使用与 自动存款和自动兑现

type Payment

type Payment struct {
	Out         OutPayment //传出付款处理程序
	In          InPayment  //入站付款经办人
	Buys, Sells bool
}

付款处理程序

type Profile

type Profile struct {
	BuyAt  *big.Int //接受的块最大价格
	SellAt *big.Int //大宗商品报价
	PayAt  uint     //触发付款请求的阈值
	DropAt uint     //触发断开连接的阈值
}

配置文件-公共交换配置文件 交换的公共参数,握手中传递的可序列化配置结构

type Promise

type Promise interface{}

承诺-第三方可证明的付款承诺 由预付款签发 可序列化以使用协议发送

type Protocol

type Protocol interface {
	Pay(int, Promise) //单位,付款证明
	Drop()
	String() string
}

用于测试或外部替代支付的对等协议的协议接口

type Strategy

type Strategy struct {
	AutoCashInterval     time.Duration //自动清除的默认间隔
	AutoCashThreshold    *big.Int      //触发自动清除的阈值(wei)
	AutoDepositInterval  time.Duration //自动清除的默认间隔
	AutoDepositThreshold *big.Int      //触发自动报告的阈值(wei)
	AutoDepositBuffer    *big.Int      //剩余用于叉保护等的缓冲器(WEI)
}

策略封装了与 自动存款和自动兑现

type Swap

type Swap struct {
	Payment
	// contains filtered or unexported fields
}

swap是swarm会计协议实例 *成对会计和付款

func New

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

新建-交换构造函数

func (*Swap) Add

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

加法(n) 当承诺/提供n个服务单元时调用n>0 n<0使用/请求时调用n个服务单元

func (*Swap) Balance

func (swap *Swap) Balance() int

余额存取器

func (*Swap) Receive

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

当收到付款消息时,协议调用Receive(Units,Promise) 如果承诺无效,则返回错误。

func (*Swap) SetParams

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

setparams-动态设置策略

func (*Swap) SetRemote

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

setremote-设置远程交换配置文件的入口点(例如来自握手或其他消息)

func (*Swap) Stop

func (swap *Swap) Stop()

停止会导致autocash循环终止。 在协议句柄循环终止后调用。

Jump to

Keyboard shortcuts

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