Module: BSV::Wallet::Pushable

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

Overview

Mixin contract for entities that can be pushed to the network.

Include this module in any model that needs to submit data to a network service (e.g. broadcasting a transaction via ARC). The including class must override every method — the defaults raise NotImplementedError to enforce the contract.

Designed to work alongside Fetchable. 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

#needs_push?Boolean

Whether this entity currently needs pushing.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/bsv/wallet/pushable.rb', line 40

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

#push_commandSymbol

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

Returns:

  • (Symbol)

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/bsv/wallet/pushable.rb', line 19

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

#push_payloadObject

The payload to send (e.g. raw_tx binary).

Returns:

  • (Object)

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/bsv/wallet/pushable.rb', line 26

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

#write!(response) ⇒ Object

Update self from the network response after a successful push.

Parameters:

  • response (BSV::Network::ProtocolResponse)

    normalized response

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/bsv/wallet/pushable.rb', line 33

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