Skip to content

Commit

Permalink
fix: keep unique analyze job (#2310)
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid authored Dec 5, 2024
1 parent 6c9ce5c commit 33927e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/workers/analyze_contract_from_cell_dependency_worker.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
class AnalyzeContractFromCellDependencyWorker
include Sidekiq::Worker
sidekiq_options queue: "contract", retry: 0

def perform
cell_deps_out_points_attrs = Set.new
contract_attrs = Set.new
cell_deps_attrs = Set.new

CellDependency.where(contract_analyzed: false).where.not(block_number: nil).order("block_number desc").limit(1000).each do |cell_dep|
CellDependency.where(contract_analyzed: false).where.not(block_number: nil).limit(1000).each do |cell_dep|
cell_deps_attrs << { contract_analyzed: true, ckb_transaction_id: cell_dep.ckb_transaction_id, contract_cell_id: cell_dep.contract_cell_id, dep_type: cell_dep.dep_type }

next if CellDepsOutPoint.where(contract_cell_id: cell_dep.contract_cell_id).exists?
Expand Down
3 changes: 3 additions & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- bitcoin
- fiber
- low
- contract
:limits:
contract: 1

production:
:concurrency: 20
Expand Down
2 changes: 1 addition & 1 deletion lib/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def call_worker(clz)
call_worker GenerateUdtHolderAllocationWorker
end

s.every "5s", overlap: false do
s.every "10s", overlap: false do
call_worker AnalyzeContractFromCellDependencyWorker
end

Expand Down

0 comments on commit 33927e0

Please sign in to comment.