Documentation ¶
Overview ¶
Package channel defines types and methods for state channels.
Index ¶
- Constants
- type ChainUpdateData
- type Channel
- func (c *Channel) AddSignedState(ss state.SignedState) bool
- func (c *Channel) AddStateWithSignature(s state.State, sig state.Signature) bool
- func (c Channel) Affords(allocationMap map[common.Address]outcome.Allocation, fundingMap types.Funds) bool
- func (c *Channel) Clone() *Channel
- func (c Channel) FinalCompleted() bool
- func (c Channel) FinalSignedByMe() bool
- func (c Channel) HasSupportedState() bool
- func (c Channel) LatestSignedState() (state.SignedState, error)
- func (c Channel) LatestSupportedState() (state.State, error)
- func (c Channel) MarshalJSON() ([]byte, error)
- func (c Channel) MyDestination() types.Destination
- func (c Channel) PostFundComplete() bool
- func (c Channel) PostFundSignedByMe() bool
- func (c Channel) PostFundState() state.State
- func (c Channel) PreFundComplete() bool
- func (c Channel) PreFundSignedByMe() bool
- func (c Channel) PreFundState() state.State
- func (c *Channel) SignAndAddPostfund(sk *[]byte) (state.SignedState, error)
- func (c *Channel) SignAndAddPrefund(sk *[]byte) (state.SignedState, error)
- func (c *Channel) SignAndAddState(s state.State, sk *[]byte) (state.SignedState, error)
- func (c Channel) SignedPostFundState() state.SignedState
- func (c Channel) SignedPreFundState() state.SignedState
- func (c Channel) Total() types.Funds
- func (c *Channel) UnmarshalJSON(data []byte) error
- func (c *Channel) UpdateWithChainEvent(event chainservice.Event) (*Channel, error)
- type OffChainData
- type OnChainData
- type VirtualChannel
Constants ¶
const ( PreFundTurnNum uint64 = iota PostFundTurnNum MaxTurnNum = ^uint64(0) // MaxTurnNum is a reserved value which is taken to mean "there is not yet a supported state" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainUpdateData ¶ added in v0.1.1
type Channel ¶
type Channel struct { state.FixedPart Id types.Destination MyIndex uint OnChain OnChainData OffChain OffChainData LastChainUpdate ChainUpdateData }
Channel contains states and metadata and exposes convenience methods.
func (*Channel) AddSignedState ¶
func (c *Channel) AddSignedState(ss state.SignedState) bool
AddSignedState adds a signed state to the Channel, updating the LatestSupportedState and Support if appropriate. Returns false and does not alter the channel if the state is "stale", belongs to a different channel, or is signed by a non participant.
func (*Channel) AddStateWithSignature ¶
AddStateWithSignature constructs a SignedState from the passed state and signature, and calls s.AddSignedState with it.
func (Channel) Affords ¶
func (c Channel) Affords( allocationMap map[common.Address]outcome.Allocation, fundingMap types.Funds, ) bool
Affords returns true if, for each asset keying the input variables, the channel can afford the allocation given the funding. The decision is made based on the latest supported state of the channel.
Both arguments are maps keyed by the same asset
func (*Channel) Clone ¶
Clone returns a pointer to a new, deep copy of the receiver, or a nil pointer if the receiver is nil.
func (Channel) FinalCompleted ¶
FinalCompleted returns true if I have a complete set of signatures on a final state, false otherwise.
func (Channel) FinalSignedByMe ¶
FinalSignedByMe returns true if the calling client has signed a final state, false otherwise.
func (Channel) HasSupportedState ¶
HasSupportedState returns true if the channel has a supported state, false otherwise.
func (Channel) LatestSignedState ¶
func (c Channel) LatestSignedState() (state.SignedState, error)
LatestSignedState fetches the state with the largest turn number signed by at least one participant.
func (Channel) LatestSupportedState ¶
LatestSupportedState returns the latest supported state. A state is supported if it is signed by all participants.
func (Channel) MarshalJSON ¶
MarshalJSON returns a JSON representation of the Channel
func (Channel) MyDestination ¶
func (c Channel) MyDestination() types.Destination
MyDestination returns the client's destination
func (Channel) PostFundComplete ¶
PostFundComplete() returns true if I have a complete set of signatures on the pre fund setup state, false otherwise.
func (Channel) PostFundSignedByMe ¶
PostFundSignedByMe returns true if the calling client has signed the post fund setup state, false otherwise.
func (Channel) PostFundState ¶
PostFundState() returns the post fund setup state for the channel.
func (Channel) PreFundComplete ¶
PreFundComplete() returns true if I have a complete set of signatures on the pre fund setup state, false otherwise.
func (Channel) PreFundSignedByMe ¶
PreFundSignedByMe returns true if the calling client has signed the pre fund setup state, false otherwise.
func (Channel) PreFundState ¶
PreFundState() returns the pre fund setup state for the channel.
func (*Channel) SignAndAddPostfund ¶
func (c *Channel) SignAndAddPostfund(sk *[]byte) (state.SignedState, error)
SignAndAddPrefund signs and adds the postfund state for the channel, returning a state.SignedState suitable for sending to peers.
func (*Channel) SignAndAddPrefund ¶
func (c *Channel) SignAndAddPrefund(sk *[]byte) (state.SignedState, error)
SignAndAddPrefund signs and adds the prefund state for the channel, returning a state.SignedState suitable for sending to peers.
func (*Channel) SignAndAddState ¶
SignAndAddState signs and adds the state to the channel, returning a state.SignedState suitable for sending to peers.
func (Channel) SignedPostFundState ¶
func (c Channel) SignedPostFundState() state.SignedState
SignedPostFundState() returns the SIGNED post fund setup state for the channel.
func (Channel) SignedPreFundState ¶
func (c Channel) SignedPreFundState() state.SignedState
SignedPreFundState returns the signed pre fund setup state for the channel.
func (Channel) Total ¶
Total() returns the total allocated of each asset allocated by the pre fund setup state of the Channel.
func (*Channel) UnmarshalJSON ¶
UnmarshalJSON populates the calling Channel with the json-encoded data
func (*Channel) UpdateWithChainEvent ¶
func (c *Channel) UpdateWithChainEvent(event chainservice.Event) (*Channel, error)
UpdateWithChainEvent mutates the receiver with the supplied chain event, replacing the relevant data fields.
type OffChainData ¶
type OffChainData struct { SignedStateForTurnNum map[uint64]state.SignedState // Longer term, we should have a more efficient and smart mechanism to store states https://github.com/statechannels/go-nitro/issues/106 LatestSupportedStateTurnNum uint64 // largest uint64 value reserved for "no supported state" }
type OnChainData ¶
type VirtualChannel ¶
type VirtualChannel struct {
Channel
}
func NewVirtualChannel ¶
func NewVirtualChannel(s state.State, myIndex uint) (*VirtualChannel, error)
NewVirtualChannel returns a new VirtualChannel based on the supplied state.
Virtual channel protocol currently presumes exactly two "active" participants, Alice and Bob (p[0] and p[last]). They should be the only destinations allocated to in the supplied state's Outcome.
func (*VirtualChannel) Clone ¶
func (v *VirtualChannel) Clone() *VirtualChannel
Clone returns a pointer to a new, deep copy of the receiver, or a nil pointer if the receiver is nil.
func (*VirtualChannel) GetPaidAndRemaining ¶
func (v *VirtualChannel) GetPaidAndRemaining() (*big.Int, *big.Int)
Directories ¶
Path | Synopsis |
---|---|
Package consensus_channel manages a running ledger channel.
|
Package consensus_channel manages a running ledger channel. |
Package state defines the data structures which are signed by channel participants.
|
Package state defines the data structures which are signed by channel participants. |
outcome
Package outcome defines the data structures for expressing how channel funds are to be distributed on-chain.
|
Package outcome defines the data structures for expressing how channel funds are to be distributed on-chain. |