more tracing
This commit is contained in:
parent
e7ce8c9558
commit
d53c47aa69
@ -230,6 +230,8 @@ pub struct LightProtocol {
|
|||||||
impl LightProtocol {
|
impl LightProtocol {
|
||||||
/// Create a new instance of the protocol manager.
|
/// Create a new instance of the protocol manager.
|
||||||
pub fn new(provider: Arc<Provider>, params: Params) -> Self {
|
pub fn new(provider: Arc<Provider>, params: Params) -> Self {
|
||||||
|
debug!(target: "les", "Initializing LES handler");
|
||||||
|
|
||||||
let genesis_hash = provider.chain_info().genesis_hash;
|
let genesis_hash = provider.chain_info().genesis_hash;
|
||||||
LightProtocol {
|
LightProtocol {
|
||||||
provider: provider,
|
provider: provider,
|
||||||
@ -400,6 +402,8 @@ impl LightProtocol {
|
|||||||
fn handle_packet(&self, io: &IoContext, peer: &PeerId, packet_id: u8, data: &[u8]) {
|
fn handle_packet(&self, io: &IoContext, peer: &PeerId, packet_id: u8, data: &[u8]) {
|
||||||
let rlp = UntrustedRlp::new(data);
|
let rlp = UntrustedRlp::new(data);
|
||||||
|
|
||||||
|
trace!(target: "les", "Incoming packet {} from peer {}", packet_id, peer);
|
||||||
|
|
||||||
// handle the packet
|
// handle the packet
|
||||||
let res = match packet_id {
|
let res = match packet_id {
|
||||||
packet::STATUS => self.status(peer, io, rlp),
|
packet::STATUS => self.status(peer, io, rlp),
|
||||||
@ -452,6 +456,8 @@ impl LightProtocol {
|
|||||||
fn on_connect(&self, peer: &PeerId, io: &IoContext) {
|
fn on_connect(&self, peer: &PeerId, io: &IoContext) {
|
||||||
let peer = *peer;
|
let peer = *peer;
|
||||||
|
|
||||||
|
trace!(target: "les", "Peer {} connecting", peer);
|
||||||
|
|
||||||
match self.send_status(peer, io) {
|
match self.send_status(peer, io) {
|
||||||
Ok(pending_peer) => {
|
Ok(pending_peer) => {
|
||||||
self.pending_peers.write().insert(peer, pending_peer);
|
self.pending_peers.write().insert(peer, pending_peer);
|
||||||
@ -465,6 +471,9 @@ impl LightProtocol {
|
|||||||
|
|
||||||
// called when a peer disconnects.
|
// called when a peer disconnects.
|
||||||
fn on_disconnect(&self, peer: PeerId, io: &IoContext) {
|
fn on_disconnect(&self, peer: PeerId, io: &IoContext) {
|
||||||
|
trace!(target: "les", "Peer {} disconnecting", peer);
|
||||||
|
|
||||||
|
|
||||||
self.pending_peers.write().remove(&peer);
|
self.pending_peers.write().remove(&peer);
|
||||||
if self.peers.write().remove(&peer).is_some() {
|
if self.peers.write().remove(&peer).is_some() {
|
||||||
let unfulfilled: Vec<_> = self.pending_requests.read()
|
let unfulfilled: Vec<_> = self.pending_requests.read()
|
||||||
|
@ -98,6 +98,7 @@ impl<'a> Parser<'a> {
|
|||||||
// expect a specific next key, and get the value's RLP.
|
// expect a specific next key, and get the value's RLP.
|
||||||
// if the key isn't found, the position isn't advanced.
|
// if the key isn't found, the position isn't advanced.
|
||||||
fn expect_raw(&mut self, key: Key) -> Result<UntrustedRlp<'a>, DecoderError> {
|
fn expect_raw(&mut self, key: Key) -> Result<UntrustedRlp<'a>, DecoderError> {
|
||||||
|
trace!(target: "les", "Expecting key {}", key.as_str());
|
||||||
let pre_pos = self.pos;
|
let pre_pos = self.pos;
|
||||||
if let Some((k, val)) = try!(self.get_next()) {
|
if let Some((k, val)) = try!(self.get_next()) {
|
||||||
if k == key { return Ok(val) }
|
if k == key { return Ok(val) }
|
||||||
|
Loading…
Reference in New Issue
Block a user