From 497b35262e7b232be7b33f38867e87284a91dfca Mon Sep 17 00:00:00 2001 From: davvd Date: Thu, 30 Nov 2023 05:31:53 +0300 Subject: [PATCH] #819 skip them --- Gemfile | 2 +- lib/zold/commands/create.rb | 6 +++++- lib/zold/hungry_wallets.rb | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index cabdb5b3..a597afa1 100755 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -# frozen_string_literal: true + # frozen_string_literal: true # Copyright (c) 2018-2023 Zerocracy # diff --git a/lib/zold/commands/create.rb b/lib/zold/commands/create.rb index 9f47b75f..51abfbd7 100644 --- a/lib/zold/commands/create.rb +++ b/lib/zold/commands/create.rb @@ -70,7 +70,11 @@ def create_id(opts) loop do id = Id.new return id if opts['skip-test'] - found = false + found = @wallets.exists?(id) + if found + @log.debug("Wallet ID #{id} already exists locally, will try another one...") + next + end @remotes.iterate(@log) do |r| head = r.http("/wallet/#{id}/digest").get found = true if head.status == 200 diff --git a/lib/zold/hungry_wallets.rb b/lib/zold/hungry_wallets.rb index a01a3890..b0de5573 100644 --- a/lib/zold/hungry_wallets.rb +++ b/lib/zold/hungry_wallets.rb @@ -64,7 +64,7 @@ def acq(id, exclusive: false) else @mutex.synchronize do unless @queue.include?(id) - @missed.put(id.to_s, lifetime: 5 * 60) + @missed.put(id.to_s, true, lifetime: 5 * 60) @queue << id @log.debug("Hungry queue got #{id}, at the pos no.#{@queue.size - 1}") end