   alias Neoscan.Addresses.Address
   alias Neoscan.Transactions
   alias Neoscan.Transactions.Transaction
+  alias Ecto.Multi
 
   @doc """
   Returns the list of addresses.

      %Ecto.Changeset{source: %Address{}}

  """
  def change_address(%Address{} = address) do
    Address.changeset(address, %{})
  end

  @doc """


  def update_multiple_addresses(list) do
    list
    |> Stream.map(fn {address, attrs} -> {address.address, change_address(address, attrs)} end)
    |> Enum.to_list
    |> create_multi
    |> Repo.transaction
  end

  def create_multi(changesets) do
    Multi.new
    |> insert_updates(changesets)
  end

  def insert_updates(multi, [{hash, changeset} | t]) do
    name = String.to_atom(hash)
    multi
    |> Multi.update(name, changeset, [])
    |> insert_updates(t)
  end
  def insert_updates(multi, []) do
    multi
  end

  @doc """
