Add a convenience method to determine the network a message is from
This commit is contained in:
@@ -428,7 +428,7 @@ module BtcWireProto
|
||||
string :command, :length => 12
|
||||
uint32 :payload_len, :value => lambda { payload.num_bytes }
|
||||
uint32 :checksum, :onlyif => :has_checksum?
|
||||
|
||||
|
||||
choice :payload, :selection => :payload_choice do
|
||||
version "version"
|
||||
addr_pre31402 "addr_pre31402"
|
||||
@@ -446,10 +446,17 @@ module BtcWireProto
|
||||
null_payload "null"
|
||||
end
|
||||
|
||||
# @return[Symbol] representation of the command this message contains
|
||||
def cmd_sym
|
||||
c = command.strip
|
||||
c == "" ? nil : c.to_sym
|
||||
end
|
||||
|
||||
# @return[Symbol] representation of the network this message belongs to
|
||||
def network_name
|
||||
NETWORKS[magic]
|
||||
end
|
||||
|
||||
# version and verack messages don't have a checksum. The rest do.
|
||||
# @return[Boolean] does this message header have a checksum field or not?
|
||||
def has_checksum?
|
||||
|
Reference in New Issue
Block a user