class Tapyrus::Network::Connection
Basic Bitcoin P2P connection class
Attributes
fee_rate[RW]
minimum fee(in satoshis per kilobyte) for relay tx
logger[R]
peer[R]
sendheaders[RW]
if true, this peer send new block announcements using a headers message rather than an inv message.
version[RW]
remote peer version.
Public Class Methods
new(peer)
click to toggle source
# File lib/tapyrus/network/connection.rb, line 18 def initialize(peer) @peer = peer @logger = peer.logger @sendheaders = false @attr_accessor = 0 @message = '' self.pending_connect_timeout = 5.0 end
Public Instance Methods
addr()
click to toggle source
# File lib/tapyrus/network/connection.rb, line 42 def addr peer.addr end
close(msg = '')
click to toggle source
close network connection.
# File lib/tapyrus/network/connection.rb, line 47 def close(msg = '') logger.info "close connection with #{addr}. #{msg}" close_connection_after_writing end
handle_error(e)
click to toggle source
# File lib/tapyrus/network/connection.rb, line 52 def handle_error(e) peer.handle_error(e) end
post_handshake()
click to toggle source
# File lib/tapyrus/network/connection.rb, line 38 def post_handshake peer.post_handshake end
post_init()
click to toggle source
# File lib/tapyrus/network/connection.rb, line 27 def post_init logger.info "connected. #{addr}" peer.conn_time = Time.now.to_i begin_handshake end
receive_data(data)
click to toggle source
handle receiving data from remote node.
# File lib/tapyrus/network/connection.rb, line 34 def receive_data(data) handle(data) end
unbind()
click to toggle source
# File lib/tapyrus/network/connection.rb, line 56 def unbind logger.info "unbind. #{addr}" peer.unbind end
Private Instance Methods
begin_handshake()
click to toggle source
start handshake
# File lib/tapyrus/network/connection.rb, line 64 def begin_handshake logger.info "begin handshake with #{addr}" send_message(peer.local_version) end