Skip to content

Commit 9a4f98c

Browse files
committed
Update README and gitignore
1 parent 7a9e15c commit 9a4f98c

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ target/
5959

6060
# PyCharm
6161
.idea/
62+
63+
.vscode/
64+
.venv/

README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# bitcoin-blockchain-parser [![Build Status](https://travis-ci.org/alecalve/python-bitcoin-blockchain-parser.svg?branch=master)](https://travis-ci.org/alecalve/python-bitcoin-blockchain-parser) [![Coverage Status](https://coveralls.io/repos/alecalve/python-bitcoin-blockchain-parser/badge.svg?branch=master&service=github)](https://coveralls.io/github/alecalve/python-bitcoin-blockchain-parser?branch=master)
2-
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.
33

44
## Features
55
- Detects outputs types
@@ -17,10 +17,10 @@ Below are two basic examples for parsing the blockchain. More examples are avail
1717
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:
1818

1919
```python
20-
import os
20+
import os
2121
from blockchain_parser.blockchain import Blockchain
2222

23-
# Instantiate the Blockchain by giving the path to the directory
23+
# Instantiate the Blockchain by giving the path to the directory
2424
# containing the .blk files created by bitcoind
2525
blockchain = Blockchain(os.path.expanduser('~/.bitcoin/blocks'))
2626
for block in blockchain.get_unordered_blocks():
@@ -34,7 +34,7 @@ for block in blockchain.get_unordered_blocks():
3434
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.
3535

3636
```python
37-
import os
37+
import os
3838
from blockchain_parser.blockchain import Blockchain
3939

4040
# 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
5252
print("height=%d block=%s" % (block.height, block.hash))
5353
```
5454

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.
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.
5656

5757
```python
5858
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
6363

6464
## Installing
6565

66+
### Using pip
67+
68+
```
69+
pip install blockchain-parser
70+
```
71+
72+
### Using source
73+
6674
Requirements : python-bitcoinlib, plyvel, coverage for tests
6775

6876
plyvel requires leveldb development libraries for LevelDB >1.2.X
@@ -73,12 +81,25 @@ On Linux, install libleveldb-dev
7381
sudo apt-get install libleveldb-dev
7482
```
7583

84+
Install dependencies contained in `requirements.txt`:
85+
```
86+
pip install -r requirements.txt
87+
```
88+
7689
Then, just run
7790
```
7891
python setup.py install
7992
```
8093

81-
## Tests
94+
## Developing
95+
96+
First, setup a virtualenv and install dependencies:
97+
98+
```
99+
virtualenv -p python3 .venv
100+
source .venv/bin/activate
101+
pip install -r requirements.txt
102+
```
82103

83104
Run the test suite by lauching
84105
```

0 commit comments

Comments
 (0)