Class: Reth::JSONRPC::PendingTransactionFilter
- Inherits:
-
Object
- Object
- Reth::JSONRPC::PendingTransactionFilter
- Defined in:
- lib/reth/jsonrpc/filter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(chain) ⇒ PendingTransactionFilter
constructor
A new instance of PendingTransactionFilter.
Constructor Details
#initialize(chain) ⇒ PendingTransactionFilter
Returns a new instance of PendingTransactionFilter.
259 260 261 262 263 |
# File 'lib/reth/jsonrpc/filter.rb', line 259 def initialize(chain) @chain = chain @latest_block = @chain.head_candidate @reported_txs = [] end |
Class Method Details
Instance Method Details
#check ⇒ Object
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/reth/jsonrpc/filter.rb', line 265 def check head_candidate = @chain.head_candidate pending_txs = head_candidate.get_transactions new_txs = pending_txs.select {|tx| !@reported_txs.include?(tx.full_hash) } block = head_candidate.get_parent while block.number >= @latest_block.number block.get_transactions.reverse.each do |tx| new_txs.push(tx) unless @reported_txs.include?(tx.full_hash) end block = block.get_parent end @latest_block = head_candidate @reported_txs = pending_txs.map(&:full_hash) new_txs.reverse end |