Class: BSV::Wallet::InlineQueue
- Inherits:
-
Object
- Object
- BSV::Wallet::InlineQueue
- Includes:
- BroadcastQueue
- Defined in:
- lib/bsv/wallet_interface/inline_queue.rb
Overview
Synchronous broadcast queue adapter — the default for WalletClient.
InlineQueue replicates the current wallet broadcast behaviour exactly:
-
With a broadcaster: calls
broadcaster.broadcast, promotes UTXO state on success, rolls back on failure. -
Without a broadcaster: promotes immediately and returns BEEF for the caller to broadcast manually (backwards-compatible fallback).
Because this adapter executes synchronously, async? returns false and the caller can rely on the returned hash containing the final result.
Instance Method Summary collapse
-
#async? ⇒ Boolean
Returns
false— this adapter executes synchronously. -
#enqueue(payload) ⇒ Hash
Broadcasts and promotes (or just promotes) a transaction synchronously.
-
#initialize(storage:, broadcaster: nil) ⇒ InlineQueue
constructor
A new instance of InlineQueue.
-
#status(txid) ⇒ String?
Returns the broadcast status for a previously enqueued transaction.
Methods included from BroadcastQueue
Constructor Details
#initialize(storage:, broadcaster: nil) ⇒ InlineQueue
Returns a new instance of InlineQueue.
21 22 23 24 |
# File 'lib/bsv/wallet_interface/inline_queue.rb', line 21 def initialize(storage:, broadcaster: nil) @broadcaster = broadcaster @storage = storage end |
Instance Method Details
#async? ⇒ Boolean
Returns false — this adapter executes synchronously.
29 30 31 |
# File 'lib/bsv/wallet_interface/inline_queue.rb', line 29 def async? false end |
#enqueue(payload) ⇒ Hash
Broadcasts and promotes (or just promotes) a transaction synchronously.
Dispatches to broadcast_and_promote when a broadcaster is configured, or promote_without_broadcast when none is present.
52 53 54 55 56 57 58 |
# File 'lib/bsv/wallet_interface/inline_queue.rb', line 52 def enqueue(payload) if @broadcaster broadcast_and_promote(payload) else promote_without_broadcast(payload) end end |
#status(txid) ⇒ String?
Returns the broadcast status for a previously enqueued transaction.
Delegates to storage and returns the action status field, or nil if the action is not found.
40 41 42 43 |
# File 'lib/bsv/wallet_interface/inline_queue.rb', line 40 def status(txid) actions = @storage.find_actions({ txid: txid, limit: 1, offset: 0 }) actions.first&.dig(:status) end |