Coverage for silkaj/blockchain/information.py: 100%
13 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-20 12:29 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-20 12:29 +0000
1# Copyright 2016-2025 Maël Azimi <m.a@moul.re>
2#
3# Silkaj is free software: you can redistribute it and/or modify
4# it under the terms of the GNU Affero General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7#
8# Silkaj is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU Affero General Public License for more details.
12#
13# You should have received a copy of the GNU Affero General Public License
14# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
16import arrow
17import rich_click as click
19from silkaj.blockchain.tools import get_head_block
20from silkaj.constants import ALL
21from silkaj.network import determine_endpoint
22from silkaj.tools import get_currency_symbol
25@click.command("info", help="Display information about currency")
26def currency_info() -> None:
27 head_block = get_head_block()
28 ep = determine_endpoint()
29 current_time = arrow.get(head_block["time"]).to("local")
30 mediantime = arrow.get(head_block["medianTime"]).to("local")
31 print(
32 "Connected to node:",
33 ep.host,
34 ep.port,
35 "\nCurrent block number:",
36 head_block["number"],
37 "\nCurrency name:",
38 get_currency_symbol(),
39 "\nNumber of members:",
40 head_block["membersCount"],
41 "\nMinimal Proof-of-Work:",
42 head_block["powMin"],
43 "\nCurrent time:",
44 current_time.format(ALL),
45 "\nMedian time:",
46 mediantime.format(ALL),
47 "\nDifference time:",
48 current_time - mediantime,
49 )