View Source Yggdrasil.Subscriber.Adapter.Icon (ICON 2.0 SDK v0.1.3)

Yggdrasil publisher adapter for Icon. The name of the channel should be a map with:

  • :source - Either :block or :event (required).
  • :identity - Icon.RPC.Identity instance pointed to the right network.
  • :data - Data for the subscription.
  • :from_height - Height to start receiving messages. Defaults to :latest.

Important: We need to be careful when using from_height in the channel because Yggdrasil will restart the synchronization process from the chosen height if the process crashes.

e.g. given a proper channel name, then we can subscribe to ICON 2.0 :block websocket:

iex(1)> Yggdrasil.subscribe(name: %{source: :block}, adapter: :icon)
:ok
iex(4)> flush()
{:Y_CONNECTED, %Yggdrasil.Channel{name: %{source: :block}, (...)}}

after that, we'll start receiving messages like the following:

iex(6)> flush()
{:Y_EVENT, %Yggdrasil.Channel{name: %{source: :block}, (...)}, %Yggdrasil.Icon.Block{hash: "0x...", (...)}}

Finally, when we're done, we can unsubscribe from the channel:

iex(7)> Yggdrasil.unsubscribe(name: %{source: :block}, adapter: :icon)
:ok
iex(8)> flush()
{:Y_DISCONNECTED, %Yggdrasil.Channel{name: %{source: :block}, (...)}}

Link to this section Summary

Functions

Starts Elixir.Yggdrasil.Subscriber.Adapter.Icon with a channel and optional options.

Link to this section Functions

Link to this function

start_link(channel, options \\ [])

View Source

Specs

Starts Elixir.Yggdrasil.Subscriber.Adapter.Icon with a channel and optional options.