Class: Ledger
- Inherits:
-
Object
- Object
- Ledger
- Defined in:
- lib/centralbank/ledger.rb
Instance Attribute Summary collapse
-
#wallets ⇒ Object
readonly
use addresses - why? why not? for now single address wallet (wallet==address).
Instance Method Summary collapse
-
#initialize(chain = []) ⇒ Ledger
constructor
A new instance of Ledger.
- #sufficient_funds?(wallet, amount) ⇒ Boolean
Constructor Details
#initialize(chain = []) ⇒ Ledger
Returns a new instance of Ledger.
5 6 7 8 9 10 |
# File 'lib/centralbank/ledger.rb', line 5 def initialize( chain=[] ) @wallets = {} chain.each do |block| apply_transactions( block.transactions ) end end |
Instance Attribute Details
#wallets ⇒ Object (readonly)
use addresses - why? why not? for now single address wallet (wallet==address)
3 4 5 |
# File 'lib/centralbank/ledger.rb', line 3 def wallets @wallets end |
Instance Method Details
#sufficient_funds?(wallet, amount) ⇒ Boolean
12 13 14 15 |
# File 'lib/centralbank/ledger.rb', line 12 def sufficient_funds?( wallet, amount ) return true if Centralbank.config.coinbase?( wallet ) @wallets.has_key?( wallet ) && @wallets[wallet] - amount >= 0 end |