|
5 | 5 | /* global sendMessage */
|
6 | 6 |
|
7 | 7 | module.exports = {
|
8 |
| - greet: function () { |
9 |
| - console.log("Welcome to the Forest Javascript console!\n\nTo exit, press ctrl-d or type :quit"); |
10 |
| - }, |
11 |
| - showPeers: function () { |
12 |
| - let ids = netPeers().map((x) => x.ID).sort(); |
13 |
| - let buffer = ""; |
14 |
| - for (var i = 0; i < ids.length; i++) { |
15 |
| - let id = ids[i]; |
16 |
| - buffer += `${i}:\t${id}\n`; |
17 |
| - } |
18 |
| - console.log(buffer); |
19 |
| - }, |
20 |
| - getPeer: function (peerID) { |
21 |
| - return netPeers().find((x) => x.ID == peerID); |
22 |
| - }, |
23 |
| - disconnectPeers: function (count) { |
24 |
| - let ids = netPeers().map((x) => x.ID).sort(); |
25 |
| - // clamp count |
26 |
| - let new_count = Math.min(count, ids.length); |
27 |
| - for (var i = 0; i < new_count; i++) { |
28 |
| - netDisconnect(ids[i]); |
29 |
| - } |
30 |
| - }, |
31 |
| - isPeerConnected: function (peerID) { |
32 |
| - return netPeers().some((x) => x.ID == peerID); |
33 |
| - }, |
34 |
| - showWallet: function () { |
35 |
| - let addrs = walletList(); |
36 |
| - let defaultAddr = walletDefaultAddress(); |
37 |
| - let buffer = "Address Balance\n"; |
38 |
| - for (var i = 0; i < addrs.length; i++) { |
39 |
| - const addr = addrs[i]; |
40 |
| - const line = `${addr} ${walletBalance(addr)} attoFIL\n`; |
41 |
| - if (addr == defaultAddr) { |
42 |
| - buffer = buffer.concat("\033[1m", line, "\033[0m") |
43 |
| - } else { |
44 |
| - buffer = buffer.concat(line); |
45 |
| - } |
46 |
| - } |
47 |
| - console.log(buffer); |
48 |
| - }, |
49 |
| - sendFIL: function (to, amount) { |
50 |
| - let from = walletDefaultAddress(); |
51 |
| - return sendMessage(from, to, amount.toString()); |
52 |
| - }, |
53 |
| - showSyncStatus: function() { |
54 |
| - let stage = syncStatus().ActiveSyncs[0].Stage; |
55 |
| - let height = syncStatus().ActiveSyncs[0].Epoch; |
56 |
| - let result = |
57 |
| -`sync status: |
| 8 | + greet: function () { |
| 9 | + console.log( |
| 10 | + "Welcome to the Forest Javascript console!\n\nTo exit, press ctrl-d or type :quit" |
| 11 | + ); |
| 12 | + }, |
| 13 | + showPeers: function () { |
| 14 | + let ids = netPeers() |
| 15 | + .map((x) => x.ID) |
| 16 | + .sort(); |
| 17 | + let buffer = ""; |
| 18 | + for (var i = 0; i < ids.length; i++) { |
| 19 | + let id = ids[i]; |
| 20 | + buffer += `${i}:\t${id}\n`; |
| 21 | + } |
| 22 | + console.log(buffer); |
| 23 | + }, |
| 24 | + getPeer: function (peerID) { |
| 25 | + return netPeers().find((x) => x.ID == peerID); |
| 26 | + }, |
| 27 | + disconnectPeers: function (count) { |
| 28 | + let ids = netPeers() |
| 29 | + .map((x) => x.ID) |
| 30 | + .sort(); |
| 31 | + // clamp count |
| 32 | + let new_count = Math.min(count, ids.length); |
| 33 | + for (var i = 0; i < new_count; i++) { |
| 34 | + netDisconnect(ids[i]); |
| 35 | + } |
| 36 | + }, |
| 37 | + isPeerConnected: function (peerID) { |
| 38 | + return netPeers().some((x) => x.ID == peerID); |
| 39 | + }, |
| 40 | + showWallet: function () { |
| 41 | + let addrs = walletList(); |
| 42 | + let defaultAddr = walletDefaultAddress(); |
| 43 | + let buffer = "Address Balance\n"; |
| 44 | + for (var i = 0; i < addrs.length; i++) { |
| 45 | + const addr = addrs[i]; |
| 46 | + const line = `${addr} ${walletBalance(addr)} attoFIL\n`; |
| 47 | + if (addr == defaultAddr) { |
| 48 | + buffer = buffer.concat("\033[1m", line, "\033[0m"); |
| 49 | + } else { |
| 50 | + buffer = buffer.concat(line); |
| 51 | + } |
| 52 | + } |
| 53 | + console.log(buffer); |
| 54 | + }, |
| 55 | + sendFIL: function (to, amount) { |
| 56 | + let from = walletDefaultAddress(); |
| 57 | + return sendMessage(from, to, amount.toString()); |
| 58 | + }, |
| 59 | + showSyncStatus: function () { |
| 60 | + let stage = syncStatus().ActiveSyncs[0].Stage; |
| 61 | + let height = syncStatus().ActiveSyncs[0].Epoch; |
| 62 | + let result = `sync status: |
58 | 63 | Stage: ${stage}
|
59 | 64 | Height: ${height}
|
60 | 65 | `;
|
61 |
| - console.log(result); |
62 |
| - } |
63 |
| -} |
| 66 | + console.log(result); |
| 67 | + }, |
| 68 | +}; |
0 commit comments