libp2p/muxers/mplex/lpchannel

Search:
Group by:
Source   Edit  

Channel half-closed states

| State    | Closed local      | Closed remote
|=============================================
| Read     | Yes (until EOF)   | No
| Write    | No                | Yes

Channels are considered fully closed when both outgoing and incoming
directions are closed and when the reader of the channel has read the
EOF marker

Types

LPChannel = ref object of BufferStream
  id*: uint64
  name*: string
  conn*: Connection
  initiator*: bool
  isOpen*: bool
  closedLocal*: bool
  remoteReset*: bool
  localReset*: bool
  msgCode*: MessageType
  closeCode*: MessageType
  resetCode*: MessageType
  writes*: int
Source   Edit  

Consts

LPChannelTrackerName = "LPChannel"
Source   Edit  

Procs

proc init(L: type LPChannel; id: uint64; conn: Connection; initiator: bool;
          name: string = ""; timeout: Duration = DefaultChanTimeout): LPChannel {.
    ...raises: [].}
Source   Edit  
proc open(s: LPChannel): InternalRaisesFuture[void,
    (CancelledError, LPStreamError)] {....stackTrace: false, raises: [], gcsafe,
                                       raises: [], tags: [RootEffect],
                                       forbids: [].}
Source   Edit  
proc reset(s: LPChannel): InternalRaisesFuture[void, void] {....stackTrace: false,
    raises: [], gcsafe, raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
func shortLog(s: LPChannel): auto {....raises: [], tags: [], forbids: [].}
Source   Edit  

Methods

method close(s: LPChannel): InternalRaisesFuture[void, void] {.
    ...stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect],
    forbids: [].}
Close channel for writing - a message will be sent to the other peer informing them that the channel is closed and that we're waiting for their acknowledgement. Source   Edit  
method closed(s: LPChannel): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
method closeWrite(s: LPChannel): InternalRaisesFuture[void, void] {.
    ...stackTrace: false, raises: [], gcsafe, raises: [], tags: [RootEffect],
    forbids: [].}
For mplex, closeWrite is the same as close - it implements half-close Source   Edit  
method getWrapped(s: LPChannel): Connection {....raises: [], tags: [], forbids: [].}
Source   Edit  
method initStream(s: LPChannel) {....raises: [], tags: [TimeEffect, RootEffect],
                                  forbids: [].}
Source   Edit  
method readOnce(s: LPChannel; pbytes: pointer; nbytes: int): InternalRaisesFuture[
    int, (CancelledError, LPStreamError)] {....stackTrace: false, raises: [],
    gcsafe, raises: [], tags: [RootEffect], forbids: [].}
Mplex relies on reading being done regularly from every channel, or all channels are blocked - in particular, this means that reading from one channel must not be done from within a callback / read handler of another or the reads will lock each other. Source   Edit  
method write(s: LPChannel; msg: seq[byte]): InternalRaisesFuture[void,
    (CancelledError, LPStreamError)] {....stackTrace: false, raises: [], gcsafe,
                                       raises: [], tags: [RootEffect],
                                       forbids: [].}
Source   Edit  

Templates

template formatItIMPL(it: LPChannel): auto {..}
Source   Edit  

Exports

DNS_OR_IP, shortLog, init, random, UDP_DNS, MaError, libp2p_network_bytes, ephemeral, decode, MaPattern, MaPatternOp, ==, WS_DNS, initVBuffer, <=, filterIt, ECDHEScheme, shortLog, init, closed, [], MaxSizeError, shuffle, random, init, Secret, peekVarint, random, $, validate, mac, init, Memory, maxInlineKeyLength, TranscoderDNS, QUIC, [], QUIC_V1_DNS, ephemeral, withValue, WS_IP, public, MAKind, write, write, getField, valueOr, init, getRepeatedField, matchPartial, libp2p_pki_schemes, getBytes, len, areAddrsConsistent, init, readLp, HTTP, initVBuffer, atEof, LPStreamTrackerName, peekSeq, toOpt, join, fullAddrs, payloadType, LPStreamError, $, IP, protoAddress, QUIC_V1_IP, decode, newRng, ==, withValue, checkValid, getPublicKey, libp2p_multiaddress_exts, len, getPart, CircuitRelay, extractPublicKey, mapAnd, new, maErr, UDP_IP, new, newLPStreamEOFError, init, ==, DNSADDR, AddressMapper, write, WSS, LPStream, waitForService, QUIC_V1, TCP_IP, init, closeImpl, readSeq, toBytes, TCP_DNS, closeWrite, shortLog, encode, WebSockets, capLen, init, protoName, protoArgument, toRawBytes, $, WSS_DNS, match, writeLPVarint, CryptoResult, parseFullAddress, init, WebRTCDirect, init, UDP, PeerInfo, TranscoderOnion, StreamTracker, write, init, LPStreamResetError, writeArray, getRawBytes, LPStreamIncompleteError, PeerId, [], LPStreamEOFError, IP6, shortLog, decode, initVBuffer, PKScheme, random, init, init, Connection, write, init, TCP, PrivateKey, getBytes, write, init, &=, PeerInfoError, newLPStreamClosedError, payload, compilesOr, TranscoderMemory, close, TranscoderIP4, init, toException, DNS, init, collectCompleted, goffset, >, KeyPair, init, high, toString, init, cmp, DefaultConnectionTimeout, formatItIMPL, formatItIMPL, formatItIMPL, Signature, contains, exclIfIt, hash, formatItIMPL, toBytes, DigestSheme, IPFS, getField, shortLog, readOnce, init, isEmpty, data, shortLog, hex, protocols, bytes, hash, HTTPS, UNIX, LPError, TLS_WS, sign, init, encode, formatItIMPL, supported, MaResult, init, toBytes, writeSeq, init, &, DNS6, expandAddrs, IpTransportProtocol, init, IP4, TranscoderPort, writeLp, getBytes, safeConvert, init, >=, init, payloadDomain, $, withValue, init, includeFile, LPStreamLimitError, TranscoderOnion3, SignedPayload, toBytes, newLPStreamLimitError, write, keyOpenArray, match, WebSockets_DNS, $, isEmpty, init, newLPStreamIncompleteError, MAProtocol, newLPStreamResetError, initStream, getField, shortLog, DNS4, MultiAddress, getWrapped, selectBest, P2PPattern, Envelope, hasPublicKey, toException, isEnough, DNSANY, finish, Reliable, addrs, hex, closeImpl, write, WS, init, encode, init, stretchKeys, getField, match, readArray, <, iv, readLine, Eof, CryptoError, append, hash, init, parseFullAddress, WSS_IP, LPStreamConnDownError, peekArray, PeerRecord, init, SupportedSchemes, getField, RsaDefaultKeySize, Unreliable, SupportedSchemesInt, random, checkFutures, macOpenArray, validate, $, mapEq, Onion3, TcpOnion3, toFullAddress, concat, TranscoderP2P, AddressInfo, ConnectionTrackerName, TranscoderIP6, write, EnvelopeError, encode, len, newLPStreamRemoteClosedError, TranscoderIP6Zone, MaPatResult, Direction, key, InvalidVarintError, shortLog, ==, init, write, getBytes, write, init, UTP, readVarint, verify, TimeoutHandler, QUIC_IP, PublicKey, WebSockets_IP, VBuffer, writeLp, writePBVarint, toChunks, readExactly, protoArgument, mapOr, newLPStreamConnDownError, init, initStream, readVarint, ivOpenArray, closeWithEOF, orError, getField, LPStreamRemoteClosedError, protoCode, MaInvalidAddress, LPStreamClosedError, items, write, getOrder, QUIC_DNS, update, TranscoderUnix, SignedPeerRecord, writeVarint