Skip to content

Commit

Permalink
few tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Armstrong committed Sep 6, 2011
1 parent a9a20a1 commit 2bd4e38
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
.rvmrc
4 changes: 2 additions & 2 deletions bin/bitcoin_connect
Expand Up @@ -22,9 +22,9 @@ EM.run do
#host = '217.157.1.202'

connections = []
RawJSON_Connection.connect(host, 8333, connections)
#RawJSON_Connection.connect(host, 8333, connections)

#Bitcoin::Connection.connect(host, 8333, connections)
#Bitcoin::Connection.connect_random_from_dns(connections)
Bitcoin::Connection.connect_random_from_dns(connections)

end
7 changes: 4 additions & 3 deletions lib/bitcoin/connection.rb
Expand Up @@ -66,8 +66,9 @@ def on_handshake_begin
from = "127.0.0.1:8333"
from_id = Bitcoin::Protocol::Uniq
to = @sockaddr.reverse.join(":")
p "==", from_id, from, to, block
pkt = Protocol.version_pkt(from_id, from, to, block)
#p ['sending version pkt', pkt]
p ['sending version pkt', pkt]
send_data(pkt)
end
end
Expand Down Expand Up @@ -112,8 +113,8 @@ def self.connect_random_from_dns(connections)

connections = []
#Bitcoin::Connection.connect('127.0.0.1', 8333, connections)
Bitcoin::Connection.connect('217.157.1.202', 8333, connections)
#Bitcoin::Connection.connect_random_from_dns(connections)
#Bitcoin::Connection.connect('217.157.1.202', 8333, connections)
Bitcoin::Connection.connect_random_from_dns(connections)

end
end
2 changes: 1 addition & 1 deletion lib/bitcoin/protocol.rb
Expand Up @@ -82,7 +82,7 @@ def self.network_address(addr)
host, port = addr.split(":")
port = port ? port.to_i : 8333
sockaddr = Socket.pack_sockaddr_in(port, host)
raise "invalid IPv4 Address: #{addr}" unless sockaddr[0...2] == "\x02\x00"
#raise "invalid IPv4 Address: #{addr}" unless sockaddr[0...2] == "\x02\x00"
port, host = sockaddr[2...4], sockaddr[4...8]
[[1].pack("Q"), "\x00"*10, "\xFF\xFF", host, port].join
end
Expand Down

0 comments on commit 2bd4e38

Please sign in to comment.