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, log: Log::NULL, dir: wallets.path) ⇒ SyncWallets

Returns a new instance of SyncWallets.



36
37
38
39
40
# File 'lib/zold/sync_wallets.rb', line 36

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

Instance Method Details

#acq(id, exclusive: false) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/zold/sync_wallets.rb', line 58

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



50
51
52
# File 'lib/zold/sync_wallets.rb', line 50

def all
  @wallets.all
end

#countObject



54
55
56
# File 'lib/zold/sync_wallets.rb', line 54

def count
  @wallets.count
end

#pathObject



46
47
48
# File 'lib/zold/sync_wallets.rb', line 46

def path
  @wallets.path
end

#to_sObject



42
43
44
# File 'lib/zold/sync_wallets.rb', line 42

def to_s
  @wallets.to_s
end