Documentation ¶
Index ¶
- Constants
- func GetVirtualChannelFromObjectiveId(id protocols.ObjectiveId) (types.Destination, error)
- func IsVirtualDefundObjective(id protocols.ObjectiveId) bool
- type GetChannelByIdFunction
- type GetTwoPartyConsensusLedgerFunction
- 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) ReceiveProposal(sp consensus_channel.SignedProposal) (protocols.ProposalReceiver, error)
- 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(op protocols.ObjectivePayload) (protocols.Objective, error)
- func (o *Objective) VId() types.Destination
- type ObjectiveRequest
Constants ¶
const ( WaitingForFinalStateFromAlice protocols.WaitingFor = "WaitingForFinalStateFromAlice" WaitingForSupportedFinalState protocols.WaitingFor = "WaitingForSupportedFinalState" // Round 1 WaitingForDefundingOnMyLeft protocols.WaitingFor = "WaitingForDefundingOnMyLeft" // Round 2 WaitingForDefundingOnMyRight protocols.WaitingFor = "WaitingForDefundingOnMyRight" // Round 2 WaitingForNothing protocols.WaitingFor = "WaitingForNothing" // Finished )
const ( // SignedStatePayload indicates that the payload is a json serialized signed state SignedStatePayload protocols.PayloadType = "SignedStatePayload" // RequestFinalStatePayload indicates that the payload is a request for the final state // The actual payload is simply the channel id that the final state is for RequestFinalStatePayload protocols.PayloadType = "RequestFinalStatePayload" )
const FinalTurnNum = 2
The turn number used for the final state
const ObjectivePrefix = "VirtualDefund-"
Variables ¶
This section is empty.
Functions ¶
func GetVirtualChannelFromObjectiveId ¶
func GetVirtualChannelFromObjectiveId(id protocols.ObjectiveId) (types.Destination, error)
GetVirtualChannelFromObjectiveId gets the virtual channel id from the objective id.
func IsVirtualDefundObjective ¶
func IsVirtualDefundObjective(id protocols.ObjectiveId) bool
IsVirtualDefundObjective inspects a objective id and returns true if the objective id is for a virtualdefund 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 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 // MinimumPaymentAmount is the latest payment amount we have received from Alice before starting defunding. // This is set by Bob so he can ensure he receives the latest amount from any vouchers he's received. // If this is not set then virtual defunding will accept any final outcome from Alice. MinimumPaymentAmount *big.Int V *channel.VirtualChannel ToMyLeft *consensus_channel.ConsensusChannel ToMyRight *consensus_channel.ConsensusChannel // MyRole is the index of the participant in the participants list // 0 is Alice // 1...n is Irene, Ivan, ... (the n intermediaries) // n+1 is Bob MyRole uint }
Objective contains relevant information for the defund objective
func ConstructObjectiveFromPayload ¶
func ConstructObjectiveFromPayload( p protocols.ObjectivePayload, preapprove bool, myAddress types.Address, getChannel GetChannelByIdFunction, getTwoPartyConsensusLedger GetTwoPartyConsensusLedgerFunction, latestVoucherAmount *big.Int, ) (Objective, error)
ConstructObjectiveFromPayload takes in a message payload and constructs an objective from it.
func NewObjective ¶
func NewObjective(request ObjectiveRequest, preApprove bool, myAddress types.Address, largestPaymentAmount *big.Int, getChannel GetChannelByIdFunction, getConsensusChannel GetTwoPartyConsensusLedgerFunction, ) (Objective, error)
NewObjective constructs a new virtual defund objective
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) MarshalJSON ¶
MarshalJSON returns a JSON representation of the VirtualDefundObjective
NOTE: Marshal -> Unmarshal is a lossy process. All channel data (other than Id) from the fields ToMyLeft,ToMyRight are discarded
func (*Objective) OwnsChannel ¶
func (o *Objective) OwnsChannel() types.Destination
OwnsChannel returns the channel that the objective is funding.
func (*Objective) ReceiveProposal ¶
func (o *Objective) ReceiveProposal(sp consensus_channel.SignedProposal) (protocols.ProposalReceiver, error)
ReceiveProposal receives a signed proposal and returns an updated VirtualDefund objective.
func (*Objective) Reject ¶
func (o *Objective) Reject() (protocols.Objective, protocols.SideEffects)
Reject returns a rejected copy of the objective.
func (*Objective) Related ¶
Related returns channels that need to be stored along with the objective.
func (*Objective) UnmarshalJSON ¶
UnmarshalJSON populates the calling VirtualDefundObjective with the json-encoded data
NOTE: Marshal -> Unmarshal is a lossy process. All channel data (other than Id) from the fields ToMyLeft,ToMyRight are discarded
func (*Objective) Update ¶
Update receives an protocols.ObjectiveEvent, applies all applicable event data to the VirtualDefundObjective, and returns the updated state.
func (*Objective) VId ¶
func (o *Objective) VId() types.Destination
VId returns the channel id of the virtual channel.
type ObjectiveRequest ¶
type ObjectiveRequest struct { ChannelId types.Destination // contains filtered or unexported fields }
ObjectiveRequest represents a request to create a new virtual defund objective.
func NewObjectiveRequest ¶
func NewObjectiveRequest(channelId types.Destination) ObjectiveRequest
NewObjectiveRequest creates a new ObjectiveRequest.
func (ObjectiveRequest) Id ¶
func (r ObjectiveRequest) Id(types.Address, *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