Sha256: 75ca4a293ace5db2fc545e6b5cd692efc8d080271ed2d528fe70109c74db1fe6

Contents?: true

Size: 796 Bytes

Versions: 14

Compression:

Stored size: 796 Bytes

Contents

module Bitcoin
  module Message

    # sendcmpct message
    # https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki
    class SendCmpct < Base

      COMMAND = 'sendcmpct'

      MODE_HIGH = 1
      MODE_LOW = 0

      attr_accessor :mode
      attr_accessor :version
      # TODO support version 2

      def initialize(mode = MODE_HIGH, version = 1)
        @mode = mode
        @version = version
      end

      def self.parse_from_payload(payload)
        buf = StringIO.new(payload)
        mode = buf.read(1).unpack1('c')
        version = buf.read(8).unpack1('Q')
        new(mode, version)
      end

      def to_payload
        [mode, version].pack('cQ')
      end

      def high?
        mode == 1
      end

      def low?
        mode.zero?
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
bitcoinrb-1.7.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.6.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.5.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.4.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.3.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.2.1 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.2.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.1.1 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.1.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-1.0.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-0.9.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-0.8.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-0.7.0 lib/bitcoin/message/send_cmpct.rb
bitcoinrb-0.6.0 lib/bitcoin/message/send_cmpct.rb