Class: BSV::Wallet::Postgres::ArcAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/bsv/wallet/postgres/arc_adapter.rb

Overview

Bridges the BroadcastQueue’s arc_client interface (which passes raw_tx binary) with the SDK’s ARC protocol (which expects Transaction objects).

Examples:

provider = BSV::Network::Providers::GorillaPool.mainnet
adapter = ArcAdapter.new(provider)
broadcast_queue = BroadcastQueue.new(db: db, arc_client: adapter)

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ ArcAdapter

Returns a new instance of ArcAdapter.



14
15
16
# File 'lib/bsv/wallet/postgres/arc_adapter.rb', line 14

def initialize(provider)
  @provider = provider
end

Instance Method Details

#call(method, *args, **kwargs) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bsv/wallet/postgres/arc_adapter.rb', line 18

def call(method, *args, **kwargs)
  case method
  when :broadcast
    tx = BSV::Transaction::Transaction.from_binary(args.first)
    @provider.call(:broadcast, tx)
  when :get_tx_status
    @provider.call(:get_tx_status, **kwargs)
  else
    @provider.call(method, *args, **kwargs)
  end
end