Module: BSV::Wallet::Fetchable

Defined in:
lib/bsv/wallet/fetchable.rb

Overview

Mixin contract for entities that can fetch state from the network.

Include this module in any model that needs to poll a network service for updated state (e.g. checking transaction status, retrieving merkle proofs).

The including class must override every method — the defaults raise NotImplementedError to enforce the contract.

Designed to work alongside Pushable. When a class includes both, only one write! method exists — the class must provide its own override that handles both push and fetch response shapes.

Instance Method Summary collapse

Instance Method Details

#fetch_argsHash

The arguments to pass to the protocol command.

Returns:

  • (Hash)

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/bsv/wallet/fetchable.rb', line 28

def fetch_args
  raise NotImplementedError, "#{self.class}#fetch_args not implemented"
end

#fetch_commandSymbol

The protocol command to invoke (e.g. :get_tx_status).

Returns:

  • (Symbol)

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/bsv/wallet/fetchable.rb', line 21

def fetch_command
  raise NotImplementedError, "#{self.class}#fetch_command not implemented"
end

#needs_fetch?Boolean

Whether this entity currently needs fetching.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/bsv/wallet/fetchable.rb', line 42

def needs_fetch?
  raise NotImplementedError, "#{self.class}#needs_fetch? not implemented"
end

#write!(response) ⇒ Object

Update self from the network response after a successful fetch.

Parameters:

  • response (BSV::Network::ProtocolResponse)

    normalized response

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/bsv/wallet/fetchable.rb', line 35

def write!(response)
  raise NotImplementedError, "#{self.class}#write! not implemented"
end