Documentation ¶
Overview ¶
Package connector provides the functionality to invoke and query Perun canister methods and handles the responses.
Index ¶
- Constants
- Variables
- func BuildDeposit(addr wallet.Address, cid ChannelID) icperun.Funding
- func DecodePrincipal(principalString string) (*principal.Principal, error)
- func EvaluateConcludedEvents(events []ConcludedEvent) (bool, error)
- func GetBasePath() string
- func HandleTransferError(err *icpledger.TransferError) error
- func MakeTime(sec ChallengeDuration) time.Duration
- func MakeTransferArgs(memo Memo, amount uint64, fee uint64, recipient string) icpledger.TransferArgs
- func NewICAgent(accountPath string, host string, port int) (*agent.Agent, error)
- func NewIdentity(accountPath string) (*identity.Identity, error)
- func NewLedgerAgent(canID principal.Principal, accountPath, host string, port int) (*icpledger.Agent, error)
- func NewPerunAgent(canID principal.Principal, accountPath, host string, port int) (*icperun.Agent, error)
- type AdjEvent
- type AdjEventSub
- func (s *AdjEventSub) Close() error
- func (s *AdjEventSub) Err() error
- func (s *AdjEventSub) Events() <-chan AdjEvent
- func (e *AdjEventSub) GetEvents() <-chan AdjEvent
- func (s *AdjEventSub) Next() pchannel.AdjudicatorEvent
- func (s *AdjEventSub) PanicErr() <-chan error
- func (e *AdjEventSub) QueryEvents() (string, error)
- type AppID
- type Balance
- type BlockNum
- type ChallengeDuration
- type ChannelID
- type ConcludedEvent
- type Connector
- func (c *Connector) BuildTransfer(transactor principal.Principal, _amount, _fee *big.Int, funding Funding, ...) (icpledger.TransferArgs, error)
- func (c *Connector) DepositToPerunChannel(addr wallet.Address, cid ChannelID) error
- func (c *Connector) NotifyTransferToPerun(blockNum BlockNum, recipientPerun principal.Principal) (uint64, error)
- func (c *Connector) TransferIC(txArgs icpledger.TransferArgs) (*icpledger.TransferResult, error)
- type DisputedEvent
- type EventPredicate
- type ExecPath
- type ExpiredTimeout
- type FundedEvent
- type Funding
- type FundingID
- type Memo
- type Nonce
- type OffIdentity
- type OnIdentity
- type Params
- type PerunEvent
- type Sig
- type State
- type TimePoint
- type Timeout
- type Version
- type Withdrawal
Constants ¶
const ( DefaultBufferSize = 3 DefaultSubscriptionPollingInterval = time.Duration(4) * time.Second )
const ( // OffIdentityLen is the length of an OffIdentity in byte. OffIdentityLen = 32 // OnIdentityLen is the length of an OnIdentity in byte. OnIdentityLen = 32 // NonceLen is the length of a Nonce in byte. NonceLen = 32 // SigLen is the length of a Sig in byte. SigLen = 64 // FIDLen is the length of a FundingId in byte. FIDLen = 32 // Length of a channel ID in byte. IDLen = 32 // Fee for transfering on IC ICTransferFee = 10000 // MaxBalance is the maximum balance allowed MaxBalance = uint64(1) << 30 )
const ChanBuffSize = 1024
const DefaultTimeoutPollInterval = 1 * time.Second
DefaultTimeoutPollInterval default value for the PollInterval of a Timeout.
const MaxNumIters = 4
Variables ¶
var ( // ErrNonceOutOfRange a nonce was out of range of valid values. ErrNonceOutOfRange = errors.New("nonce values was out of range") // ErrAllocIncompatible an allocation was incompatible. ErrAllocIncompatible = errors.New("incompatible allocation") // ErrStateIncompatible a state was incompatible. ErrStateIncompatible = errors.New("incompatible state") // ErrIdentLenMismatch the length of an identity was wrong. ErrIdentLenMismatch = errors.New("length of an identity was wrong") // Channel was assumed concluded, but is not ErrNotConcluded = errors.New("channel not concluded") // Depositing funds into the canister failed ErrFundTransfer = errors.New("funding transfer failed") )
Functions ¶
func EvaluateConcludedEvents ¶
func EvaluateConcludedEvents(events []ConcludedEvent) (bool, error)
func GetBasePath ¶
func GetBasePath() string
func HandleTransferError ¶
func HandleTransferError(err *icpledger.TransferError) error
func MakeTime ¶
func MakeTime(sec ChallengeDuration) time.Duration
MakeTime creates a new time from the argument.
func MakeTransferArgs ¶
func NewLedgerAgent ¶
Types ¶
type AdjEvent ¶
type AdjEvent interface { SetEventData(cid pchannel.ID, version uint64, finalized bool, alloc [2]uint64, timeout, timestamp uint64) error ID() pchannel.ID Timeout() pchannel.Timeout Version() Version Tstamp() uint64 }
predecessor to the go-perun AdjEvent interface
type AdjEventSub ¶
type AdjEventSub struct { Ev []AdjEvent // contains filtered or unexported fields }
AdjudicatorSub implements the AdjudicatorSubscription interface.
func NewAdjEventSub ¶
func NewAdjEventSub(addr pwallet.Address, chanID pchannel.ID, starttime uint64, req pchannel.AdjudicatorReq, conn *Connector) (*AdjEventSub, error)
func NewAdjudicatorSub ¶
func (*AdjEventSub) Close ¶
func (s *AdjEventSub) Close() error
func (*AdjEventSub) Err ¶
func (s *AdjEventSub) Err() error
func (*AdjEventSub) Events ¶
func (s *AdjEventSub) Events() <-chan AdjEvent
func (*AdjEventSub) GetEvents ¶
func (e *AdjEventSub) GetEvents() <-chan AdjEvent
func (*AdjEventSub) Next ¶
func (s *AdjEventSub) Next() pchannel.AdjudicatorEvent
Next implements the AdjudicatorSub.Next function.
func (*AdjEventSub) PanicErr ¶
func (s *AdjEventSub) PanicErr() <-chan error
func (*AdjEventSub) QueryEvents ¶
func (e *AdjEventSub) QueryEvents() (string, error)
type ChallengeDuration ¶
type ChallengeDuration = uint64
ChallengeDuration the duration of a challenge as defined by go-perun.
func MakeChallengeDuration ¶
func MakeChallengeDuration(challengeDuration uint64) ChallengeDuration
MakeChallengeDuration creates a new ChallengeDuration from the argument.
type ConcludedEvent ¶
type ConcludedEvent struct { Finalized bool Alloc [2]uint64 Tout uint64 Timestamp uint64 VersionV Version IDV pchannel.ID // contains filtered or unexported fields }
func ParseEventsConcluded ¶
func ParseEventsConcluded(input string) ([]ConcludedEvent, error)
func (*ConcludedEvent) ID ¶
func (c *ConcludedEvent) ID() pchannel.ID
func (*ConcludedEvent) SetEventData ¶
func (*ConcludedEvent) Timeout ¶
func (c *ConcludedEvent) Timeout() pchannel.Timeout
func (*ConcludedEvent) Tstamp ¶
func (c *ConcludedEvent) Tstamp() uint64
func (*ConcludedEvent) Version ¶
func (c *ConcludedEvent) Version() Version
type Connector ¶
type Connector struct { Log log.Embedding ICAgent *agent.Agent PerunID *principal.Principal LedgerID *principal.Principal L1Account *principal.Principal LedgerAgent *icpledger.Agent PerunAgent *icperun.Agent }
Connects Perun users with the Internet Computer
func NewICConnector ¶
func (*Connector) BuildTransfer ¶
func (*Connector) DepositToPerunChannel ¶
func (*Connector) NotifyTransferToPerun ¶
func (*Connector) TransferIC ¶
func (c *Connector) TransferIC(txArgs icpledger.TransferArgs) (*icpledger.TransferResult, error)
type DisputedEvent ¶
type DisputedEvent struct { Finalized bool Alloc [2]uint64 Tout uint64 Timestamp uint64 VersionV Version IDV pchannel.ID // contains filtered or unexported fields }
func (*DisputedEvent) ID ¶
func (d *DisputedEvent) ID() pchannel.ID
func (*DisputedEvent) SetEventData ¶
func (*DisputedEvent) Timeout ¶
func (d *DisputedEvent) Timeout() pchannel.Timeout
func (*DisputedEvent) Tstamp ¶
func (d *DisputedEvent) Tstamp() Version
func (*DisputedEvent) Version ¶
func (d *DisputedEvent) Version() Version
type EventPredicate ¶
type EventPredicate func(PerunEvent) bool
EventPredicate can be used to filter events.
type ExpiredTimeout ¶
type ExpiredTimeout struct{}
ExpiredTimeout is always expired. Implements the Perun Timeout interface.
func NewExpiredTimeout ¶
func NewExpiredTimeout() *ExpiredTimeout
NewExpiredTimeout returns a new ExpiredTimeout.
type FundedEvent ¶
func (*FundedEvent) ID ¶
func (c *FundedEvent) ID() pchannel.ID
func (*FundedEvent) Timeout ¶
func (c *FundedEvent) Timeout() pchannel.Timeout
func (*FundedEvent) Version ¶
func (c *FundedEvent) Version() Version
type Funding ¶
type Funding struct { // Channel is the channel to fund. Channel ChannelID // Part is the participant who wants to fund. Part OffIdentity }
Funding is used to calculate a FundingId.
func NewFunding ¶
func NewFunding(id ChannelID, part OffIdentity) *Funding
NewFunding returns a new Funding.
type OffIdentity ¶
type OffIdentity = [OffIdentityLen]byte
OffIdentity is an off-chain identity.
func MakeOffIdent ¶
func MakeOffIdent(part pwallet.Address) (OffIdentity, error)
func MakeOffIdents ¶
func MakeOffIdents(parts []pwallet.Address) ([]OffIdentity, error)
MakeOffIdents creates a new []OffIdentity.
type OnIdentity ¶
type OnIdentity = [OnIdentityLen]byte
OnIdentity is an on-chain identity.
func MakeOnIdent ¶
func MakeOnIdent(addr wallet.Address) (OnIdentity, error)
type Params ¶
type Params struct { // Nonce is the unique nonce of a channel. Nonce Nonce // Participants are the off-chain participants of a channel. Participants []OffIdentity // ChallengeDuration is the duration that disputes can be refuted in. ChallengeDuration ChallengeDuration // App is the identifier of the channel application. App AppID }
Params holds the fixed parameters of a channel and uniquely identifies it.
type PerunEvent ¶
PerunEvent is a Perun event.
type State ¶
type State struct { // Channel is the unique ID of the channel that this state belongs to. Channel ChannelID // Version is the version of the state. Version Version // Balances are the balances of the participants. Balances []Balance // Final whether or not this state is the final one. Final bool // Data is the channel's application data. Data []byte }
State is the state of a channel.
type Timeout ¶
Timeout can be used to wait until a specific timepoint is reached by the blockchain. Implements the Perun Timeout interface.
func MakeTimeout ¶
func MakeTimeout(sec ChallengeDuration) *Timeout
MakeTimeout creates a new timeout.
func NewTimeout ¶
NewTimeout returns a new Timeout which expires at the given time.
type Withdrawal ¶
type Withdrawal struct { // Channel is the channel from which to withdraw. Channel ChannelID // Part is the participant who wants to withdraw. Part OffIdentity // Receiver is the receiver of the withdrawal. Receiver OnIdentity }
Withdrawal is used by a participant to withdraw his on-chain funds.