Class: Voucher::ElectionContract

Inherits:
Object
  • Object
show all
Defined in:
lib/voucher/election_contract.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ElectionContract

Returns a new instance of ElectionContract.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/voucher/election_contract.rb', line 7

def initialize(options = {})
  @ethereum = Ethereum::HttpClient.new(options[:ethereum_url])

  @contract = Ethereum::Contract.create(
    name: options[:name] || 'ElectionContractClient',
    address: options[:address],
    abi: options[:abi],
    client: ethereum
  )

  @roots = {}
  @formatter = Ethereum::Formatter.new
end

Instance Attribute Details

#contractObject (readonly)

Returns the value of attribute contract.



5
6
7
# File 'lib/voucher/election_contract.rb', line 5

def contract
  @contract
end

#ethereumObject (readonly)

Returns the value of attribute ethereum.



5
6
7
# File 'lib/voucher/election_contract.rb', line 5

def ethereum
  @ethereum
end

Instance Method Details

#winning_hash(shard) ⇒ Object



21
22
23
# File 'lib/voucher/election_contract.rb', line 21

def winning_hash(shard)
  @roots[shard] ||= find_root(shard)
end