Class: Centralbank::Configuration

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

Constant Summary collapse

WALLET_ADDRESSES =
%w[Alice Bob Max Franz Maria Ferdl Lisi Adam Eva]
COINBASE =

note: add a (†) coinbase marker

['Everest†', 'Aconcagua†', 'Denali†',
 'Kilimanjaro†', 'Elbrus†', 'Vinson†',
 'Puncak Jaya†', 'Kosciuszko†',
 'Mont Blanc†'
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



60
61
62
63
64
65
66
67
68
# File 'lib/centralbank.rb', line 60

def initialize
  ## try default setup via ENV variables
  ## pick "random" address if nil (none passed in)
  @address = ENV[ 'CENTRALBANK_NAME'] || rand_address()

  @coinbase = COINBASE         ## use a different name - why? why not?
                               ##  note: for now is an array (multiple coinbases)
  @mining_reward = 5
end

Instance Attribute Details

#addressObject

user/node settings



44
45
46
# File 'lib/centralbank.rb', line 44

def address
  @address
end

#coinbaseObject

system/blockchain settings



49
50
51
# File 'lib/centralbank.rb', line 49

def coinbase
  @coinbase
end

#mining_rewardObject

Returns the value of attribute mining_reward.



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

def mining_reward
  @mining_reward
end

Instance Method Details

#coinbase?(address) ⇒ Boolean

check/todo: use wallet - why? why not? (for now wallet==address)

Returns:

  • (Boolean)


73
74
75
# File 'lib/centralbank.rb', line 73

def coinbase?( address )    ## check/todo: use wallet - why? why not? (for now wallet==address)
  @coinbase.include?( address )
end

#rand_addressObject



70
# File 'lib/centralbank.rb', line 70

def rand_address()      WALLET_ADDRESSES[rand( WALLET_ADDRESSES.size )];  end

#rand_coinbaseObject



71
# File 'lib/centralbank.rb', line 71

def rand_coinbase()     @coinbase[rand( @coinbase.size )];  end