Class: Zold::Push
- Inherits:
-
Object
- Object
- Zold::Push
- Defined in:
- lib/zold/commands/push.rb
Overview
Wallet pushing command
Instance Method Summary collapse
-
#initialize(wallet:, log: Log::Quiet.new) ⇒ Push
constructor
A new instance of Push.
- #run ⇒ Object
Constructor Details
Instance Method Details
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/zold/commands/push.rb', line 36 def run raise 'The wallet is absent' unless @wallet.exists? request = Net::HTTP::Put.new("/wallets/#{@wallet.id}") request.body = File.read(@wallet.path) response = Net::HTTP.new('b1.zold.io', 80).start do |http| http.request(request) end unless response.code.to_i == 200 raise "Failed to push to the node, code=#{response.code}" end @log.info("The #{@wallet.id} pushed to the server") end |