Class: Zold::Emission

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

Overview

The emission control poine

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Emission

Returns a new instance of Emission.



38
39
40
# File 'lib/zold/node/emission.rb', line 38

def initialize(root)
  @root = root
end

Instance Method Details

#checkObject



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

def check
  return unless @root.root?
  allowed = limit * -1
  balance = @root.balance
  raise "The balance #{balance} of the root wallet is too low (max allowed: #{allowed})" if balance < allowed
end

#limitObject



47
48
49
50
# File 'lib/zold/node/emission.rb', line 47

def limit
  max = Amount::MAX
  Amount.new(coins: (max * quota).to_i)
end

#quotaObject



42
43
44
45
# File 'lib/zold/node/emission.rb', line 42

def quota
  years = @root.age / (24 * 1024)
  1 - (2**-years)
end