Documentation ¶
Overview ¶
Package protocols defines the off-chain protocols for managing channels. It is the functional core of a go-nitro node.
Index ¶
- Variables
- type AdjudicationStatus
- type ChainTransaction
- type ChainTransactionBase
- type ChallengeTransaction
- type DepositTransaction
- type Message
- func CreateObjectivePayloadMessage(id ObjectiveId, p interface{}, payloadType PayloadType, ...) ([]Message, error)
- func CreateRejectionNoticeMessage(oId ObjectiveId, recipients ...types.Address) []Message
- func CreateSignedProposalMessage(recipient types.Address, proposals ...consensus_channel.SignedProposal) Message
- func CreateVoucherMessage(voucher payments.Voucher, recipients ...types.Address) []Message
- func DeserializeMessage(s string) (Message, error)
- type MessageSummary
- type Objective
- type ObjectiveId
- type ObjectivePayload
- type ObjectivePayloadSummary
- type ObjectiveRequest
- type ObjectiveStatus
- type PayloadType
- type PaymentSummary
- type ProposalReceiver
- type ProposalSummary
- type SideEffects
- type Storable
- type Summary
- type WaitingFor
- type WithdrawAllTransaction
Constants ¶
This section is empty.
Variables ¶
var ErrNotApproved = errors.New("objective not approved")
Functions ¶
This section is empty.
Types ¶
type AdjudicationStatus ¶
type AdjudicationStatus struct {
TurnNumRecord uint
}
AdjudicationStatus mirrors the on chain adjudication status of a particular channel. Everything that is stored on chain, other than holdings.
type ChainTransaction ¶
type ChainTransaction interface {
ChannelId() types.Destination
}
ChainTransaction defines the interface that every transaction must implement
type ChainTransactionBase ¶
type ChainTransactionBase struct {
// contains filtered or unexported fields
}
ChainTransactionBase is a convenience struct that is embedded in other transaction structs. It is exported only to allow cmp.Diff to compare transactions
func (ChainTransactionBase) ChannelId ¶
func (cct ChainTransactionBase) ChannelId() types.Destination
type ChallengeTransaction ¶
type ChallengeTransaction struct { ChainTransaction Candidate state.SignedState Proof []state.SignedState ChallengerSig crypto.Signature }
func NewChallengeTransaction ¶
func NewChallengeTransaction( channelId types.Destination, candidate state.SignedState, proof []state.SignedState, challengerSig crypto.Signature, ) ChallengeTransaction
type DepositTransaction ¶
type DepositTransaction struct { ChainTransaction Deposit types.Funds }
func NewDepositTransaction ¶
func NewDepositTransaction(channelId types.Destination, deposit types.Funds) DepositTransaction
type Message ¶
type Message struct { To types.Address From types.Address // ObjectivePayloads contains a collection of payloads for various objectives. // Protocols are responsible for parsing the payload. ObjectivePayloads []ObjectivePayload // LedgerProposals contains a collection of signed proposals. // Since proposals need to be handled in order they need to be an explicit part of the message format. LedgerProposals []consensus_channel.SignedProposal // Payments contains a collection of signed vouchers representing payments. // Payments are handled outside of any objective. Payments []payments.Voucher // RejectedObjectives is a collection of objectives that have been rejected. RejectedObjectives []ObjectiveId }
Message is an object to be sent across the wire.
func CreateObjectivePayloadMessage ¶
func CreateObjectivePayloadMessage(id ObjectiveId, p interface{}, payloadType PayloadType, recipients ...types.Address) ([]Message, error)
CreateObjectivePayloadMessage returns a message for each recipient tht contains an objective payload.
func CreateRejectionNoticeMessage ¶
func CreateRejectionNoticeMessage(oId ObjectiveId, recipients ...types.Address) []Message
CreateSignedProposalMessage returns a signed proposal message addressed to the counterparty in the given ledger It contains the provided signed proposals and any proposals in the proposal queue.
func CreateSignedProposalMessage ¶
func CreateSignedProposalMessage(recipient types.Address, proposals ...consensus_channel.SignedProposal) Message
CreateSignedProposalMessage returns a signed proposal message addressed to the counterparty in the given ledger channel. The proposals MUST be sorted by turnNum since the ledger protocol relies on the message receipient processing the proposals in that order. See ADR 4.
func CreateVoucherMessage ¶
CreateVoucherMessage returns a signed voucher message for each of the recipients provided.
func DeserializeMessage ¶
DeserializeMessage deserializes the passed string into a protocols.Message.
func (Message) Summarize ¶
func (m Message) Summarize() MessageSummary
Summarize returns a MessageSummary for the message that is suitable for logging
type MessageSummary ¶
type MessageSummary struct { To string From string PayloadSummaries []ObjectivePayloadSummary ProposalSummaries []ProposalSummary Payments []PaymentSummary // RejectedObjectives is a collection of objectives that have been rejected. RejectedObjectives []string }
MessageSummary is a summary of a message suitable for logging.
type Objective ¶
type Objective interface { Id() ObjectiveId Approve() Objective // returns an updated Objective (a copy, no mutation allowed), does not declare effects Reject() (Objective, SideEffects) // returns an updated Objective (a copy, no mutation allowed), does not declare effects Update(payload ObjectivePayload) (Objective, error) // returns an updated Objective (a copy, no mutation allowed), does not declare effects Crank(secretKey *[]byte) (Objective, SideEffects, WaitingFor, error) // does *not* accept an event, but *does* accept a pointer to a signing key; declare side effects; return an updated Objective // Related returns a slice of related objects that need to be stored along with the objective Related() []Storable Storable // OwnsChannel returns the channel the objective exclusively owns. OwnsChannel() types.Destination // GetStatus returns the status of the objective. GetStatus() ObjectiveStatus }
Objective is the interface for off-chain protocols. The lifecycle of an objective is as follows:
- It is initialized by a single client (passing in various parameters). It is implicitly approved by that client. It is communicated to the other clients.
- It is stored and then approved or rejected by the other clients
- It is updated with external information arriving to the client
- After each update, it is cranked. This generates side effects and other metadata
- The metadata will eventually indicate that the Objective has stalled OR the Objective has completed successfully
type ObjectiveId ¶
type ObjectiveId string
ObjectiveId is a unique identifier for an Objective.
func GetProposalObjectiveId ¶
func GetProposalObjectiveId(p consensus_channel.Proposal) (ObjectiveId, error)
GetProposalObjectiveId returns the objectiveId for a proposal.
type ObjectivePayload ¶
type ObjectivePayload struct { // PayloadData is the serialized json payload PayloadData []byte // ObjectiveId is the id of the objective that is responsible for decoding and handling the payload ObjectiveId ObjectiveId // Type is the type of the payload the message contains. // This is useful when a protocol wants to handle different types of payloads. Type PayloadType }
ObjectivePayload is a message containing a payload of []byte that an objective is responsible for decoding.
func CreateObjectivePayload ¶
func CreateObjectivePayload(id ObjectiveId, payloadType PayloadType, p interface{}) (ObjectivePayload, error)
CreateObjectivePayload generates an objective message from the given objective id and payload. CreateObjectivePayload handles serializing `p` into json.
type ObjectivePayloadSummary ¶
ObjectivePayloadSummary is a summary of an objective payload suitable for logging.
type ObjectiveRequest ¶
type ObjectiveRequest interface { Id(types.Address, *big.Int) ObjectiveId WaitForObjectiveToStart() SignalObjectiveStarted() }
ObjectiveRequest is a request to create a new objective.
type ObjectiveStatus ¶
type ObjectiveStatus int8
const ( Unapproved ObjectiveStatus = iota Approved Rejected Completed )
type PayloadType ¶
type PayloadType string
type PaymentSummary ¶
PaymentSummary is a summary of a payment voucher suitable for logging.
type ProposalReceiver ¶
type ProposalReceiver interface { Objective // ReceiveProposal receives a signed proposal and returns an updated VirtualObjective. // It is used to update the objective with a proposal received from a peer. ReceiveProposal(signedProposal consensus_channel.SignedProposal) (ProposalReceiver, error) }
ProposalReceiver is an Objective that receives proposals.
type ProposalSummary ¶
type ProposalSummary struct { ObjectiveId string LedgerId string ProposalType string TurnNum uint64 }
ProposalSummary is a summary of a proposal suitable for logging.
type SideEffects ¶
type SideEffects struct { MessagesToSend []Message TransactionsToSubmit []ChainTransaction ProposalsToProcess []consensus_channel.Proposal }
SideEffects are effects to be executed by an imperative shell
func (*SideEffects) Merge ¶
func (se *SideEffects) Merge(other SideEffects)
Merge accepts a SideEffects struct that is merged into the the existing SideEffects.
type Storable ¶
type Storable interface { json.Marshaler json.Unmarshaler }
Storable is an object that can be stored by the store.
type Summary ¶
type Summary interface { ObjectivePayloadSummary | ProposalSummary | PaymentSummary | string }
type WaitingFor ¶
type WaitingFor string
WaitingFor is an enumerable "pause-point" computed from an Objective. It describes how the objective is blocked on actions by third parties (i.e. co-participants or the blockchain).
type WithdrawAllTransaction ¶
type WithdrawAllTransaction struct { ChainTransaction SignedState state.SignedState }
func NewWithdrawAllTransaction ¶
func NewWithdrawAllTransaction(channelId types.Destination, signedState state.SignedState) WithdrawAllTransaction
Directories ¶
Path | Synopsis |
---|---|
Package directdefund implements an off-chain protocol to defund a directly-funded channel.
|
Package directdefund implements an off-chain protocol to defund a directly-funded channel. |
Package directfund implements an off-chain protocol to directly fund a channel.
|
Package directfund implements an off-chain protocol to directly fund a channel. |
Package virtualfund implements an off-chain protocol to virtually fund a channel.
|
Package virtualfund implements an off-chain protocol to virtually fund a channel. |