Coverage for silkaj/blockchain/tools.py: 100%

14 statements  

« 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/>. 

15 

16import functools 

17 

18from duniterpy.api.bma import blockchain 

19 

20from silkaj.network import client_instance 

21 

22 

23@functools.lru_cache(maxsize=1) 

24def get_blockchain_parameters() -> dict: 

25 client = client_instance() 

26 return client(blockchain.parameters) 

27 

28 

29@functools.lru_cache(maxsize=1) 

30def get_head_block() -> dict: 

31 client = client_instance() 

32 return client(blockchain.current) 

33 

34 

35@functools.lru_cache(maxsize=1) 

36def get_currency() -> str: 

37 return get_head_block()["currency"]