Skip to content

Commit c328b5c

Browse files
authored
Merge pull request #108 from willHol/master
Elixir 1.5 child specs - removed deprecated Supervisor.Spec module
2 parents cc7d42b + 8f3cec4 commit c328b5c

19 files changed

+44
-36
lines changed

apps/aecore/lib/aecore.ex

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ defmodule Aecore do
22
use Application
33

44
def start(_type, _args) do
5-
import Supervisor.Spec
6-
75
children = [
8-
supervisor(Aecore.Keys.Worker.Supervisor, []),
9-
supervisor(Aecore.Chain.Worker.Supervisor, []),
10-
supervisor(Aecore.Miner.Worker.Supervisor, []),
11-
supervisor(Aecore.Txs.Pool.Worker.Supervisor, []),
12-
supervisor(Aecore.Peers.Worker.Supervisor, [])
6+
Aecore.Keys.Worker.Supervisor,
7+
Aecore.Chain.Worker.Supervisor,
8+
Aecore.Miner.Worker.Supervisor,
9+
Aecore.Txs.Pool.Worker.Supervisor,
10+
Aecore.Peers.Worker.Supervisor
1311
]
1412

1513
Supervisor.start_link(children, strategy: :one_for_one)

apps/aecore/lib/aecore/chain/worker.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule Aecore.Chain.Worker do
1313

1414
use GenServer
1515

16-
def start_link do
16+
def start_link(_args) do
1717
GenServer.start_link(__MODULE__, {}, name: __MODULE__)
1818
end
1919

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
defmodule Aecore.Chain.Worker.Supervisor do
22
use Supervisor
33

4-
def start_link() do
4+
def start_link(_args) do
55
Supervisor.start_link(__MODULE__, :ok)
66
end
77

88
def init(:ok) do
99
children = [
10-
worker(Aecore.Chain.Worker, [])
10+
Aecore.Chain.Worker
1111
]
1212

13-
supervise(children, strategy: :one_for_one)
13+
Supervisor.init(children, strategy: :one_for_one)
1414
end
1515
end

apps/aecore/lib/aecore/keys/worker.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule Aecore.Keys.Worker do
1111
@filename_priv "key"
1212
@pub_key_length 65
1313

14-
def start_link() do
14+
def start_link(_args) do
1515
GenServer.start_link(
1616
__MODULE__,
1717
%{
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
defmodule Aecore.Keys.Worker.Supervisor do
22
use Supervisor
33

4-
def start_link() do
4+
def start_link(_args) do
55
Supervisor.start_link(__MODULE__, :ok)
66
end
77

88
def init(:ok) do
99
children = [
10-
worker(Aecore.Keys.Worker, [])
10+
Aecore.Keys.Worker
1111
]
1212

13-
supervise(children, strategy: :one_for_one)
13+
Supervisor.init(children, strategy: :one_for_one)
1414
end
1515
end

apps/aecore/lib/aecore/miner/worker.ex

+11-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,20 @@ defmodule Aecore.Miner.Worker do
1818
@coinbase_transaction_value 100
1919
@nonce_per_cycle 1
2020

21-
def start_link() do
21+
def start_link(_args) do
2222
GenStateMachine.start_link(__MODULE__, %{}, name: __MODULE__)
2323
end
2424

25+
def child_spec(arg) do
26+
%{
27+
id: __MODULE__,
28+
start: {__MODULE__, :start_link, [arg]},
29+
restart: :permanent,
30+
shutdown: 5000,
31+
type: :worker
32+
}
33+
end
34+
2535
def resume() do
2636
GenStateMachine.call(__MODULE__, :start)
2737
end
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
defmodule Aecore.Miner.Worker.Supervisor do
22
use Supervisor
33

4-
def start_link() do
4+
def start_link(_args) do
55
Supervisor.start_link(__MODULE__, :ok)
66
end
77

88
def init(:ok) do
99
children = [
10-
worker(Aecore.Miner.Worker, [])
10+
Aecore.Miner.Worker
1111
]
1212

13-
supervise(children, strategy: :one_for_one)
13+
Supervisor.init(children, strategy: :one_for_one)
1414
end
1515
end

apps/aecore/lib/aecore/peers/scheduler.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Aecore.Peers.Scheduler do
55

66
@check_time 60_000
77

8-
def start_link do
8+
def start_link(_args) do
99
GenServer.start_link(__MODULE__, %{})
1010
end
1111

apps/aecore/lib/aecore/peers/worker.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defmodule Aecore.Peers.Worker do
1414

1515
require Logger
1616

17-
def start_link do
17+
def start_link(_args) do
1818
GenServer.start_link(__MODULE__, %{}, name: __MODULE__)
1919
end
2020

Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
defmodule Aecore.Peers.Worker.Supervisor do
22
use Supervisor
33

4-
def start_link() do
4+
def start_link(_args) do
55
Supervisor.start_link(__MODULE__, :ok)
66
end
77

88
def init(:ok) do
99
children = [
10-
worker(Aecore.Peers.Worker, []),
11-
worker(Aecore.Peers.Scheduler, [])
10+
Aecore.Peers.Worker,
11+
Aecore.Peers.Scheduler
1212
]
1313

14-
supervise(children, strategy: :one_for_one)
14+
Supervisor.init(children, strategy: :one_for_one)
1515
end
1616
end

apps/aecore/lib/aecore/txs/pool/worker.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defmodule Aecore.Txs.Pool.Worker do
1212

1313
require Logger
1414

15-
def start_link do
15+
def start_link(_args) do
1616
GenServer.start_link(__MODULE__, %{}, name: __MODULE__)
1717
end
1818

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
defmodule Aecore.Txs.Pool.Worker.Supervisor do
22
use Supervisor
33

4-
def start_link() do
4+
def start_link(_args) do
55
Supervisor.start_link(__MODULE__, :ok)
66
end
77

88
def init(:ok) do
99
children = [
10-
worker(Aecore.Txs.Pool.Worker, [])
10+
Aecore.Txs.Pool.Worker
1111
]
1212

13-
supervise(children, strategy: :one_for_one)
13+
Supervisor.init(children, strategy: :one_for_one)
1414
end
1515
end

apps/aecore/test/aecore_chain_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule AecoreChainTest do
1313
alias Aecore.Miner.Worker, as: Miner
1414

1515
setup do
16-
Chain.start_link()
16+
Chain.start_link([])
1717
[]
1818
end
1919

apps/aecore/test/aecore_keys_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule AecoreKeysTest do
1010
alias Aecore.Chain.Worker, as: Chain
1111

1212
setup do
13-
Keys.start_link()
13+
Keys.start_link([])
1414
[]
1515
end
1616

apps/aecore/test/aecore_miner_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule MinerTest do
77

88
@tag timeout: 100000000
99
test "mine_next_block" do
10-
Miner.start_link()
10+
Miner.start_link([])
1111
Miner.resume()
1212
Miner.suspend()
1313
assert length(Chain.all_blocks) > 1

apps/aecore/test/aecore_peers_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule AecorePeersTest do
55
alias Aecore.Peers.Worker, as: Peers
66

77
setup do
8-
Peers.start_link()
8+
Peers.start_link([])
99
[]
1010
end
1111

apps/aecore/test/aecore_tx_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule AecoreTxTest do
99
alias Aecore.Chain.Worker, as: Chain
1010

1111
setup do
12-
Keys.start_link()
12+
Keys.start_link([])
1313
[]
1414
end
1515

apps/aecore/test/aecore_txs_pool_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule AecoreTxsPoolTest do
1010
alias Aecore.Keys.Worker, as: Keys
1111

1212
setup do
13-
Pool.start_link()
13+
Pool.start_link([])
1414
[]
1515
end
1616

apps/aecore/test/multiple_transactions_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule MultipleTransactionsTest do
1313
alias Aecore.Chain.Worker, as: Chain
1414

1515
setup do
16-
Pool.start_link()
16+
Pool.start_link([])
1717
[]
1818
end
1919

0 commit comments

Comments
 (0)