Parrhesia.Negentropy.Message (parrhesia v0.12.0)

Copy Markdown

NIP-77 negentropy message codec and helpers.

Summary

Types

bound()

@type bound() :: :infinity | {non_neg_integer(), binary()}

item()

@type item() :: %{created_at: non_neg_integer(), id: binary()}

range()

@type range() :: %{
  upper_bound: bound(),
  mode: :skip | :fingerprint | :id_list,
  payload: nil | binary() | [binary()]
}

Functions

compare_bound(arg1, arg2)

@spec compare_bound(bound(), bound()) :: :lt | :eq | :gt

compare_items(left, right)

@spec compare_items(item(), item()) :: :lt | :eq | :gt

decode(arg1)

@spec decode(binary()) ::
  {:ok, [range()]} | {:unsupported_version, byte()} | {:error, term()}

encode(ranges)

@spec encode([range()]) :: binary()

fingerprint(items)

@spec fingerprint([item()]) :: binary()

initial_lower_bound()

@spec initial_lower_bound() :: bound()

item_in_range?(item, lower_bound, upper_bound)

@spec item_in_range?(item(), bound(), bound()) :: boolean()

protocol_version()

@spec protocol_version() :: byte()

split_bound(previous_item, next_item)

@spec split_bound(item(), item()) :: bound()

supported_version_message()

@spec supported_version_message() :: binary()

zero_id()

@spec zero_id() :: binary()