Network::getNetTotals()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 18/08/15
5
 * Time: 19:54
6
 */
7
8
namespace Del\Bitcoin\Api;
9
10
11
class Network extends AbstractApi
12
{
13
14
    /**
15
     * The addnode RPC attempts to add or remove a node from
16
     * the addnode list, or to try a connection to a node once.
17
     *
18
     * @param string $host The node to add as a string in the form of
19
     * <IP address>:<port>. The IP address may be a hostname
20
     * resolvable through DNS, an IPv4 address, an IPv4-as-IPv6 address,
21
     * or an IPv6 address
22
     * @param string $command What to do with the IP address above. Options are:
23
     * add to add a node to the addnode list. This will not connect immediately
24
     *      if the outgoing connection slots are full
25
     * remove to remove a node from the list. If currently connected, this will
26
     *      disconnect immediately
27
     * onetry to immediately attempt connection to the node even if the outgoing
28
     *      connection slots are full; this will only attempt the connection once
29
     * @return mixed
30
     */
31
    public function addNode($host,$command)
32
    {
33
        return $this->send('addnode',[$host,$command]);
34
    }
35
36
    /**
37
     * The getaddednodeinfo RPC returns information about the given added
38
     * node, or all added nodes (except onetry nodes). Only nodes which
39
     * have been manually added using the addnode RPC will have their
40
     * information displayed.
41
     *
42
     * @param bool $details Set to true to display detailed
43
     * information about each added node; set to false to only
44
     * display the IP address or hostname and port added
45
     * @param string $node The node to get information about in the same
46
     * <IP address>:<port> format as the addnode RPC. If this parameter
47
     * is not provided, information about all added nodes will be returned
48
     * @return mixed
49
     */
50
    public function getAddedNodeInfo($details,$node)
51
    {
52
        return $this->send('getaddednodeinfo',[$details,$node]);
53
    }
54
55
    /**
56
     * The getconnectioncount RPC returns the number of connections
57
     * to other nodes.
58
     *
59
     * @return mixed
60
     */
61
    public function getConnectionCount()
62
    {
63
        return $this->send('getconnectioncount');
64
    }
65
66
    /**
67
     * The getnettotals RPC returns information about network traffic,
68
     * including bytes in, bytes out, and the current time.
69
     *
70
     * @return mixed
71
     */
72
    public function getNetTotals()
73
    {
74
        return $this->send('getnettotals');
75
    }
76
77
    /**
78
     * The getnetworkinfo RPC returns information about the node’s
79
     * connection to the network.
80
     *
81
     * @return mixed
82
     */
83
    public function getNetworkInfo()
84
    {
85
        return $this->send('getnetworkinfo');
86
    }
87
88
89
    /**
90
     * The getpeerinfo RPC returns data about each
91
     * connected network node.
92
     *
93
     * @return mixed
94
     */
95
    public function getPeerInfo()
96
    {
97
        return $this->send('getpeerinfo');
98
    }
99
100
    /**
101
     * The ping RPC sends a P2P ping message to all connected nodes
102
     * to measure ping time. Results are provided by the getpeerinfo
103
     * RPC pingtime and pingwait fields as decimal seconds. The P2P
104
     * ping message is handled in a queue with all other commands, so
105
     * it measures processing backlog, not just network ping.
106
     *
107
     * Get the results using the getpeerinfo RPC:
108
     *
109
     * @return mixed
110
     */
111
    public function ping()
112
    {
113
        return $this->send('ping');
114
    }
115
}