From 3bf316ac4c6d6837cdac6de690e773c9ae074d40 Mon Sep 17 00:00:00 2001 From: James Piechota Date: Tue, 21 May 2024 21:43:12 -0400 Subject: [PATCH] WIP --- apps/arweave/src/ar_coordination.erl | 20 +++++++++++++++---- apps/arweave/src/ar_http_iface_middleware.erl | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/arweave/src/ar_coordination.erl b/apps/arweave/src/ar_coordination.erl index 8d554a16a..868c10eb8 100644 --- a/apps/arweave/src/ar_coordination.erl +++ b/apps/arweave/src/ar_coordination.erl @@ -6,7 +6,7 @@ start_link/0, computed_h1/2, compute_h2_for_peer/2, computed_h2_for_peer/1, get_public_state/0, send_h1_batch_to_peer/0, stat_loop/0, get_peers/1, get_peer/1, update_peer/2, remove_peer/1, garbage_collect/0, is_exit_peer/0, - get_unique_partitions_list/0, get_self_plus_external_partitions_list/0, + get_partition_table/0, get_self_plus_external_partitions_list/0, get_cluster_partitions_list/0 ]). @@ -461,9 +461,21 @@ refetch_peer_partitions(Peers) -> refetch_pool_peer_partitions() -> gen_server:cast(?MODULE, refetch_pool_peer_partitions). -get_unique_partitions_list() -> - Set = get_unique_partitions_set(ar_mining_io:get_partitions(), sets:new()), - lists:sort(sets:to_list(Set)). +get_partition_table() -> + lists:foldl( + fun({BucketSize, Bucket, {spora_2_6, MiningAddress}}, Acc) -> + [ + {[ + {bucket, Bucket}, + {bucketsize, BucketSize}, + {addr, ar_util:encode(MiningAddress)} + ]} + | Acc + ] + end, + sets:new(), + ar_mining_io:get_storage_modules() + ) get_unique_partitions_set() -> get_unique_partitions_set(ar_mining_io:get_partitions(), sets:new()). diff --git a/apps/arweave/src/ar_http_iface_middleware.erl b/apps/arweave/src/ar_http_iface_middleware.erl index b9bbf3d31..ae6811af1 100644 --- a/apps/arweave/src/ar_http_iface_middleware.erl +++ b/apps/arweave/src/ar_http_iface_middleware.erl @@ -1357,7 +1357,7 @@ handle(<<"GET">>, [<<"coordinated_mining">>, <<"partition_table">>], Req, _Pid) %% CM miners ask each other about their local %% partitions. A CM exit node is not an exception - it %% does NOT aggregate peer partitions in this case. - ar_coordination:get_unique_partitions_list() + ar_coordination:get_partition_table() end, JSON = ar_serialize:jsonify(Partitions), {200, #{}, JSON, Req}