@@ -3,51 +3,13 @@ defmodule AeMdw.Sync.AsyncTasks.WealthRankAccounts do
3
3
4
4
@ typep micro_block :: term ( )
5
5
6
- alias AeMdw.Collection
7
6
alias AeMdw.Db.Model
8
- alias AeMdw.Db.State
9
7
alias AeMdw.Db.Mutation
10
8
alias AeMdw.Db.IntCallsMutation
11
- alias AeMdw.Db.DeleteKeysMutation
12
- alias AeMdw.Db.WriteMutation
13
9
alias AeMdw.Sync.Transaction
14
10
15
11
require Model
16
12
17
- @ spec dedup_pending_accounts ( ) :: :ok
18
- def dedup_pending_accounts do
19
- state = State . new ( )
20
-
21
- { delete_keys , pubkeys_set } =
22
- state
23
- |> Collection . stream ( Model.AsyncTask , nil )
24
- |> Stream . filter ( fn { _ts , type } -> type == :store_acc_balance end )
25
- |> Stream . map ( & State . fetch! ( state , Model.AsyncTask , & 1 ) )
26
- |> Enum . map_reduce ( MapSet . new ( ) , fn
27
- Model . async_task ( index: index , extra_args: [ ] ) , acc ->
28
- { index , acc }
29
-
30
- Model . async_task ( index: index , extra_args: [ extra_args ] ) , acc ->
31
- { index , MapSet . union ( acc , extra_args ) }
32
- end )
33
-
34
- with args when args != [ ] <- last_mb ( state , nil ) do
35
- task_index = { System . system_time ( ) , :store_acc_balance }
36
- m_task = Model . async_task ( index: task_index , args: args , extra_args: [ pubkeys_set ] )
37
-
38
- State . commit_db (
39
- state ,
40
- [
41
- DeleteKeysMutation . new ( % { Model.AsyncTask => delete_keys } ) ,
42
- WriteMutation . new ( Model.AsyncTask , m_task )
43
- ] ,
44
- false
45
- )
46
- end
47
-
48
- :ok
49
- end
50
-
51
13
@ spec micro_block_accounts ( micro_block ( ) , [ Mutation . t ( ) ] ) :: MapSet . t ( )
52
14
def micro_block_accounts ( micro_block , mutations ) do
53
15
txs_pubkeys =
@@ -93,18 +55,4 @@ defmodule AeMdw.Sync.AsyncTasks.WealthRankAccounts do
93
55
_other -> [ ]
94
56
end )
95
57
end
96
-
97
- defp last_mb ( state , key ) do
98
- case State . prev ( state , Model.Block , key ) do
99
- { :ok , { _height , - 1 } = prev_key } ->
100
- last_mb ( state , prev_key )
101
-
102
- { :ok , block_index } ->
103
- Model . block ( hash: mb_hash ) = State . fetch! ( state , Model.Block , block_index )
104
- [ mb_hash , block_index ]
105
-
106
- :none ->
107
- [ ]
108
- end
109
- end
110
58
end
0 commit comments