From c61a785525b972f46f147ed3f2a40b708044006e Mon Sep 17 00:00:00 2001 From: Hugo Trentesaux <hugo@trentesaux.fr> Date: Wed, 7 Oct 2020 10:59:14 +0200 Subject: [PATCH] [feat] example for loading local blockchain --- examples/load_local_blockchain.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 examples/load_local_blockchain.py diff --git a/examples/load_local_blockchain.py b/examples/load_local_blockchain.py new file mode 100644 index 00000000..260f49fd --- /dev/null +++ b/examples/load_local_blockchain.py @@ -0,0 +1,11 @@ +# this example lets you load locally copy of duniter blockchain into duniterpy objects +# by default, it searches in ~/.config/duniter/duniter_default/g1/ + +from duniterpy.helpers.blockchain import load + +bc = load() # gets blockchain iterator +b = next(bc) # gets block +b.number # should return 0 +# you can access all properties of this block through it's duniterpy objects attributes +next(bc).number # should return 1 +next(bc).number # should return 2 (and so on) \ No newline at end of file -- GitLab