Class: Beowulf::Type::AuthorityUpdate
- Inherits:
-
Object
- Object
- Beowulf::Type::AuthorityUpdate
- Includes:
- Utils
- Defined in:
- lib/beowulf/type/authority_update.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ AuthorityUpdate
constructor
A new instance of AuthorityUpdate.
- #to_bytes ⇒ Object
- #to_json(options = {}) ⇒ Object
Methods included from Utils
#debug, #error, #extract_signatures, #hexlify, #pakArr, #pakC, #pakHash, #pakI, #pakL!, #pakPubKey, #pakQ, #pakS, #pakStr, #pakc, #pakq, #paks, #send_log, #unhexlify, #varint, #warning
Constructor Details
#initialize(options = {}) ⇒ AuthorityUpdate
Returns a new instance of AuthorityUpdate.
8 9 10 11 12 13 |
# File 'lib/beowulf/type/authority_update.rb', line 8 def initialize( = {}) # puts 'AuthorityUpdate.initialize.options', options.to_json @weight_threshold = [:weight_threshold] || 1 @account_auths = [:account_auths] || [] @key_auths = [:key_auths] || [] end |
Instance Method Details
#to_bytes ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/beowulf/type/authority_update.rb', line 15 def to_bytes bytes = unhexlify("01") wt = @weight_threshold.to_i + 0 bytes << [wt].pack("I") #uint8_t bytes << pakC(@account_auths.length) if @account_auths.length > 0 @account_auths.each do |account| bytes << pakStr(account[0]) bytes << pakS(account[1]) end end #uint8_t bytes << pakC(@key_auths.length) if @key_auths.length > 0 @key_auths.each do |key| bytes << pakPubKey(key[0]) bytes << pakS(key[1]) end end bytes end |
#to_json(options = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/beowulf/type/authority_update.rb', line 38 def to_json( = {}) JSON.dump ({ :weight_threshold => @weight_threshold, :account_auths => @account_auths, :key_auths => @key_auths }) end |