<commit_before>## Pocket 

The POCKET, or Proof Of Concept Electronic Token (the K is silent), is a sub-token designed to operate on the Steem blockchain and interact with its users through a simple set of commands which users can invoke via interfaces such as [Steemit.com](http://Steemit.com) and [Busy.org](https://busy.org).

Please see [the POCKET announcement on Steemit](https://steemit.com/pocket/@biophil/pocket-announcement) and [the POCKET Genesis Post](https://steemit.com/pocket/@biophil/genesis-pocket).

## How to run a confirmer bot

Here are basic instructions for Ubuntu 16.04, they probably work fine on most Linux distribution with latest version of Python 3.5.

Install the python steem library and clone the Pocket repo:

```
pip3 install steem
git clone https://github.com/biophil/pocket
cd pocket
```


Run the `blockchain_reader.py` script:
```
python3 blockchain_reader.py
```

The first time, it will exit with the error message `FileNotFoundError: Please populate config.json file with relevant values`.
So open `config.json` with your favorite text editor and fill in the following fields; I've included here @pocket-a's values:

```
"confirm_message": "Thanks for using POCKET! I am running [this confirmer code.](https://github.com/biophil/pocket)"
"confirmer_account": "pocket-a"
"confirmer_key": <your account's private Posting key>
"confirmation_active": true
"vote_on_valid_confs": true
"nodes": [""]
```

If you are running a local steemd node, the last one, `nodes`, should be set to `["localhost:8092"]` (or whichever port you're running it on). 
If you leave `"nodes"` set to its default value of `[""]`, this will use the default nodes from the steem Python library.
Or, alternatively, you could give it a custom list of public nodes you want it to connect to like
`["node1:8092","node2:8092"]...`

**Note: if you are not using a local steemd node, you may want to contact a current bot owner for a recent snapshot of the Pocket database.**
Populating the database from scratch on public nodes may take months, since you have to scan the entire blockchain block-by-block. 

There are 3 startup options, passed as arguments to `blockchain_reader.py`:
- `normal`: Starts parsing the Steem blockchain right where you last left off. If this is the first time you've run your bot, this will start at Steem block 1.
- `replay-from-0`: Begin parsing the Steem blockchain at the beginning of history. **Danger!** This erases your current database! Consider making a backup of your `.db` file.
- `replay-from-genesis`: Begin parsing the Steem blockchain in block number 14971640, when Pocket Genesis begins. Uses the eligibility snapshot contained in `db_pregenesis.json`. **Danger!** This erases your current database! Consider making a backup of your `.db` file.

Open a screen terminal and hit it (my example command uses the `replay_from_genesis` option):

```
screen [press Enter]
python3 blockchain_reader.py replay-from-genesis
```

**Note:** To access the `normal` startup mode, you can simply call `blockchain_reader.py`:

```
python3 blockchain_reader.py
```

## How to see how the sync is going
Once you're running the `blockchain_reader.py` script, the code will scan through the entire Steem blockchain computing everybody's eligibility and looking for Pocket commands. To check its progress, run these python commands in another terminal window:

```
python3
>>> import util.db as db
>>> DB = db.Mist_DB()
>>> DB.last_parsed_block()
200
```
This means it's gotten through Steem block 200; when Pocket was new, there were over 15,000,000 blocks.<commit_msg>clarifications to readme<commit_after>## Pocket 

The POCKET, or Proof Of Concept Electronic Token (the K is silent), is a sub-token designed to operate on the Steem blockchain and interact with its users through a simple set of commands which users can invoke via interfaces such as [Steemit.com](http://Steemit.com) and [Busy.org](https://busy.org).

Please see [the POCKET announcement on Steemit](https://steemit.com/pocket/@biophil/pocket-announcement) and [the POCKET Genesis Post](https://steemit.com/pocket/@biophil/genesis-pocket).

## How to run a confirmer bot

Here are basic instructions for Ubuntu 16.04, they probably work fine on most Linux distribution with latest version of Python 3.5.

Install the python steem library and clone the Pocket repo:

```
pip3 install steem
pip3 install funcy==1.8
git clone https://github.com/biophil/pocket
cd pocket
git checkout develop
```


Run the `blockchain_reader.py` script:
```
python3 blockchain_reader.py
```

The first time, it will exit with the error message `FileNotFoundError: Please populate config.json file with relevant values`.
So open `config.json` with your favorite text editor and fill in the following fields; I've included here @pocket-a's values:

```
"confirm_message": "Thanks for using POCKET! I am running [this confirmer code.](https://github.com/biophil/pocket)"
"confirmer_account": "pocket-a"
"confirmer_key": <your account's private Posting key>
"confirmation_active": true
"vote_on_valid_confs": true
"nodes": ["https://steemd.steemitstage.com","https://steemd.steemit.com","steem.house:8090"]
```

If you are running a local steemd node, the last one, `nodes`, should be set to `["localhost:8092"]` (or whichever port you're running it on). 
If you leave `"nodes"` set to its default value of `[""]`, this will use the default nodes from the steem Python library.
Or, alternatively, you could give it a custom list of public nodes you want it to connect to like
`["node1:8092","node2:8092"]...`

Populating the database from scratch on public nodes may take months, since you have to scan the entire blockchain block-by-block. 
To alleviate this, a snapshot is provided of the Pocket database immediately preceding Genesis in the file `db_pregenesis.json`. To use this snapshot, use the second of these startup options the first time you run `blockchain_reader.py` after editing config:

There are 3 startup options, passed as arguments to `blockchain_reader.py`:
- `normal`: Starts parsing the Steem blockchain right where you last left off. If this is the first time you've run your bot, this will start at Steem block 1.
- `replay-from-0`: Begin parsing the Steem blockchain at the beginning of history. **Danger!** This erases your current database! Consider making a backup of your `.db` file.
- `replay-from-genesis`: Begin parsing the Steem blockchain in block number 14971640, when Pocket Genesis begins. Uses the eligibility snapshot contained in `db_pregenesis.json`. **Danger!** This erases your current database! Consider making a backup of your `.db` file.

Open a screen terminal and hit it (my example command uses the `replay_from_genesis` option):

```
screen [press Enter]
python3 blockchain_reader.py replay-from-genesis
```

**Note:** After this first time, to access the `normal` startup mode, you can simply call `blockchain_reader.py`:

```
python3 blockchain_reader.py
```

## How to see how the sync is going
Once you're running the `blockchain_reader.py` script, the code will scan through the entire Steem blockchain computing everybody's eligibility and looking for Pocket commands. To check its progress, run these python commands in another terminal window:

```
python3
>>> import util.db as db
>>> DB = db.Mist_DB()
>>> DB.last_parsed_block()
200
```
This means it's gotten through Steem block 200; when Pocket was new, there were over 15,000,000 blocks.
{'fraction_non_alphanumeric': 0.09188177076367528, 'fraction_numerical': 0.014310552360572422, 'mean_word_length': 4.934920634920635, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5667434', 'n_tokens_mistral': 2250, 'n_tokens_neox': 2034, 'n_words': 991}