Coverage for silkaj/blockchain/tools.py: 100%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-04 17:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-04 17:03 +0000
1# Copyright 2016-2024 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 functools
17from typing import Dict
19from duniterpy.api.bma import blockchain
21from silkaj.network import client_instance
24@functools.lru_cache(maxsize=1)
25def get_blockchain_parameters() -> Dict:
26 client = client_instance()
27 return client(blockchain.parameters)
30@functools.lru_cache(maxsize=1)
31def get_head_block() -> Dict:
32 client = client_instance()
33 return client(blockchain.current)
36@functools.lru_cache(maxsize=1)
37def get_currency() -> str:
38 return get_head_block()["currency"]