Class: Zold::Emission
- Inherits:
-
Object
- Object
- Zold::Emission
- Defined in:
- lib/zold/node/emission.rb
Overview
The emission control poine
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(root) ⇒ Emission
constructor
A new instance of Emission.
- #limit ⇒ Object
- #quota ⇒ Object
Constructor Details
Instance Method Details
#check ⇒ Object
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 |
#limit ⇒ Object
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 |
#quota ⇒ Object
42 43 44 45 |
# File 'lib/zold/node/emission.rb', line 42 def quota years = @root.age / (24 * 1024) 1 - (2**-years) end |