channel

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package channel implements the main components of Perun channels.

Index

Constants

View Source
const DefaultMaxIters = 15
View Source
const DefaultPollInterval = 3 * time.Second
View Source
const DisputeSuccess = "successful initialization of a dispute"
View Source
const ResponseErrorConcludingChannel = "error concluding the channel"
View Source
const WithdrawalSuccessResponse = "successful withdrawal"

Variables

View Source
var (
	ErrNotFundedInTime            = errors.New("funding not in time")
	ErrFundingReqIncompatible     = errors.New("incompatible funding request")
	ErrFailWithdrawal             = errors.New("withdrawal failed")
	ErrFailDispute                = errors.New("error disputing")
	ErrFailConclude               = errors.New("error concluding")
	ErrFinalizedNotConcludable    = errors.New("channel finalized but not concludable")
	ErrConcludedDifferentVersion  = errors.New("channel was concluded with a different version")
	ErrAdjudicatorReqIncompatible = errors.New("adjudicator request was not compatible")
	ErrReqVersionTooLow           = errors.New("request version too low")
)
View Source
var Asset = &asset{}

Asset is the unique asset that is supported by the chain.

View Source
var Backend backend

Backend is the channel backend. Is a singleton since there is only one backend.

Functions

func BigToLittleEndianBytes

func BigToLittleEndianBytes(big *big.Int) []byte

func BoolToBytes

func BoolToBytes(b bool) []byte

func CalcID

func CalcID(params *pchannel.Params) (pchannel.ID, error)

func EvaluateFundedEvents

func EvaluateFundedEvents(events []FundedEvent, funderAddr wallet.Address, freqAmount, fundedTotal uint64) (bool, error)

func MakeAlloc

func MakeAlloc(bals pchannel.Balances) []icperun.Amount

func MakeFundingReq

func MakeFundingReq(req *pchannel.FundingReq) (chanconn.Funding, error)

func MakeParts

func MakeParts(addrs []pwallet.Address) ([][]byte, error)

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

func WrapError

func WrapError(err error, msg string) error

Types

type Adjudicator

type Adjudicator struct {
	// contains filtered or unexported fields
}

func NewAdjudicator

func NewAdjudicator(acc wallet.Account, c *chanconn.Connector) *Adjudicator

NewAdjudicator returns a new Adjudicator.

func (*Adjudicator) GetAcc

func (a *Adjudicator) GetAcc() *wallet.Account

func (*Adjudicator) MakeWithdrawalReq

func (a *Adjudicator) MakeWithdrawalReq(req pchannel.AdjudicatorReq) (icperun.WithdrawalRequest, error)

func (*Adjudicator) Progress

func (a *Adjudicator) Progress(ctx context.Context, req pchannel.ProgressReq) error

Progress returns nil because app channels are currently not supported.

func (*Adjudicator) Register

func (a *Adjudicator) Register(ctx context.Context, req pchannel.AdjudicatorReq, states []pchannel.SignedState) error

Register registers and disputes a channel.

func (*Adjudicator) Subscribe

func (*Adjudicator) Withdraw

type DepositReq

type DepositReq struct {
	Balance pchannel.Bal
	Fee     pchannel.Bal
	Account wallet.Account
	Funding chanconn.Funding
}

func NewDepositReq

func NewDepositReq(bal, fee pchannel.Bal, acc wallet.Account, funding chanconn.Funding) *DepositReq

func NewDepositReqFromPerun

func NewDepositReqFromPerun(req *pchannel.FundingReq, acc pwallet.Account) (*DepositReq, error)

type Depositor

type Depositor struct {
	log.Embedding
	// contains filtered or unexported fields
}

func NewDepositor

func NewDepositor(cnr *chanconn.Connector) *Depositor

NewDepositor returns a new Depositor.

func (*Depositor) Deposit

func (d *Depositor) Deposit(ctx context.Context, req *DepositReq) error

func (*Depositor) TransferToPerun

func (d *Depositor) TransferToPerun(req *DepositReq) (chanconn.BlockNum, error)

type Event

type Event struct {
	EventType string
	Address   []uint8
	Timestamp int64
	Total     int
}

type FundedEvent

type FundedEvent struct {
	Address   wallet.Address
	Total     uint64
	Timestamp uint64
}

func SortEvents

func SortEvents(eventString string) ([]FundedEvent, error)

type Funder

type Funder struct {
	// contains filtered or unexported fields
}

func NewFunder

func NewFunder(acc wallet.Account, c *chanconn.Connector) *Funder

func (*Funder) Fund

func (f *Funder) Fund(ctx context.Context, req pchannel.FundingReq) error

func (*Funder) GetAcc

func (f *Funder) GetAcc() *wallet.Account

type FundingEventSub

type FundingEventSub struct {
	// contains filtered or unexported fields
}

func NewFundingEventSub

func NewFundingEventSub(addr wallet.Address, starttime uint64, req pchannel.FundingReq, conn *chanconn.Connector) (*FundingEventSub, error)

func (*FundingEventSub) QueryEvents

func (f *FundingEventSub) QueryEvents() (string, error)

func (*FundingEventSub) QueryFundingState

func (f *FundingEventSub) QueryFundingState(ctx context.Context) error

Directories

Path Synopsis
Package connector provides the functionality to invoke and query Perun canister methods and handles the responses.
Package connector provides the functionality to invoke and query Perun canister methods and handles the responses.
icperun
Package icperun contains functions to communicate to the Perun canister
Package icperun contains functions to communicate to the Perun canister

Jump to

Keyboard shortcuts

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