Documentation
¶
Index ¶
- Constants
- type AuthToken
- type ChanMsg
- type Client
- type MetricPool
- type Peer
- func (me *Peer) ConfirmSnapshotForPeer(idForNetwork, snap crypto.Hash)
- func (me *Peer) ConnectRelayer(idForNetwork crypto.Hash, addr string)
- func (me *Peer) GetNeighbors(key crypto.Hash) []*Peer
- func (me *Peer) GetRemoteRelayers(key crypto.Hash) []*Peer
- func (me *Peer) IsRelayer() bool
- func (me *Peer) ListenConsumers() error
- func (me *Peer) Metric() map[string]*MetricPool
- func (me *Peer) Neighbors() []*Peer
- func (me *Peer) SendCommitmentsMessage(idForNetwork crypto.Hash, commitments []*crypto.Key) error
- func (me *Peer) SendFullChallengeMessage(idForNetwork crypto.Hash, s *common.Snapshot, ...) error
- func (me *Peer) SendGraphMessage(idForNetwork crypto.Hash) error
- func (me *Peer) SendSnapshotAnnouncementMessage(idForNetwork crypto.Hash, s *common.Snapshot, R crypto.Key, spend crypto.Key) error
- func (me *Peer) SendSnapshotCommitmentMessage(idForNetwork crypto.Hash, s *common.Snapshot, R crypto.Key, ...) error
- func (me *Peer) SendSnapshotConfirmMessage(idForNetwork crypto.Hash, snap crypto.Hash) error
- func (me *Peer) SendSnapshotFinalizationMessage(idForNetwork crypto.Hash, s *common.Snapshot) error
- func (me *Peer) SendSnapshotResponseMessage(idForNetwork crypto.Hash, snap crypto.Hash, si *[32]byte) error
- func (me *Peer) SendTransactionChallengeMessage(idForNetwork crypto.Hash, s *common.Snapshot, cosi *crypto.CosiSignature, ...) error
- func (me *Peer) SendTransactionMessage(idForNetwork crypto.Hash, ver *common.VersionedTransaction) error
- func (me *Peer) SendTransactionRequestMessage(idForNetwork crypto.Hash, tx crypto.Hash) error
- func (me *Peer) SendTransactionsMessage(idForNetwork crypto.Hash, txs []*common.VersionedTransaction) error
- func (me *Peer) SetMetricEnabled(enabled bool)
- func (me *Peer) Teardown()
- type PeerMessage
- type QuicClient
- type QuicRelayer
- type SyncHandle
- type SyncPoint
- type Transport
- type TransportMessage
Constants ¶
View Source
const ( PeerMessageTypePing = 1 // not used because too more than enough graph sync messages PeerMessageTypeAuthentication = 3 PeerMessageTypeGraph = 4 PeerMessageTypeSnapshotConfirm = 5 PeerMessageTypeTransactionRequest = 6 PeerMessageTypeTransaction = 7 PeerMessageTypeTransactionBundle = 8 // TODO legacy messages, delete after all nodes upgraded PeerMessageTypeSnapshotAnnouncement = 10 PeerMessageTypeSnapshotCommitment = 11 PeerMessageTypeTransactionChallenge = 12 PeerMessageTypeSnapshotResponse = 13 PeerMessageTypeSnapshotFinalization = 14 PeerMessageTypeFullChallenge = 16 PeerMessageTypePreCommitments = 15 // pre commitments so the round can just start from full challenge PeerMessageTypeBatchSnapshotAnnouncement = 20 // leader send snapshot to peer PeerMessageTypeBatchSnapshotCommitment = 21 // peer generate ri based, send Ri to leader PeerMessageTypeBatchTransactionChallenge = 22 // leader send bitmask Z and aggregated R to peer PeerMessageTypeBatchSnapshotResponse = 23 // peer generate A from nodes and Z, send response si = ri + H(R || A || M)ai to leader PeerMessageTypeBatchFullChallenge = 24 // full challenge can be the first round if there are pre commitments PeerMessageTypeBatchSnapshotFinalization = 25 // leader generate A, verify si B = ri B + H(R || A || M)ai B = Ri + H(R || A || M)Ai, then finalize based on threshold PeerMessageTypeRelay = 200 PeerMessageTypeConsumers = 201 MsgPriorityNormal = 0 MsgPriorityHigh = 1 )
View Source
const ( // Each peer connection uses exactly one bidirectional stream. MaxIncomingStreams = 1 HandshakeTimeout = 10 * time.Second IdleTimeout = 60 * time.Second WriteDeadline = 10 * time.Second ReadDeadline = 2 * WriteDeadline )
View Source
const ( TransportMessageVersion = 2 TransportMessageMaxSize = 32 * 1024 * 1024 TransportMessageHeaderSize = 6 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricPool ¶
type MetricPool struct {
PeerMessageTypePing uint32 `json:"ping"`
PeerMessageTypeAuthentication uint32 `json:"authentication"`
PeerMessageTypeGraph uint32 `json:"graph"`
PeerMessageTypeSnapshotConfirm uint32 `json:"snapshot-confirm"`
PeerMessageTypeTransactionRequest uint32 `json:"transaction-request"`
PeerMessageTypeTransaction uint32 `json:"transaction"`
PeerMessageTypeSnapshotAnnouncement uint32 `json:"snapshot-announcement"`
PeerMessageTypeSnapshotCommitment uint32 `json:"snapshot-commitment"`
PeerMessageTypeTransactionChallenge uint32 `json:"transaciton-challenge"`
PeerMessageTypeSnapshotResponse uint32 `json:"snapshot-response"`
PeerMessageTypeSnapshotFinalization uint32 `json:"snapshot-finalization"`
PeerMessageTypePreCommitments uint32 `json:"commitments"`
PeerMessageTypeFullChallenge uint32 `json:"full-challenge"`
PeerMessageTypeTransactionBundle uint32 `json:"transaction-bundle"`
PeerMessageTypeBatchSnapshotAnnouncement uint32 `json:"batch-snapshot-announcement"`
PeerMessageTypeBatchSnapshotCommitment uint32 `json:"batch-snapshot-commitment"`
PeerMessageTypeBatchTransactionChallenge uint32 `json:"batch-transaction-challenge"`
PeerMessageTypeBatchFullChallenge uint32 `json:"batch-full-challenge"`
PeerMessageTypeBatchSnapshotFinalization uint32 `json:"batch-snapshot-finalization"`
PeerMessageTypeRelay uint32 `json:"relay"`
// contains filtered or unexported fields
}
func (*MetricPool) MarshalJSON ¶ added in v0.19.0
func (mp *MetricPool) MarshalJSON() ([]byte, error)
func (*MetricPool) String ¶
func (mp *MetricPool) String() string
type Peer ¶
type Peer struct {
IdForNetwork crypto.Hash
Address string
// contains filtered or unexported fields
}
func (*Peer) ConfirmSnapshotForPeer ¶
func (*Peer) GetRemoteRelayers ¶ added in v0.18.10
func (*Peer) ListenConsumers ¶
func (*Peer) Metric ¶
func (me *Peer) Metric() map[string]*MetricPool
func (*Peer) SendCommitmentsMessage ¶
func (*Peer) SendFullChallengeMessage ¶
func (*Peer) SendSnapshotAnnouncementMessage ¶
func (*Peer) SendSnapshotCommitmentMessage ¶
func (*Peer) SendSnapshotConfirmMessage ¶
func (*Peer) SendSnapshotFinalizationMessage ¶
TODO should we also send transactions together when do the sync
func (*Peer) SendSnapshotResponseMessage ¶
func (*Peer) SendTransactionChallengeMessage ¶
func (me *Peer) SendTransactionChallengeMessage(idForNetwork crypto.Hash, s *common.Snapshot, cosi *crypto.CosiSignature, txs []*common.VersionedTransaction) error
func (*Peer) SendTransactionMessage ¶
func (*Peer) SendTransactionRequestMessage ¶
func (*Peer) SendTransactionsMessage ¶ added in v0.19.0
func (*Peer) SetMetricEnabled ¶ added in v0.19.0
type PeerMessage ¶
type PeerMessage struct {
Type uint8
Snapshot *common.Snapshot
SnapshotHash crypto.Hash
Transactions []*common.VersionedTransaction
TransactionHash crypto.Hash
Cosi crypto.CosiSignature
Commitment crypto.Key
Challenge crypto.Key
Response [32]byte
WantTxs []crypto.Hash
Commitments []*crypto.Key
Graph []*SyncPoint
Data []byte
// contains filtered or unexported fields
}
type QuicClient ¶
type QuicClient struct {
// contains filtered or unexported fields
}
func NewQuicConsumer ¶
func NewQuicConsumer(ctx context.Context, relayer string) (*QuicClient, error)
func (*QuicClient) Close ¶
func (c *QuicClient) Close(code string)
func (*QuicClient) Receive ¶
func (c *QuicClient) Receive() (*TransportMessage, error)
func (*QuicClient) RemoteAddr ¶
func (c *QuicClient) RemoteAddr() net.Addr
func (*QuicClient) Send ¶
func (c *QuicClient) Send(data []byte) error
type QuicRelayer ¶
type QuicRelayer struct {
// contains filtered or unexported fields
}
func NewQuicRelayer ¶
func NewQuicRelayer(listenAddr string) (*QuicRelayer, error)
func (*QuicRelayer) Close ¶
func (t *QuicRelayer) Close() error
type SyncHandle ¶
type SyncHandle interface {
GetCacheStore() *ristretto.Cache[[]byte, any]
SignData(data []byte) crypto.Signature
BuildAuthenticationMessage(relayerId crypto.Hash) []byte
AuthenticateAs(recipientId crypto.Hash, msg []byte, timeoutSec int64) (*AuthToken, error)
BuildGraph() []*SyncPoint
UpdateSyncPoint(peerId crypto.Hash, points []*SyncPoint, data []byte, sig *crypto.Signature) error
ReadAllNodesWithoutState() []crypto.Hash
ReadSnapshotsSinceTopology(offset, count uint64) ([]*common.SnapshotWithTopologicalOrder, error)
ReadSnapshotsForNodeRound(nodeIdWithNetwork crypto.Hash, round uint64) ([]*common.SnapshotWithTopologicalOrder, error)
SendTransactionToPeer(peerId, tx crypto.Hash) error
CachePutTransaction(peerId crypto.Hash, ver *common.VersionedTransaction) error
CosiQueueExternalAnnouncement(peerId crypto.Hash, s *common.Snapshot, R *crypto.Key, sig *crypto.Signature) error
CosiAggregateSelfCommitments(peerId crypto.Hash, snap crypto.Hash, commitment *crypto.Key, wantTxs []crypto.Hash, data []byte, sig *crypto.Signature) error
CosiQueueExternalChallenge(peerId crypto.Hash, snap crypto.Hash, cosi *crypto.CosiSignature, txs []*common.VersionedTransaction) error
CosiQueueExternalFullChallenge(peerId crypto.Hash, s *common.Snapshot, commitment, challenge *crypto.Key, cosi *crypto.CosiSignature, txs []*common.VersionedTransaction) error
CosiAggregateSelfResponses(peerId crypto.Hash, snap crypto.Hash, response *[32]byte) error
VerifyAndQueueAppendSnapshotFinalization(peerId crypto.Hash, s *common.Snapshot) error
CosiQueueExternalPreCommitments(peerId crypto.Hash, commitments []*crypto.Key, data []byte, sig *crypto.Signature) error
}
type TransportMessage ¶
Click to show internal directories.
Click to hide internal directories.