class Beowulf::Type::Authority
Public Class Methods
new(options = {})
click to toggle source
# File lib/beowulf/type/authority.rb, line 8 def initialize(options = {}) # puts 'Authority.initialize.options', options.to_json @weight_threshold = options[:weight_threshold] || 1 @account_auths = options[:account_auths] || [] @key_auths = options[:key_auths] || [] end
Public Instance Methods
to_bytes()
click to toggle source
# File lib/beowulf/type/authority.rb, line 15 def to_bytes 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 = {})
click to toggle source
# File lib/beowulf/type/authority.rb, line 37 def to_json(options = {}) JSON.dump ({ :weight_threshold => @weight_threshold, :account_auths => @account_auths, :key_auths => @key_auths }) end