directdefund

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Overview

Package directdefund implements an off-chain protocol to defund a directly-funded channel.

Index

Constants

View Source
const (
	WaitingForFinalization protocols.WaitingFor = "WaitingForFinalization"
	WaitingForWithdraw     protocols.WaitingFor = "WaitingForWithdraw"
	WaitingForNothing      protocols.WaitingFor = "WaitingForNothing" // Finished
)
View Source
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")
)
View Source
const ObjectivePrefix = "DirectDefunding-"
View Source
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) Approve

func (o *Objective) Approve() protocols.Objective

func (*Objective) Crank

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

Id returns the unique id of the objective

func (Objective) MarshalJSON

func (o Objective) MarshalJSON() ([]byte, error)

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 (*Objective) Related

func (o *Objective) Related() []protocols.Storable

func (*Objective) UnmarshalJSON

func (o *Objective) UnmarshalJSON(data []byte) error

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

func (*Objective) Update

Update receives an ObjectiveEvent, applies all applicable event data to the DirectDefundingObjective, and returns the updated objective

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

Jump to

Keyboard shortcuts

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