Skip to content

Commit

Permalink
Pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
masonforest committed Oct 17, 2018
1 parent 6158b8a commit 6f56649
Show file tree
Hide file tree
Showing 33 changed files with 556 additions and 666 deletions.
3 changes: 2 additions & 1 deletion lib/blacksmith/application.ex
Expand Up @@ -12,7 +12,8 @@ defmodule Blacksmith.Application do

children = [
supervisor(Blacksmith.Repo, []),
{Db.Redis, name: Db.Redis},
{Redis, name: Redis},
{TransactionProccessor, name: TransactionProccessor},
{Forger, name: Forger},
{VM, name: VM},
{TransactionPool, name: TransactionPool},
Expand Down
58 changes: 0 additions & 58 deletions lib/block.ex

This file was deleted.

94 changes: 0 additions & 94 deletions lib/blockchain.ex

This file was deleted.

166 changes: 0 additions & 166 deletions lib/db/redis.ex

This file was deleted.

14 changes: 11 additions & 3 deletions lib/forger.ex
@@ -1,4 +1,5 @@
defmodule Forger do
@one_second 1_000
use GenServer

def start_link(opts) do
Expand Down Expand Up @@ -39,11 +40,14 @@ defmodule Forger do
end

def handle_cast(:auto_forge, state = %{redis: redis, auto_forge: auto_forge}) do
{:ok, ["transactions::done", receipt]} =
Redix.command(redis, ["BRPOP", "transactions::done", 0])
case Redix.command(redis, ["BRPOP", "transactions::done", 1]) do
{:ok, ["transactions::done", receipt]} ->
GenServer.cast(self(), {:forge, [receipt]})
{:ok, nil} ->
end


if auto_forge do
GenServer.cast(self(), {:forge, [receipt]})
GenServer.cast(self(), :auto_forge)
end

Expand All @@ -55,6 +59,10 @@ defmodule Forger do
send(subscriber, receipts)
end)

state = Map.put(state, :subscribers, [])
{:noreply, state}
end
def handle_cast({:forge, receipts}, state) do
{:noreply, state}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/models/block.ex
Expand Up @@ -12,7 +12,7 @@ defmodule Models.Block do
timestamps
end

def max_burned(query \\ __MODULE__), do: from(q in query, order_by: q.max_burned) |> Repo.one()
def max_burned(query \\ __MODULE__), do: from(q in query, order_by: q.total_burned)

def latest(query \\ __MODULE__, count), do: from(q in query, order_by: q.number, limit: ^count)

Expand Down

0 comments on commit 6f56649

Please sign in to comment.