Record Class Envelope

java.lang.Object
java.lang.Record
ai.badmonkey.agentspaces.peering.wire.Envelope
Record Components:
ver - protocol version; WireCodec.WIRE_VERSION (2) is the only version receivers accept (spec §9)
group - the group the frame belongs to; receivers ignore frames for groups they are not members of
kind - the frame kind
from - the sending peer
to - the intended recipient, or null when unaddressed
stamp - the sender's HLC stamp; receivers merge it into their clocks
body - kind-specific CBOR payload

public record Envelope(int ver, GroupId group, Envelope.Kind kind, PeerId from, PeerId to, HlcTimestamp stamp, byte[] body) extends Record
The wire envelope (spec §9): every frame between peers is a CBOR-encoded, signed envelope. The body is an opaque CBOR payload whose shape depends on the Envelope.Kind.

The to field binds an addressed frame to its intended recipient (a signed component, ASF-010): a receiver drops a frame whose to is set and is not this peer, so a captured frame cannot be redirected to, or replayed at, a peer it was never sent to. to is null on a genuinely unaddressed frame — the bootstrap self-introduction to a seed whose PeerID is not yet known — and such frames get no destination protection (they carry only a signed, idempotent self-advertisement).

  • Constructor Details

    • Envelope

      public Envelope(int ver, GroupId group, Envelope.Kind kind, PeerId from, PeerId to, HlcTimestamp stamp, byte[] body)
      Creates an instance of a Envelope record class.
      Parameters:
      ver - the value for the ver record component
      group - the value for the group record component
      kind - the value for the kind record component
      from - the value for the from record component
      to - the value for the to record component
      stamp - the value for the stamp record component
      body - the value for the body record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • ver

      public int ver()
      Returns the value of the ver record component.
      Returns:
      the value of the ver record component
    • group

      public GroupId group()
      Returns the value of the group record component.
      Returns:
      the value of the group record component
    • kind

      public Envelope.Kind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • from

      public PeerId from()
      Returns the value of the from record component.
      Returns:
      the value of the from record component
    • to

      public PeerId to()
      Returns the value of the to record component.
      Returns:
      the value of the to record component
    • stamp

      public HlcTimestamp stamp()
      Returns the value of the stamp record component.
      Returns:
      the value of the stamp record component
    • body

      public byte[] body()
      Returns the value of the body record component.
      Returns:
      the value of the body record component