lib/zold/node/async_entrance.rb
def push(id, body)
      if @queue.size > @queue_limit
        raise(
          SoftError,
          "Queue is too long (#{@queue.size} wallets), can't add #{id}/#{Size.new(body.length)}, try again later"
        )
      end
      start = Time.now
      unless exists?(id, body)
        loop do
          uuid = SecureRandom.uuid
          file = File.join(@dir, "#{id}-#{uuid}#{Wallet::EXT}")
          next if File.exist?(file)
          IO.write(file, body)
          @queue << { id: id, file: file }
          @log.debug("Added #{id}/#{Size.new(body.length)} to the queue at pos.#{@queue.size} \
  in #{Age.new(start, limit: 0.05)}")
          break
        end
      end
      [id]
    end
def push(id, body)
      if @queue.size > @queue_limit
        raise(
          SoftError,
          "Queue is too long (#{@queue.size} wallets), can't add #{id}/#{Size.new(body.length)}, try again later"
        )
      end
      start = Time.now
      unless exists?(id, body)
        loop do
          uuid = SecureRandom.uuid
          file = File.join(@dir, "#{id}-#{uuid}#{Wallet::EXT}")
          next if File.exist?(file)
          IO.write(file, body)
          @queue << { id: id, file: file }
          @log.debug("Added #{id}/#{Size.new(body.length)} to the queue at pos.#{@queue.size} \
  in #{Age.new(start, limit: 0.05)}")
          break
        end
      end
      [id]
    end
def push ( id , body ) if @queue . size > @queue_limit raise ( SoftError , "Queue is too long (#{@queue.size} wallets), can't add #{id}/#{Size.new(body.length)}, try again later" ) end start = Time . now unless exists? ( id , body ) loop do uuid = SecureRandom . uuid file = File . join ( @dir , "#{id}-#{uuid}#{Wallet::EXT}" ) next if File . exist? ( file ) IO . write ( file , body ) @queue << { id : id , file : file } @log . debug ( "Added #{id}/#{Size.new(body.length)} to the queue at pos.#{@queue.size} \
  in #{Age.new(start, limit: 0.05)}" ) break end end [ id ] end
Always returns an array with a single ID of the pushed wallet
Always returns an array with a single ID of the pushed wallet