Class: Casper::Entity::AuctionState
- Inherits:
-
Object
- Object
- Casper::Entity::AuctionState
- Defined in:
- lib/entity/auction_state.rb
Overview
Data structure summarizing auction contract data.
Instance Method Summary collapse
-
#get_bids ⇒ Array<Bid>
Array of Bid.
-
#get_block_height ⇒ Integer
Block height as an Integer.
-
#get_era_validators ⇒ Array<EraValidator>
Array of EraValidator.
-
#get_state_root_hash ⇒ String
State root hash as a String.
-
#initialize(state_root_hash, block_height, era_validators, bids) ⇒ AuctionState
constructor
A new instance of AuctionState.
Constructor Details
#initialize(state_root_hash, block_height, era_validators, bids) ⇒ AuctionState
Returns a new instance of AuctionState.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/entity/auction_state.rb', line 11 def initialize(state_root_hash, block_height, era_validators, bids) @state_root_hash = state_root_hash @block_height = block_height @era_validators = [] era_validators.each do |era_validator| @validators_weights = [] era_validator[:validator_weights].each do |validator_weight| @validators_weights << Casper::Entity::ValidatorWeight.new(validator_weight[:public_key], validator_weight[:weight]) end @era_validators << Casper::Entity::EraValidator.new(era_validator[:era_id], @validators_weights) @validators_weights = [] # puts Casper::Entity::EraValidator.new(era_validator[:era_id], @validators_weights).get_era_id # puts Casper::Entity::EraValidator.new(era_validator[:era_id], @validators_weights).get_validator_weights end # @era_validators.each do |era_validator| # puts era_validator.get_validator_weights[0].get_era_id # puts era_validator.get_validator_weights[0].get_weight # end @bids = bids @bids_list = [] bids.each do |bid| bid_info = bid[:bid] @delegators_list = [] delegators = bid_info[:delegators] delegators.each do |delegator| @delegators_list << Casper::Entity::Delegator.new( delegator[:public_key], delegator[:staked_amount], delegator[:bonding_purse], delegator[:delegatee] ) # puts delegator # puts delegator[:public_key] end bid_info = Casper::Entity::BidInfo.new( bid_info[:bonding_purse], bid_info[:staked_amount], bid_info[:delegation_rate], bid_info[:vesting_schedule], # bid_info[:delegators], @delegators_list, bid_info[:inactive] ) @bids_list << Casper::Entity::Bid.new(bid[:public_key], bid_info) end end |
Instance Method Details
#get_bids ⇒ Array<Bid>
Returns array of Bid.
80 81 82 |
# File 'lib/entity/auction_state.rb', line 80 def get_bids @bids_list end |
#get_block_height ⇒ Integer
Returns block height as an Integer.
70 71 72 |
# File 'lib/entity/auction_state.rb', line 70 def get_block_height @block_height end |
#get_era_validators ⇒ Array<EraValidator>
Returns array of EraValidator.
75 76 77 |
# File 'lib/entity/auction_state.rb', line 75 def get_era_validators @era_validators end |
#get_state_root_hash ⇒ String
Returns state root hash as a String.
65 66 67 |
# File 'lib/entity/auction_state.rb', line 65 def get_state_root_hash @state_root_hash end |