Interface TransportConnection

All Superinterfaces:
AutoCloseable

public interface TransportConnection extends AutoCloseable
A bidirectional, frame-oriented connection between two peers. Frames are opaque byte arrays; the wire protocol (spec §9) layers CBOR envelopes on top.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Optional<PeerId>
    Returns the PeerID this connection's remote end proved it controls, when the transport authenticated the channel itself (spec §5.6): a TLS-backed transport that verified the peer's channel certificate reports the bound identity here, and the wire layer may then accept unsigned envelopes from exactly that peer on exactly this connection.
    void
    Closes the connection.
    void
    onReceive(Consumer<byte[]> receiver)
    Registers the receiver for inbound frames.
    Returns the remote address in the transport's own format.
    default X509Certificate[]
    Returns the certificate chain the remote end presented in this connection's handshake, leaf first (SPEC §5.6, v0.1.13), whether or not it attested: a node in the enterprise-CA mode judges it again when its trust refreshes, and roots a peer revocation in the CA when the chain's leaf is revoked.
    void
    send(byte[] frame)
    Sends one frame.
  • Method Details

    • remoteAddress

      String remoteAddress()
      Returns the remote address in the transport's own format.
    • attestedPeer

      default Optional<PeerId> attestedPeer()
      Returns the PeerID this connection's remote end proved it controls, when the transport authenticated the channel itself (spec §5.6): a TLS-backed transport that verified the peer's channel certificate reports the bound identity here, and the wire layer may then accept unsigned envelopes from exactly that peer on exactly this connection. Transports without channel authentication return empty, and every frame stays fully signed.
      Returns:
      the attested remote PeerID, or empty on unauthenticated channels
    • remoteChain

      default X509Certificate[] remoteChain()
      Returns the certificate chain the remote end presented in this connection's handshake, leaf first (SPEC §5.6, v0.1.13), whether or not it attested: a node in the enterprise-CA mode judges it again when its trust refreshes, and roots a peer revocation in the CA when the chain's leaf is revoked. Empty on transports without a handshake.
      Returns:
      the presented chain, possibly empty
    • send

      void send(byte[] frame) throws IOException
      Sends one frame.
      Parameters:
      frame - the frame bytes
      Throws:
      IOException - if the connection has failed
    • onReceive

      void onReceive(Consumer<byte[]> receiver)
      Registers the receiver for inbound frames. One receiver per connection; registering replaces the previous receiver.
      Parameters:
      receiver - invoked for each inbound frame
    • close

      void close()
      Closes the connection. Idempotent.
      Specified by:
      close in interface AutoCloseable