Sha256: f0d68a9375c61765511c96613a3a030499e5ef8f6176fcc6d36043e155664502

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

# encoding: ascii-8bit

module Bitcoin
  module Protocol
    # https://en.bitcoin.it/wiki/Protocol_documentation#Message_types
    class Handler
      def on_inv_transaction(hash)
        p ['inv transaction', hash.hth]
      end

      def on_inv_block(hash)
        p ['inv block', hash.hth]
      end

      def on_get_transaction(hash)
        p ['get transaction', hash.hth]
      end

      def on_get_block(hash)
        p ['get block', hash.hth]
      end

      def on_addr(addr)
        p ['addr', addr, addr.alive?]
      end

      def on_tx(tx)
        p ['tx', tx]
      end

      def on_block(block)
        # p ['block', block]
        puts block.to_json
      end

      def on_error(message, payload)
        p ['error', message, payload]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bitcoin-ruby-0.0.20 lib/bitcoin/protocol/handler.rb
bitcoin-ruby-0.0.19 lib/bitcoin/protocol/handler.rb