Compare commits

..

No commits in common. "a6364d3208fd2c37cc77fc159d7629fe76fb2927" and "0fd8d18162ff49891dbf58f1ce4c73fa9a1ec5f1" have entirely different histories.

6 changed files with 57 additions and 4540 deletions

View File

@ -1,28 +1,21 @@
# What is it
This contains both RanchiMall Token SmartContract Scanner, as well as API on MYSQL. Installation for Scanner will also install all dependencies for API.
# Howto start the MYSQL version
## Setup setps
1. Just download one file from this setup.sh and run it. It will download the rest of repository
2. Give setup.sh execute permissions first `chmod +x setup.sh`, and then `./setup.sh`
3. Run setup.sh to install python3.7 virtual environment, install and configure MySQL if it does not exist, install all dependencies and then start the application.
1. Run setup.sh to install python3.7 virtual environment, install and configure MySQL if it does not exist, install all dependencies and then start the application.
2. Give setup.sh execute permissions first `chmod +x setup.sh`, and then `./setup.sh`
## How to run
### Scanner
1. python3 tracktokens-smartcontracts.py
2. python3 tracktokens-smartcontracts.py --reset
3. python3 tracktokens-smartcontracts.py --rebuild
4. python3 tracktokens-smartcontracts.py --rebuild usd# tokenroom#
1. python3.7 tracktokens-smartcontracts.py
2. python3.7 tracktokens-smartcontracts.py --reset
3. python3.7 tracktokens-smartcontracts.py --rebuild
4. python3.7 tracktokens-smartcontracts.py --rebuild usd# tokenroom#
1. python3 tracktokens-smartcontracts.py => To run normally
2. python3 tracktokens-smartcontracts.py --reset => To remove all data and start from scratch
3. python3 tracktokens-smartcontracts.py --rebuild => To reprocess existing blockchain data for ALL TOKENS as stored in latestBlocks table of rm_latestCache_db database
4. python3 tracktokens-smartcontracts.py --rebuild usd# tokenroom# => To reprocess existing blockchain data for USD# TOKENROOM# as stored in latestBlocks table of rm_latestCache_db database
### API
1. python3 ranchimallflo_api.py
1. python3.7 tracktokens-smartcontracts.py => To run normally
2. python3.7 tracktokens-smartcontracts.py --reset => To remove all data and start from scratch
3. python3.7 tracktokens-smartcontracts.py --rebuild => To reprocess existing blockchain data for ALL TOKENS as stored in latestBlocks table of rm_latestCache_db database
4. python3.7 tracktokens-smartcontracts.py --rebuild usd# tokenroom# => To reprocess existing blockchain data for USD# TOKENROOM# as stored in latestBlocks table of rm_latestCache_db database
# FLO Token & Smart Contract System
[![Test flodata parsing](https://github.com/ranchimall/flo-token-tracking/actions/workflows/test_parsing.yml/badge.svg?branch=swap-statef-testing)](https://github.com/ranchimall/flo-token-tracking/actions/workflows/test_parsing.yml)

View File

@ -2,9 +2,9 @@
NET = mainnet
FLO_CLI_PATH = /usr/local/bin/flo-cli
START_BLOCK = 3387923
BLOCKBOOK_NETURL = https://blockbook.ranchimall.net/
TESTNET_BLOCKBOOK_SERVER_LIST = https://0.0.0.0:19166/
MAINNET_BLOCKBOOK_SERVER_LIST = https://blockbook.ranchimall.net/
FLOSIGHT_NETURL = https://blockbook.ranchimall.net/
TESTNET_FLOSIGHT_SERVER_LIST = https://0.0.0.0:19166/
MAINNET_FLOSIGHT_SERVER_LIST = https://blockbook.ranchimall.net/
TOKENAPI_SSE_URL = https://ranchimallflo-blockbook.ranchimall.net
IGNORE_BLOCK_LIST = 2
IGNORE_TRANSACTION_LIST = b4
@ -16,14 +16,3 @@ USERNAME = FUfB6cwSsGDbQpmA7Qs8zQJxU3HpwCdnjT
PASSWORD = RAcifrTM2V75ipy5MeLYaDU3UNcUXtrit933TGM5o7Yj2fs8XdP5
HOST = localhost
DATABASE_PREFIX = rm
[API]
APIHOST = localhost
APIPORT = 5432
apiUrl = https://blockbook.ranchimall.net/
# Timeout configurations
RETRY_TIMEOUT_LONG = 1800
RETRY_TIMEOUT_SHORT = 60
DB_RETRY_TIMEOUT = 60
API_TIMEOUT = 1

File diff suppressed because it is too large Load Diff

View File

@ -1,43 +1,19 @@
aiofiles
aiohttp
aiomysql
apscheduler==3.9.1
arrow==1.1.0
arduino
bidict==0.21.2
blinker==1.4
cachetools
certifi==2022.12.7
cffi
certifi==2021.5.30
cffi==1.14.5
chardet==3.0.4
Click==7.0
cryptography
DBUtils
greenlet==1.1.0
h11==0.9.0
h2==3.1.1
hpack==3.0.0
Hypercorn==0.8.2
hyperframe==5.2.0
idna==2.10
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe
multidict==4.5.2
priority==1.3.0
pycparser==2.20
pyflo-lib==2.0.9
pymysql
python-dateutil==2.8.1
python-engineio==3.14.2
Quart==0.10.0
Quart-CORS==0.2.0
websockets==11.0.3
requests==2.25.0
six==1.16.0
sortedcontainers==2.1.0
SQLAlchemy==1.4.18
toml==0.10.0
typing-extensions==3.7.4
urllib3==1.26.5
websockets==11.0.3
wsproto==0.15.0
pyflo-lib==2.0.9
pymysql
cryptography
arduino

View File

@ -77,13 +77,12 @@ sudo mysql -e "FLUSH PRIVILEGES;"
echo "MySQL user '${MYSQL_USER}' created and granted privileges on databases matching 'rm_%_db'."
# Step 8: Clone the FLO Token Tracking Repository Only if `setup.sh` Is Not Already Inside the Repository Directory
if [ ! -f "tracktokens-smartcontracts.py" ]; then
echo "Cloning the FLO Token Tracking repository (mysql-migration branch)..."
git clone --branch mysql-migration https://github.com/ranchimall/flo-token-tracking
cd flo-token-tracking
# Step 8: Clone the PyFLO Repository
if [ ! -d "pyflo" ]; then
echo "Cloning the PyFLO repository..."
git clone https://github.com/ranchimall/pyflo
else
echo "Setup is already in the directory containing the repository. Skipping clone."
echo "PyFLO repository already exists. Skipping clone."
fi
# Step 9: Install Python Dependencies
@ -106,7 +105,26 @@ pip install --upgrade pip
# Install Python packages
pip install --use-pep517 -r requirements.txt
# Step 10: Start the Python Application
# Step 10: Install PyFLO
echo "Installing PyFLO..."
sudo python3 pyflo/setup.py install
# Inform the user
echo "Python dependencies and PyFLO installed successfully."
# Step 11: Clone the FLO Token Tracking Repository
if [ ! -d "flo-token-tracking" ]; then
echo "Cloning the FLO Token Tracking repository (mysql-migration branch)..."
git clone --branch mysql-migration https://github.com/ranchimall/flo-token-tracking
else
echo "FLO Token Tracking repository already exists. Skipping clone."
fi
# Step 12: Navigate into the FLO Token Tracking Directory
echo "Navigating into the FLO Token Tracking directory..."
cd flo-token-tracking
# Step 13: Start the Python Application
echo "Starting the Python application 'tracktokens-smartcontracts.py'..."
python3.7 tracktokens-smartcontracts.py

View File

@ -261,7 +261,7 @@ def refresh_committee_list_old(admin_flo_id, api_url, blocktime):
if response.status_code == 200:
response = response.json()
else:
logger.info('Response from the Blockbook API failed')
logger.info('Response from the Flosight API failed')
sys.exit(0)
committee_list = []
@ -302,11 +302,11 @@ def refresh_committee_list(admin_flo_id, api_url, blocktime):
if response.status_code == 200:
return response.json()
else:
logger.info(f'Response from the Blockbook API failed. Retry in {RETRY_TIMEOUT_SHORT}s')
logger.info(f'Response from the Flosight API failed. Retry in {RETRY_TIMEOUT_SHORT}s')
#sys.exit(0)
time.sleep(RETRY_TIMEOUT_SHORT)
except:
logger.info(f'Fetch from the Blockbook API failed. Retry in {RETRY_TIMEOUT_LONG}s...')
logger.info(f'Fetch from the Flosight API failed. Retry in {RETRY_TIMEOUT_LONG}s...')
time.sleep(RETRY_TIMEOUT_LONG)
url = f'{api_url}api/v1/address/{admin_flo_id}?details=txs'
@ -2983,7 +2983,7 @@ def scanBlockchain():
processBlock(blockindex=blockindex)
# At this point the script has updated to the latest block
# Now we connect to Blockbook's websocket API to get information about the latest blocks
# Now we connect to flosight's websocket API to get information about the latest blocks
def switchNeturl(currentneturl):
# Use modulo operation to simplify the logic
@ -2992,9 +2992,9 @@ def switchNeturl(currentneturl):
def reconnectWebsocket(socket_variable):
# Switch a to different Blockbook
# Switch a to different flosight
# neturl = switchNeturl(neturl)
# Connect to Blockbook websocket to get data on new incoming blocks
# Connect to Flosight websocket to get data on new incoming blocks
i=0
newurl = serverlist[0]
while(not socket_variable.connected):
@ -3073,8 +3073,7 @@ logging.getLogger('sqlalchemy.pool').setLevel(logging.WARNING)
logging.getLogger('sqlalchemy.dialects').setLevel(logging.WARNING)
formatter = logging.Formatter('%(asctime)s:%(name)s:%(message)s')
DATA_PATH = os.path.dirname(os.path.abspath(__file__))
file_handler = logging.FileHandler(os.path.join(DATA_PATH, 'tracking.log'))
file_handler = logging.FileHandler(os.path.join(config['DEFAULT']['DATA_PATH'],'tracking.log'))
file_handler.setLevel(logging.INFO)
file_handler.setFormatter(formatter)
@ -3088,7 +3087,7 @@ logger.addHandler(stream_handler)
# Rule 1 - Read command line arguments to reset the databases as blank
# Rule 2 - Read config to set testnet/mainnet
# Rule 3 - Set flo blockexplorer location depending on testnet or mainnet
# Rule 4 - Set the local flo-cli path depending on testnet or mainnet ( removed this feature | Blockbooks are the only source )
# Rule 4 - Set the local flo-cli path depending on testnet or mainnet ( removed this feature | Flosights are the only source )
# Rule 5 - Set the block number to scan from
@ -3112,15 +3111,15 @@ if (config['DEFAULT']['NET'] != 'mainnet') and (config['DEFAULT']['NET'] != 'tes
# Specify ADMIN ID
serverlist = None
if config['DEFAULT']['NET'] == 'mainnet':
serverlist = config['DEFAULT']['MAINNET_BLOCKBOOK_SERVER_LIST']
serverlist = config['DEFAULT']['MAINNET_FLOSIGHT_SERVER_LIST']
APP_ADMIN = 'FNcvkz9PZNZM3HcxM1XTrVL4tgivmCkHp9'
websocket_uri = get_websocket_uri(testnet=False)
elif config['DEFAULT']['NET'] == 'testnet':
serverlist = config['DEFAULT']['TESTNET_BLOCKBOOK_SERVER_LIST']
serverlist = config['DEFAULT']['TESTNET_FLOSIGHT_SERVER_LIST']
APP_ADMIN = 'oWooGLbBELNnwq8Z5YmjoVjw8GhBGH3qSP'
websocket_uri = get_websocket_uri(testnet=True)
serverlist = serverlist.split(',')
neturl = config['DEFAULT']['BLOCKBOOK_NETURL']
neturl = config['DEFAULT']['FLOSIGHT_NETURL']
api_url = neturl
tokenapi_sse_url = config['DEFAULT']['TOKENAPI_SSE_URL']
API_VERIFY = config['DEFAULT']['API_VERIFY']