Skip to content

Commit cb86e21

Browse files
committed
use all cores for eventgen
1 parent 359e18d commit cb86e21

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

ex/lib/api/api_tx.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ defmodule API.TX do
157157

158158
tx = put_in(tx, [:tx, :action], action)
159159

160+
tx = if !tx[:receipt] do tx else
161+
logs = Enum.map(tx.receipt.logs, fn(line)-> RocksDB.ascii_dump(line) end)
162+
receipt = Map.merge(tx.receipt, %{result: RocksDB.ascii_dump(tx.receipt.result), logs: logs})
163+
Map.put(tx, :receipt, receipt)
164+
end
165+
160166
if !Map.has_key?(tx, :metadata) do tx else
161167
put_in(tx, [:metadata, :entry_hash], Base58.encode(tx.metadata.entry_hash))
162168
end

ex/lib/api/db_chain.ex

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ defmodule DB.Chain do
5555
entry = DB.Entry.by_hash(map.entry_hash, db_opts)
5656
tx_bytes = binary_part(entry_bytes, map.index_start, map.index_size)
5757

58-
receipt = if map[:result] do map.result else
59-
receipt = map.receipt
60-
result = RocksDB.ascii_dump(receipt.result)
61-
logs = Enum.map(receipt.logs, & RocksDB.ascii_dump(&1))
62-
Map.merge(receipt, %{result: result, logs: logs})
63-
end
58+
receipt = if map[:result] do map.result else map.receipt end
6459

6560
TX.unpack(tx_bytes)
6661
|> Map.put(:receipt, receipt)

ex/lib/consensus/coordination/fabric_event_gen.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ defmodule FabricEventGen do
5151
end
5252

5353
#IO.inspect API.Chain.format_entry_for_client(entry), limit: 11111
54-
entry_b58 = API.Chain.format_entry_for_client(entry)
55-
txs = Enum.map(entry.txs, fn(txu)->
56-
API.TX.format_tx_for_client(txu)
54+
txs_task = Task.async(fn ->
55+
entry.txs
56+
|> Task.async_stream(fn txu -> API.TX.format_tx_for_client(txu) end)
57+
|> Enum.map(fn {:ok, res} -> res end)
5758
end)
59+
entry_b58 = API.Chain.format_entry_for_client(entry)
60+
txs = Task.await(txs_task, :infinity)
61+
5862
broadcast({:update_stats_entry_tx, API.Chain.stats(), entry_b58, txs})
5963

6064
{:noreply, state}

0 commit comments

Comments
 (0)