├── api.py
├── config.ini
├── create_table
│ └── create_table.py
│ └── hash_analysis.py
│ └── test_table.py
├── Ethereum_Transaction.py
├── ethereum.txt
├── nohup.out
├── pycache
│ ├── Ethereum_Transaction.cpython-36.pyc
│ └── subfunction.cpython-36.pyc
└── subfunction.py
Install MySql DB.
sudo apt-get install mysql-server
sudo apt install mysql-client
sudo apt install libmysqlclient-dev
sudo mysql
SELECT user,authentication_string,plugin,host FROM mysql.user;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678';
FLUSH PRIVILEGES;
SELECT user,authentication_string,plugin,host FROM mysql.user;
exit
sudo mysql -u root -p
show databases;
- Use
mkdir ethereum
to create a new folder.- Use
cd ./ethereum
to change your location.- Use
geth --datadir test init ./genesis.json
to create an ethereum.
Node1:
{
"config": {
"chainId": 4567,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5e64ebff",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x80",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Node2:
{
"config": {
"chainId": 4567,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5e64ebff",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x80",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Node3:
{
"config": {
"chainId": 4567,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5e64ebff",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x80",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
- Use
personal.newAccount("password")
to create a miner account. And it will return a AccountID back to you.- Use
personal.newAccount("password")
to create a user account. And it will return a AccountID back to you.- You can use the
eth.accounts
to list all account.- Use
miner.start()
start to dug.- After dug the coin, you can use
miner.stop
to stop dug.- Use
eth.getBalance(<miner account>)
to check the coin of miner account.
The config file is at BIM_API/cinfig.ini.
[MYSQL]
host = localhost
port = 3306
user = root
password = 12345678
[FLASK]
host = 0.0.0.0
port = 5054
[PATH]
file_path = /home/hj/3N_Files
[ETHEREUM_Node1]
host = 192.168.1.99
port = 30223
miner_account = 0x2e6c3ccfe2b71e66d179d0375a2fbaa8f5d93159
miner_passwd = password
user = 0xa93d7f0ce88f4ac50918044c02026a4a707dfbb4
user_passwd = password
[ETHEREUM_Node2]
host = 192.168.1.99
port = 30224
miner_account = 0x026605cef491436cf381fd3cdb6e276043ac3286
miner_passwd = password
user = 0x8409164c9e19e7a14cc75b3dfee664fa10f6ea2f
user_passwd = password
[ETHEREUM_Node3]
host = 192.168.1.99
port = 30225
miner_account = 0x62e79b354adfcb519a00aa620f808cc772b1bf84
miner_passwd = password
user = 0xfc12f01b44d9d94199b5ab53ea9341f0f4b46151
user_passwd = password
Accroding to your system setting to edit your config.ini.
In
BIM_P_API
usepython3 ./create_table/create_table.py
to initiate the DB.
In
BIM_P_API
usepython3 ./api.py
to run the api.
1. Upload information to the Database and Blockchain
POST : http://140.118.121.110:30600/upload
Rule: Body -> raw -> json
Parameters:
{
"Project_id": "Test_project",
"Project_user_id": "Susanwu",
"Object_id": "susanwu20201215151615251353",
"Element_location": [
0.99849714986386384,
-0.054803665148789531,
0.0,
0.0,
0.054803665148789531,
0.99849714986386384,
0.0,
0.0,
0.0,
0.0,
1.0,
2100.0,
0.0,
0.0,
0.0,
1.0
],
"Element_parameters": {
"Panel Length1": 600.0,
"Panel Length2": 600.0,
"Panel Thickness": 10.0,
"Control Ratio": 0.1,
"Hole Radius": 20.0,
"Material Option": 0
},
"Label_name":[
"Object",
"Color",
"Owner"
],
"Label":[
"Object_D",
"Red",
"Susan1"
]
}
2. Conditional search the parameters from the database.
POST : http://140.118.121.110:30600/location
Rule: Body -> raw -> json
Parameters:
{
"Project_id": "TestProject",
"Object_id" : "susanwu20201215151615251353",
"Element_id": "",
"Label": "",
"Check_in_status": "1",
"Check_in_time": "2021/05/05/",
"Check_out_status": "",
"Check_out_time": ""
}
3. Upload files to File Management and record the path in the database.
POST : http://140.118.121.110:30600/upload_file
Rule: Body -> form-data (Key, Value)
Parameters:
a. Element_id [test]
b. Element_location_file [file]
4. According to the path stored in the database, and download files from the File Management.
POST : http://140.118.121.110:30600/download_file
Rule: Body -> form-data (Key, Value)
Parameters:
a. Element_id [test]
5. Check out the Element of the Project.
POST : http://140.118.121.110:30600/check_out
Rule: Body -> raw -> json
Parameters:
{
"Project_id" : "Test_project",
"Project_check_out_user_id" : "HuangJun",
"Element_id" : ["Test_projectN7", "Test_projectN8", "Test_projectN9", "Test_projectN10", "Test_projectN11"]
}
6. Check in data verification
POST : http://140.118.121.110:30600/Checkin_verification
Rule: Body -> raw -> json
Parameters:
{
"Check_in_hashcode": "0xcce0d044e21bc5d85dd43b88da1969489ea767b62e2ebfa75269863e4b29569e"
}
7. Check out data verification
POST : http://140.118.121.110:30600/Checkout_verification
Rule: Body -> raw -> json
Parameters:
{
"Check_out_hashcode": "0xe1681b78cce1f1e34b5c03bac3284c319550a717d94a95b1394d2907484c3b81"
}
8. Use the SQL command: "SELECT"
POST : http://140.118.121.110:30600/sql_select
Rule: Body -> raw -> json
Parameters:
{
"SQL_command": "select * from BIMP.Project_Information where Element_id = 'Test_projectN1';"
}
9. Use the SQL command: "INSERT"
POST : http://140.118.121.110:30600/sql_insert
Rule: Body -> raw -> json
Parameters:
{
"SQL_command" : "insert into TEST.test(Project_id, Project_user_id, Object_id, Element_id, Element_location, Element_parameters, Label_name, Label)values('Test_project', 'Susanwu', 'susanwu20201215151615251353', 'HJPN1', '[0.99849714986386384, -0.054803665148789531, 0.0, 0.0, 0.054803665148789531, 0.99849714986386384,0.0, 0.0, 0.0, 0.0, 1.0, 2100.0, 0.0, 0.0, 0.0, 1.0 ]', '[ Panel Length1: 600.0, Panel Length2: 600.0, Panel Thickness: 10.0, Control Ratio: 0.1, Hole Radius: 20.0, Material Option: 0]', '[Object, Color, Owner]', '[Object_D, Red, Susan1]')"
}
10. Use the SQL command: "UPDATE"
POST : http://140.118.121.110:30600/sql_update
Rule: Body -> raw -> json
Parameters:
{
"SQL_command" : "Update TEST.test set Project_user_id = '11', Element_id = '11' where Project_id = '1';"
}
11. Use the SQL command: "DELETE"
POST : http://140.118.121.110:30600/sql_delete
Rule: Body -> raw -> json
Parameters:
{
"SQL_command" : "delete from TEST.test where Project_id = '1';"
}
editor editor HJ 2021/07/08