Class: Radiator::SSC::Stream
- Inherits:
-
Blockchain
- Object
- BaseSteemSmartContractRPC
- Blockchain
- Radiator::SSC::Stream
- Defined in:
- lib/radiator/ssc/stream.rb
Overview
Streams the “blockchain” endpoint.
Constant Summary collapse
- MIN_BLOCK_PRODUCTION =
Block production on the sidechain is no faster than 3 seconds, but can be indefinately longer than 3 seconds if there are no pending transactions.
3.0
Constants inherited from BaseSteemSmartContractRPC
BaseSteemSmartContractRPC::MAX_BACKOFF, BaseSteemSmartContractRPC::POST_HEADERS
Instance Method Summary collapse
-
#blocks(options = {}, &block) ⇒ Object
Stream each block on the side-chain.
-
#initialize(options = {}) ⇒ Stream
constructor
A new instance of Stream.
-
#transactions(options = {}, &block) ⇒ Object
Stream each transaction on the side-chain.
Methods inherited from Blockchain
#block_info, #latest_block_info, #transaction_info
Methods inherited from BaseSteemSmartContractRPC
Constructor Details
#initialize(options = {}) ⇒ Stream
Returns a new instance of Stream.
15 16 17 |
# File 'lib/radiator/ssc/stream.rb', line 15 def initialize( = {}) super end |
Instance Method Details
#blocks(options = {}, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/radiator/ssc/stream.rb', line 28 def blocks( = {}, &block) at_block_num = [:at_block_num] || latest_block_info.blockNumber loop do block = block_info(at_block_num) if block.nil? sleep MIN_BLOCK_PRODUCTION and next end at_block_num += 1 yield block, block.blockNumber end end |
#transactions(options = {}, &block) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/radiator/ssc/stream.rb', line 53 def transactions( = {}, &block) blocks() do |block, block_num| block.transactions.each do |transaction| yield transaction, transaction.transactionId, block_num end end end |