Documentation ¶
Overview ¶
Package directdefund implements an off-chain protocol to defund a directly-funded channel.
Index ¶
- Constants
- func CreateChannelFromConsensusChannel(cc consensus_channel.ConsensusChannel) (*channel.Channel, error)
- func IsDirectDefundObjective(id protocols.ObjectiveId) bool
- type GetChannelByIdFunction
- type GetConsensusChannel
- type Objective
- func (o *Objective) Approve() protocols.Objective
- func (o *Objective) Crank(secretKey *[]byte) (protocols.Objective, protocols.SideEffects, protocols.WaitingFor, error)
- func (o Objective) GetStatus() protocols.ObjectiveStatus
- func (o *Objective) Id() protocols.ObjectiveId
- func (o Objective) MarshalJSON() ([]byte, error)
- func (o 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
Constants ¶
const ( WaitingForFinalization protocols.WaitingFor = "WaitingForFinalization" WaitingForWithdraw protocols.WaitingFor = "WaitingForWithdraw" WaitingForNothing protocols.WaitingFor = "WaitingForNothing" // Finished )
const ( ErrChannelUpdateInProgress = types.ConstError("can only defund a channel when the latest state is supported or when the channel has a final state") ErrNoFinalState = types.ConstError("cannot spawn direct defund objective without a final state") ErrNotEmpty = types.ConstError("ledger channel has running guarantees") )
const ObjectivePrefix = "DirectDefunding-"
const (
SignedStatePayload protocols.PayloadType = "SignedStatePayload"
)
Variables ¶
This section is empty.
Functions ¶
func CreateChannelFromConsensusChannel ¶
func CreateChannelFromConsensusChannel(cc consensus_channel.ConsensusChannel) (*channel.Channel, error)
CreateChannelFromConsensusChannel creates a Channel with (an appropriate latest supported state) from the supplied ConsensusChannel.
func IsDirectDefundObjective ¶
func IsDirectDefundObjective(id protocols.ObjectiveId) bool
IsDirectDefundObjective inspects a objective id and returns true if the objective id is for a direct defund objective.
Types ¶
type GetChannelByIdFunction ¶
type GetChannelByIdFunction func(id types.Destination) (channel *channel.Channel, ok bool)
GetChannelByIdFunction specifies a function that can be used to retrieve channels from a store.
type GetConsensusChannel ¶
type GetConsensusChannel func(channelId types.Destination) (ledger *consensus_channel.ConsensusChannel, err error)
GetConsensusChannel describes functions which return a ConsensusChannel ledger channel for a channel id.
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 ConstructObjectiveFromPayload ¶
func ConstructObjectiveFromPayload( p protocols.ObjectivePayload, preapprove bool, getConsensusChannel GetConsensusChannel, ) (Objective, error)
ConstructObjectiveFromPayload takes in a state and constructs an objective from it.
func NewObjective ¶
func NewObjective( request ObjectiveRequest, preApprove bool, getConsensusChannel GetConsensusChannel, ) (Objective, error)
NewObjective initiates an Objective with the supplied channel
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
func (Objective) GetStatus ¶
func (o Objective) GetStatus() protocols.ObjectiveStatus
GetStatus returns the status of the objective.
func (*Objective) Id ¶
func (o *Objective) Id() protocols.ObjectiveId
Id returns the unique id of the objective
func (Objective) MarshalJSON ¶
MarshalJSON returns a JSON representation of the DirectDefundObjective NOTE: Marshal -> Unmarshal is a lossy process. All channel data (other than Id) from the field C is discarded
func (Objective) OwnsChannel ¶
func (o 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 DirectDefundObjective 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 { ChannelId types.Destination // contains filtered or unexported fields }
ObjectiveRequest represents a request to create a new direct defund objective.
func NewObjectiveRequest ¶
func NewObjectiveRequest(channelId types.Destination) 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) 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