Class: Steem::RPC::ThreadSafeClient

Inherits:
BaseClient show all
Defined in:
lib/steem/rpc/thread_safe_client.rb

Overview

ThreadSafeClient is the default RPC Client used by steem-ruby. It’s perfect for simple requests. But for higher performance, it’s better to override BaseClient and implement something other than Net::HTTP.

Constant Summary collapse

SEMAPHORE =
Mutex.new.freeze

Constants inherited from BaseClient

BaseClient::POST_HEADERS

Constants included from ChainConfig

ChainConfig::EXPIRE_IN_SECS, ChainConfig::EXPIRE_IN_SECS_PROPOSAL, ChainConfig::NETWORKS_STEEM_ADDRESS_PREFIX, ChainConfig::NETWORKS_STEEM_CHAIN_ID, ChainConfig::NETWORKS_STEEM_CORE_ASSET, ChainConfig::NETWORKS_STEEM_DEBT_ASSET, ChainConfig::NETWORKS_STEEM_DEFAULT_NODE, ChainConfig::NETWORKS_STEEM_VEST_ASSET, ChainConfig::NETWORKS_TEST_ADDRESS_PREFIX, ChainConfig::NETWORKS_TEST_CHAIN_ID, ChainConfig::NETWORKS_TEST_CORE_ASSET, ChainConfig::NETWORKS_TEST_DEBT_ASSET, ChainConfig::NETWORKS_TEST_DEFAULT_NODE, ChainConfig::NETWORKS_TEST_VEST_ASSET, ChainConfig::NETWORK_CHAIN_IDS

Instance Attribute Summary

Attributes inherited from BaseClient

#chain, #error_pipe

Instance Method Summary collapse

Methods inherited from BaseClient

#evaluate_id, #http, #http_post, #initialize, #put, #rpc_post, #uri

Constructor Details

This class inherits a constructor from Steem::RPC::BaseClient

Instance Method Details

#http_request(request) ⇒ Object



9
10
11
12
13
# File 'lib/steem/rpc/thread_safe_client.rb', line 9

def http_request(request)
  response = SEMAPHORE.synchronize do
    http.request(request)
  end
end

#rpc_idObject



15
16
17
18
19
20
# File 'lib/steem/rpc/thread_safe_client.rb', line 15

def rpc_id
  SEMAPHORE.synchronize do
    @rpc_id ||= 0
    @rpc_id += 1
  end
end