You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This Python 3 library provides a parser for the raw data stored by bitcoind.
2
+
This Python 3 library provides a parser for the raw data stored by bitcoind.
3
3
4
4
## Features
5
5
- Detects outputs types
@@ -17,10 +17,10 @@ Below are two basic examples for parsing the blockchain. More examples are avail
17
17
This blockchain parser parses raw blocks saved in Bitcoin Core's `.blk` file format. Bitcoin Core does not guarantee that these blocks are saved in order. If your application does not require that blocks are parsed in order, the `Blockchain.get_unordered_blocks(...)` method can be used:
18
18
19
19
```python
20
-
import os
20
+
import os
21
21
from blockchain_parser.blockchain import Blockchain
22
22
23
-
# Instantiate the Blockchain by giving the path to the directory
23
+
# Instantiate the Blockchain by giving the path to the directory
@@ -34,7 +34,7 @@ for block in blockchain.get_unordered_blocks():
34
34
If maintaining block order is necessary for your application, you should use the `Blockchain.get_ordered_blocks(...)` method. This method uses Bitcoin Core's LevelDB index to locate ordered block data in it's `.blk` files.
35
35
36
36
```python
37
-
import os
37
+
import os
38
38
from blockchain_parser.blockchain import Blockchain
39
39
40
40
# To get the blocks ordered by height, you need to provide the path of the
@@ -52,7 +52,7 @@ for block in blockchain.get_ordered_blocks(os.path.expanduser('~/.bitcoin/blocks
Building the LevelDB index can take a while which can make iterative development and debugging challenging. For this reason, `Blockchain.get_ordered_blocks(...)` supports caching the LevelDB index database using [pickle](https://docs.python.org/3.6/library/pickle.html). To use a cache simply pass `cache=filename` to the ordered blocks method. If the cached file does not exist it will be created for faster parsing the next time the method is run. If the cached file already exists it will be used instead of re-parsing the LevelDB database.
55
+
Building the LevelDB index can take a while which can make iterative development and debugging challenging. For this reason, `Blockchain.get_ordered_blocks(...)` supports caching the LevelDB index database using [pickle](https://docs.python.org/3.6/library/pickle.html). To use a cache simply pass `cache=filename` to the ordered blocks method. If the cached file does not exist it will be created for faster parsing the next time the method is run. If the cached file already exists it will be used instead of re-parsing the LevelDB database.
56
56
57
57
```python
58
58
for block in blockchain.get_ordered_blocks(os.path.expanduser('~/.bitcoin/blocks/index'), cache='index-cache.pickle'):
@@ -63,6 +63,14 @@ for block in blockchain.get_ordered_blocks(os.path.expanduser('~/.bitcoin/blocks
63
63
64
64
## Installing
65
65
66
+
### Using pip
67
+
68
+
```
69
+
pip install blockchain-parser
70
+
```
71
+
72
+
### Using source
73
+
66
74
Requirements : python-bitcoinlib, plyvel, coverage for tests
67
75
68
76
plyvel requires leveldb development libraries for LevelDB >1.2.X
@@ -73,12 +81,25 @@ On Linux, install libleveldb-dev
73
81
sudo apt-get install libleveldb-dev
74
82
```
75
83
84
+
Install dependencies contained in `requirements.txt`:
85
+
```
86
+
pip install -r requirements.txt
87
+
```
88
+
76
89
Then, just run
77
90
```
78
91
python setup.py install
79
92
```
80
93
81
-
## Tests
94
+
## Developing
95
+
96
+
First, setup a virtualenv and install dependencies:
0 commit comments