Skip to content

Commit

Permalink
refactor: allocate smaller tuples for query streams (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
jyeshe committed Sep 19, 2022
1 parent 91b5014 commit bd7229b
Show file tree
Hide file tree
Showing 13 changed files with 1,153 additions and 150 deletions.
4 changes: 2 additions & 2 deletions lib/ae_mdw/aex141.ex
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ defmodule AeMdw.Aex141 do
Model.NftOwnership ->
{
{pubkey, <<>>, nil},
{pubkey, Util.max_256bit_bin(), Util.max_256bit_int()}
{pubkey, Util.max_256bit_bin(), Util.max_int()}
}

Model.NftTokenOwner ->
{{pubkey, -Util.max_256bit_int()}, {pubkey, nil}}
{{pubkey, Util.min_256bit_int()}, {pubkey, nil}}
end

fn direction ->
Expand Down
4 changes: 0 additions & 4 deletions lib/ae_mdw/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ defmodule AeMdw.Application do
|> Enum.map(fn {k, v} -> {Contract.function_hash(k), v} end)
|> Enum.into(%{})

max_int = Util.max_256bit_int()
max_blob = :binary.list_to_bin(:lists.duplicate(1024, <<max_int::256>>))

height_proto = :aec_hard_forks.protocols() |> Enum.into([]) |> Enum.sort(&>=/2)

min_block_reward_height =
Expand Down Expand Up @@ -202,7 +199,6 @@ defmodule AeMdw.Application do
aexn_mint_event_hash: [{[], :aec_hash.blake2b_256_hash("Mint")}],
aexn_transfer_event_hash: [{[], :aec_hash.blake2b_256_hash("Transfer")}],
aex141_signatures: [{[], aex141_sigs}],
max_blob: [{[], max_blob}],
height_proto: [{[], height_proto}],
min_block_reward_height: [{[], min_block_reward_height}],
token_supply_delta:
Expand Down
4 changes: 2 additions & 2 deletions lib/ae_mdw/blocks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ defmodule AeMdw.Blocks do
|> Collection.stream(
Model.Block,
direction,
{{height, 0}, {height, Util.max_256bit_int()}},
{{height, 0}, {height, Util.max_int()}},
cursor
)
|> Stream.map(fn {_height, mbi} -> mbi end)
Expand Down Expand Up @@ -231,7 +231,7 @@ defmodule AeMdw.Blocks do
Enum.map(range, fn gen ->
[key_block | micro_blocks] =
state
|> Collection.stream(@table, :backward, nil, {gen, Util.max_256bit_int()})
|> Collection.stream(@table, :backward, nil, {gen, Util.max_int()})
|> Stream.take_while(&match?({^gen, _mb_index}, &1))
|> Enum.map(fn key -> State.fetch!(state, @table, key) end)
|> Enum.reverse()
Expand Down
Loading

0 comments on commit bd7229b

Please sign in to comment.