Work in the presence of em-synchrony
Stephen Paul Weber
created
em-synchrony monkeypatches em-http when loaded. The old functionality is still
present, but under different method names.
Change summary
lib/btc_sell_prices.rb | 4 +++-
lib/electrum.rb | 5 +++--
2 files changed, 6 insertions(+), 3 deletions(-)
Detailed changes
@@ -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
@@ -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"