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) {.async, ...gcsafe, raises: [], tags: [], forbids: [].}
Source   Edit  
proc reset(s: LPChannel) {.async, ...gcsafe, raises: [], tags: [], forbids: [].}
Source   Edit  
func shortLog(s: LPChannel): auto {....raises: [], tags: [], forbids: [].}
Source   Edit  

Methods

method close(s: LPChannel) {.async, ...gcsafe, raises: [], tags: [], 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 getWrapped(s: LPChannel): Connection {....raises: [], tags: [], forbids: [].}
Source   Edit  
method initStream(s: LPChannel) {....raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
method readOnce(s: LPChannel; pbytes: pointer; nbytes: int): Future[int] {.
    async, ...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]): Future[void] {....raises: [],
    tags: [RootEffect], forbids: [].}
Write to mplex channel - there may be up to MaxWrite concurrent writes pending after which the peer is disconnected Source   Edit  

Templates

template formatItIMPL(it: LPChannel): auto
Source   Edit  

Exports

newLPStreamWriteError, DNS_OR_IP, ProtoHeader, shortLog, init, random, UDP_DNS, $, getProtoHeader, MaError, ephemeral, MaPatternOp, WS_DNS, initVBuffer, getProtoHeader, MaxSizeError, ProtoFlags, getLen, ECDHEScheme, shortLog, init, init, closed, [], decode, macOpenArray, random, init, VBuffer, Secret, peekVarint, random, $, validate, mapOr, init, bytes, maxInlineKeyLength, TranscoderDNS, QUIC, [], key, ephemeral, withValue, getRequiredField, getField, init, writeLp, WS_IP, write, public, MAKind, write, DNSANY, getField, checkFieldNumber, valueOr, init, getRepeatedField, matchPartial, libp2p_pki_schemes, getBytes, len, ==, readVarint, readLp, HTTP, initVBuffer, mac, atEof, TcpOnion3, write, toOpt, fullAddrs, payloadType, <=, LPStreamError, init, IP, protoAddress, newRng, DefaultConnectionTimeout, ==, checkValid, getPublicKey, exceptionToAssert, decodeProposal, len, CircuitRelay, extractPublicKey, mapAnd, new, verify, UDP_IP, new, newLPStreamEOFError, init, ==, DNSADDR, AddressMapper, write, PeerId, WSS, LPStream, TCP_IP, hash, writePacked, init, readSeq, toBytes, TCP_DNS, shortLog, encode, len, capLen, init, protoName, toRawBytes, TranscoderIP6Zone, $, initProtoBuffer, newLPStreamReadError, init, WSS_DNS, match, writeLPVarint, CryptoResult, parseFullAddress, ProtoResult, WebRTCDirect, init, UDP, TranscoderOnion, StreamTracker, write, init, LPStreamResetError, isEmpty, writeArray, LPStreamReadError, decode, LPStreamIncompleteError, [], LPStreamEOFError, IP6, shortLog, initVBuffer, PKScheme, payload, init, init, Connection, write, init, TCP, PrivateKey, getBytes, newLPStreamIncorrectDefect, init, &=, PeerInfoError, newLPStreamClosedError, random, write, compilesOr, TranscoderIP4, init, initProtoBuffer, toException, DNS, UTP, goffset, readVarint, getRawBytes, >, KeyPair, init, init, high, toString, cmp, init, SupportedWireTypes, formatItIMPL, formatItIMPL, formatItIMPL, Signature, contains, hash, formatItIMPL, toBytes, DigestSheme, IPFS, getField, readOnce, init, isEmpty, ProtoScalar, shortLog, data, LPStreamIncorrectDefect, hex, protocols, finish, update, HTTPS, tryAndWarn, WebSockets, LPError, getPtr, write, TLS_WS, sign, finish, encode, MaResult, init, ProtoField, init, toBytes, writeSeq, init, &, DNS6, IpTransportProtocol, toOpenArray, allFuturesThrowing, IP4, TranscoderPort, isEnough, safeConvert, getField, init, createExchange, >=, init, payloadDomain, $, MaPattern, withValue, init, LPStreamLimitError, TranscoderOnion3, SignedPayload, closeImpl, toBytes, protoArgument, newLPStreamLimitError, write, keyOpenArray, match, createProposal, parseFullAddress, $, isEmpty, supported, getRequiredRepeatedField, init, newLPStreamIncompleteError, newLPStreamReadError, initProtoBuffer, MAProtocol, newLPStreamResetError, getPackedRepeatedField, initStream, getField, shortLog, DNS4, getWrapped, readArray, selectBest, write, P2PPattern, Envelope, hasPublicKey, toException, init, isEnough, init, Reliable, addrs, hex, ProtoBuffer, getBytes, WS, stretchKeys, encode, init, init, getField, getField, match, getField, <, iv, readLine, Eof, CryptoError, hash, append, vsizeof, init, WebSockets_DNS, WSS_IP, LPStreamConnDownError, peekArray, UNIX, PeerRecord, SupportedSchemes, getRepeatedField, LPStreamWriteError, Unreliable, SupportedSchemesInt, random, checkFutures, shuffle, validate, $, protoCode, mapEq, Onion3, write, LPStreamTrackerName, concat, TranscoderP2P, PeerInfo, AddressInfo, ConnectionTrackerName, TranscoderIP6, write, EnvelopeError, encode, newLPStreamRemoteClosedError, MaPatResult, Direction, InvalidVarintError, decode, shortLog, items, ==, init, peekSeq, getBytes, write, PublicKey, WebSockets_IP, writeLp, writePBVarint, ProtoFieldKind, readExactly, protoArgument, getRepeatedField, ProtoError, newLPStreamConnDownError, initStream, getField, MultiAddress, ivOpenArray, TimeoutHandler, orError, decodeExchange, getField, LPStreamRemoteClosedError, setupStreamTracker, MaInvalidAddress, LPStreamClosedError, RsaDefaultKeySize, write, getOrder, TranscoderUnix, SignedPeerRecord, join, writeVarint