Documentation ¶
Overview ¶
Package directfund implements an off-chain protocol to directly fund a channel.
Index ¶
- Constants
- Variables
- func ChannelsExistWithCounterparty(counterparty types.Address, getChannels GetChannelsByParticipantFunction, ...) (bool, error)
- func FundOnChainEffect(cId types.Destination, asset string, amount types.Funds) string
- func IsDirectFundObjective(id protocols.ObjectiveId) bool
- type GetChannelsByParticipantFunction
- type GetTwoPartyConsensusLedgerFunction
- type Objective
- func (o *Objective) Approve() protocols.Objective
- func (o *Objective) Crank(secretKey *[]byte) (protocols.Objective, protocols.SideEffects, protocols.WaitingFor, error)
- func (dfo *Objective) CreateConsensusChannel() (*consensus_channel.ConsensusChannel, error)
- func (dfo *Objective) GetStatus() protocols.ObjectiveStatus
- func (o *Objective) Id() protocols.ObjectiveId
- func (o Objective) MarshalJSON() ([]byte, error)
- func (dfo *Objective) OwnsChannel() types.Destination
- func (o *Objective) Reject() (protocols.Objective, protocols.SideEffects)
- func (o *Objective) Related() []protocols.Storable
- func (o *Objective) UnmarshalJSON(data []byte) error
- func (o *Objective) Update(p protocols.ObjectivePayload) (protocols.Objective, error)
- type ObjectiveRequest
- type ObjectiveResponse
Constants ¶
const ( WaitingForCompletePrefund protocols.WaitingFor = "WaitingForCompletePrefund" WaitingForMyTurnToFund protocols.WaitingFor = "WaitingForMyTurnToFund" WaitingForCompleteFunding protocols.WaitingFor = "WaitingForCompleteFunding" WaitingForCompletePostFund protocols.WaitingFor = "WaitingForCompletePostFund" WaitingForNothing protocols.WaitingFor = "WaitingForNothing" // Finished )
const ObjectivePrefix = "DirectFunding-"
const (
SignedStatePayload protocols.PayloadType = "SignedStatePayload"
)
Variables ¶
var ErrLedgerChannelExists error = errors.New("directfund: ledger channel already exists")
Functions ¶
func ChannelsExistWithCounterparty ¶
func ChannelsExistWithCounterparty(counterparty types.Address, getChannels GetChannelsByParticipantFunction, getTwoPartyConsensusLedger GetTwoPartyConsensusLedgerFunction) (bool, error)
ChannelsExistWithCounterparty returns true if a channel or consensus_channel exists with the counterparty
func FundOnChainEffect ¶
func IsDirectFundObjective ¶
func IsDirectFundObjective(id protocols.ObjectiveId) bool
IsDirectFundObjective inspects a objective id and returns true if the objective id is for a direct fund objective.
Types ¶
type GetChannelsByParticipantFunction ¶
GetChannelByIdFunction specifies a function that can be used to retrieve channels from a store.
type GetTwoPartyConsensusLedgerFunction ¶
type GetTwoPartyConsensusLedgerFunction func(counterparty types.Address) (ledger *consensus_channel.ConsensusChannel, ok bool)
GetTwoPartyConsensusLedgerFuncion describes functions which return a ConsensusChannel ledger channel between the calling client and the given counterparty, if such a channel exists.
type Objective ¶
type Objective struct { Status protocols.ObjectiveStatus C *channel.Channel // contains filtered or unexported fields }
Objective is a cache of data computed by reading from the store. It stores (potentially) infinite data
func ConstructFromPayload ¶
func ConstructFromPayload( preApprove bool, op protocols.ObjectivePayload, myAddress types.Address, ) (Objective, error)
ConstructFromPayload initiates a Objective with data calculated from the supplied initialState and client address
func NewObjective ¶
func NewObjective(request ObjectiveRequest, preApprove bool, myAddress types.Address, chainId *big.Int, getChannels GetChannelsByParticipantFunction, getTwoPartyConsensusLedger GetTwoPartyConsensusLedgerFunction) (Objective, error)
NewObjective creates a new direct funding objective from a given request.
func (*Objective) Crank ¶
func (o *Objective) Crank(secretKey *[]byte) (protocols.Objective, protocols.SideEffects, protocols.WaitingFor, error)
Crank inspects the extended state and declares a list of Effects to be executed It's like a state machine transition function where the finite / enumerable state is returned (computed from the extended state) rather than being independent of the extended state; and where there is only one type of event ("the crank") with no data on it at all
func (*Objective) CreateConsensusChannel ¶
func (dfo *Objective) CreateConsensusChannel() (*consensus_channel.ConsensusChannel, error)
CreateConsensusChannel creates a ConsensusChannel from the Objective by extracting signatures and a single asset outcome from the post fund state.
func (*Objective) GetStatus ¶
func (dfo *Objective) GetStatus() protocols.ObjectiveStatus
GetStatus returns the status of the objective.
func (*Objective) Id ¶
func (o *Objective) Id() protocols.ObjectiveId
func (Objective) MarshalJSON ¶
MarshalJSON returns a JSON representation of the DirectFundObjective NOTE: Marshal -> Unmarshal is a lossy process. All channel data (other than Id) from the field C is discarded
func (*Objective) OwnsChannel ¶
func (dfo *Objective) OwnsChannel() types.Destination
OwnsChannel returns the channel that the objective is funding.
func (*Objective) Reject ¶
func (o *Objective) Reject() (protocols.Objective, protocols.SideEffects)
func (*Objective) UnmarshalJSON ¶
UnmarshalJSON populates the calling DirectFundObjective with the json-encoded data NOTE: Marshal -> Unmarshal is a lossy process. All channel data (other than Id) from the field C is discarded
type ObjectiveRequest ¶
type ObjectiveRequest struct { CounterParty types.Address ChallengeDuration uint32 Outcome outcome.Exit AppDefinition types.Address AppData types.Bytes Nonce uint64 // contains filtered or unexported fields }
ObjectiveRequest represents a request to create a new direct funding objective.
func NewObjectiveRequest ¶
func NewObjectiveRequest( counterparty types.Address, challengeDuration uint32, outcome outcome.Exit, nonce uint64, appDefinition types.Address, ) ObjectiveRequest
NewObjectiveRequest creates a new ObjectiveRequest.
func (ObjectiveRequest) Id ¶
func (r ObjectiveRequest) Id(myAddress types.Address, chainId *big.Int) protocols.ObjectiveId
Id returns the objective id for the request.
func (ObjectiveRequest) Response ¶
func (r ObjectiveRequest) Response(myAddress types.Address, chainId *big.Int) ObjectiveResponse
Response computes and returns the appropriate response from the request.
func (ObjectiveRequest) SignalObjectiveStarted ¶
func (r ObjectiveRequest) SignalObjectiveStarted()
SignalObjectiveStarted is used by the engine to signal the objective has been started.
func (ObjectiveRequest) WaitForObjectiveToStart ¶
func (r ObjectiveRequest) WaitForObjectiveToStart()
WaitForObjectiveToStart blocks until the objective starts
type ObjectiveResponse ¶
type ObjectiveResponse struct { Id protocols.ObjectiveId ChannelId types.Destination }
ObjectiveResponse is the type returned across the API in response to the ObjectiveRequest.