Class: Zold::SyncWallets

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/sync_wallets.rb

Overview

Synchronized collection of wallets

Instance Method Summary collapse

Constructor Details

#initialize(wallets, timeout: 30, log: Log::NULL, dir: wallets.path) ⇒ SyncWallets

Returns a new instance of SyncWallets.



33
34
35
36
37
38
# File 'lib/zold/sync_wallets.rb', line 33

def initialize(wallets, timeout: 30, log: Log::NULL, dir: wallets.path)
  @wallets = wallets
  @log = log
  @timeout = timeout
  @dir = dir
end

Instance Method Details

#acq(id, exclusive: false) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/zold/sync_wallets.rb', line 52

def acq(id, exclusive: false)
  @wallets.acq(id, exclusive: exclusive) do |wallet|
    Futex.new(wallet.path, log: @log, lock: File.join(@dir, "#{id}.lock")).open(exclusive) do
      yield wallet
    end
  end
end

#allObject



48
49
50
# File 'lib/zold/sync_wallets.rb', line 48

def all
  @wallets.all
end

#pathObject



44
45
46
# File 'lib/zold/sync_wallets.rb', line 44

def path
  @wallets.path
end

#to_sObject



40
41
42
# File 'lib/zold/sync_wallets.rb', line 40

def to_s
  @wallets.to_s
end