Manic.Multi (Manic v0.1.0) View Source

Module for encapsulating multiple miner Merchant API clients.

Link to this section Summary

Types

Multi miner API response

t()

Bitcoin multi miner API client

Functions

Sets the asynchronous operation on the given multi miner client.

Sets the asynchronous operation on the given multi miner client.

Returns a multi miner client for the given list of Merchant API endpoints.

Concurrently runs the asynchronous operation on the given multi miner client, yielding the response from any or all of the miners.

Link to this section Types

Specs

result() ::
  {Manic.miner(), {:ok, any()}} | [{Manic.miner(), {:ok | :error, any()}}, ...]

Multi miner API response

Specs

t() :: %Manic.Multi{
  miners: list(),
  operation: {atom(), atom(), list()} | function(),
  timeout: term(),
  yield: :any | :all
}

Bitcoin multi miner API client

Link to this section Functions

Specs

async(t(), function()) :: t()

Sets the asynchronous operation on the given multi miner client.

The operation is an inline function which receives the miner client.

Example

iex> Manic.Multi.async(multi, fn miner ->
...>   MyModule.some_function(miner)
...> end)

Or, the same more succinctly:

iex> Manic.Multi.async(multi, &MyModule.some_function/1)
Link to this function

async(multi, module, function_name, args)

View Source

Specs

async(t(), atom(), atom(), list()) :: t()

Sets the asynchronous operation on the given multi miner client.

The operation is passed as a tuple containing the module, function name and list or arguments. In this case, the miner client will automatically be prepended to the list of arguments.

Example

iex> Manic.Multi.async(multi, MyModule, :some_function, args)
Link to this function

new(miners, options \\ [])

View Source

Specs

new(list(), keyword()) :: t()

Returns a multi miner client for the given list of Merchant API endpoints.

Specs

yield(t()) :: result()

Concurrently runs the asynchronous operation on the given multi miner client, yielding the response from any or all of the miners.

By default, multi miner operations will yield until any of the miners respond. Alternatively, a multi client can be initialized with the option yield: :all which awaits for all miner clients to respond.