Coverage Summary for Class: NodeHandler (org.ethereum.net)
Class |
Class, %
|
Method, %
|
Line, %
|
NodeHandler |
0%
(0/1)
|
0%
(0/4)
|
0%
(0/8)
|
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2017 RSK Labs Ltd.
4 * (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>)
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package org.ethereum.net;
21
22 import org.ethereum.net.rlpx.Node;
23 import org.ethereum.util.ByteUtil;
24
25 /**
26 * The instance of this class responsible for discovery messages exchange with the specified Node
27 * It also manages itself regarding inclusion/eviction from Kademlia table
28 *
29 * Created by Anton Nashatyrev on 14.07.2015.
30 */
31 public class NodeHandler {
32
33 private Node node;
34 private NodeStatistics nodeStatistics;
35
36 public NodeHandler(Node node) {
37 this.node = node;
38 }
39
40 public Node getNode() {
41 return node;
42 }
43
44 public NodeStatistics getNodeStatistics() {
45 if (nodeStatistics == null) {
46 nodeStatistics = new NodeStatistics();
47 }
48 return nodeStatistics;
49 }
50
51 @Override
52 public String toString() {
53 return "NodeHandler[node: " + node.getHost() + ":" + node.getPort() + ", id="
54 + (node.getId().getID().length > 0 ? ByteUtil.toHexString(node.getId().getID(), 0, 4) : "empty") + "]";
55 }
56
57
58 }