From 946b50dea5e5c9553e7eaf6ab2d958e66034800f Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 10 May 2021 14:18:52 -0500 Subject: [PATCH] Work in the presence of em-synchrony em-synchrony monkeypatches em-http when loaded. The old functionality is still present, but under different method names. --- lib/btc_sell_prices.rb | 4 +++- lib/electrum.rb | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/btc_sell_prices.rb b/lib/btc_sell_prices.rb index 32621108b147ec909d124077fb17189095217789..ed36b25b826e26864a212ff3356d9d5b0f15e652 100644 --- a/lib/btc_sell_prices.rb +++ b/lib/btc_sell_prices.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require "em-http" +require "em_promise" +require "em-synchrony/em-http" # For aget vs get require "money/bank/open_exchange_rates_bank" require "nokogiri" @@ -38,7 +40,7 @@ protected EM::HttpRequest.new( "https://www.canadianbitcoins.com", tls: { verify_peer: true } - ).get + ).aget end def cad_to_usd diff --git a/lib/electrum.rb b/lib/electrum.rb index 88ae11625a4c11749c974c431785b322d1c861f1..b30922c01d88bcbb87173568c11922aa183e1e95 100644 --- a/lib/electrum.rb +++ b/lib/electrum.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true require "bigdecimal" +require "em-http" require "em_promise" +require "em-synchrony/em-http" # For apost vs post require "json" -require "net/http" require "securerandom" class Electrum @@ -69,7 +70,7 @@ protected EM::HttpRequest.new( @rpc_uri, tls: { verify_peer: true } - ).post( + ).apost( head: { "Authorization" => [@rpc_username, @rpc_password], "Content-Type" => "application/json"