|
|
|
# Setup
|
|
|
|
|
|
|
|
## 1. Preparing database
|
|
|
|
|
|
|
|
Install postgres extension using this [README](https://gitlab.syncad.com/hive/psql_tools/-/blob/master/src/hive_fork_manager/Readme.md)
|
|
|
|
by cloning this [repo](https://gitlab.syncad.com/hive/psql_tools)
|
|
|
|
|
|
|
|
⚠️ It requires super user privillages when installing ⚠️
|
|
|
|
|
|
|
|
When you create new database with extension `hive_fork_manager` you can proceed to next step
|
|
|
|
|
|
|
|
## 2 Fulling database
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone git@gitlab.syncad.com:hive/hive.git
|
|
|
|
pushd hive
|
|
|
|
git submodules --init --recursive
|
|
|
|
popd
|
|
|
|
mkdir build_haf_sql_serializer
|
|
|
|
pushd build_haf_sql_serializer
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release ../hive
|
|
|
|
make -j${nproc}
|
|
|
|
pushd programs/hived
|
|
|
|
./hived -d data --dump-config
|
|
|
|
vim data/config.ini
|
|
|
|
```
|
|
|
|
|
|
|
|
now add following lines to the file, next save and exit:
|
|
|
|
```
|
|
|
|
plugin = sql_serializer
|
|
|
|
psql-url = dbname=<db name> user=<user> password=<password> hostaddr=127.0.0.1 port=5432
|
|
|
|
```
|
|
|
|
|
|
|
|
additionally You can add block_log in: `data/blockchain` if you have one<br>
|
|
|
|
at the end run:
|
|
|
|
```
|
|
|
|
./hived -d data --replay-blockchain --stop-replay-at-block 5000000 --exit-before-sync
|
|
|
|
```
|
|
|
|
|
|
|
|
hived should exit by itself.
|
|
|
|
|
|
|
|
To follow this instruction execute following commands (moving to proper dir):
|
|
|
|
|
|
|
|
```
|
|
|
|
popd
|
|
|
|
popd
|
|
|
|
```
|
|
|
|
|
|
|
|
## 3 Filling tables required by AH
|
|
|
|
|
|
|
|
```
|
|
|
|
pushd hived
|
|
|
|
git checkout km-mt-ah-feed-irr
|
|
|
|
git submodule --init --recursive
|
|
|
|
HIVE_PATH=$PWD
|
|
|
|
popd
|
|
|
|
# alternatively you can reuse previous build directory
|
|
|
|
mkdir build_haf_fed
|
|
|
|
pushd build_haf_fed
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release ../hive
|
|
|
|
make -j${nproc}
|
|
|
|
./programs/haf_ah/haf_ah --url postgresql://<user>:<password>@127.0.0.1/<db name> --schema-dir $HIVE_PATH/programs/haf_ah/data/ --range-blocks-flush 5000 --allowed-empty-result 10
|
|
|
|
popd
|
|
|
|
```
|
|
|
|
|
|
|
|
## 4. Running API
|
|
|
|
|
|
|
|
```
|
|
|
|
git clone git@gitlab.syncad.com:hive/HAfAH.git -b develop
|
|
|
|
pushd HAfAH
|
|
|
|
screen -mdS HAfAH ./main.py
|
|
|
|
popd
|
|
|
|
```
|
|
|
|
|
|
|
|
By default app will reserve address: `0.0.0.0:8090`
|
|
|
|
|
|
|
|
You can change it in: main.py:64
|
|
|
|
|
|
|
|
## 5. Testing
|
|
|
|
|
|
|
|
Following curl should succeed
|
|
|
|
|
|
|
|
```
|
|
|
|
curl -s --data '{"jsonrpc":"2.0", "method":"account_history_api.get_account_history", "params":{"account":"initminer", "start":1000, "limit":1000}, "id":1}' http://192.168.6.200:8090 | jq .
|
|
|
|
```
|
|
|
|
|