Vinoblock: Implementation

Connect and run the costaflores global vineyard node

First of all we'll create a new directory in the /home/pi/ path to allocate all the files related to the node:

pi$ mkdir node && cd node

 

Once we are in the node directory we create an ethereum account using the geth client and following the instructions:

pi$ geth account new —-datadir . ... WARN [07-26|12:46:35.692] Sanitizing cache to Go's GC limits       provided=1024 updated=308 INFO [07-26|12:46:35.698] Maximum peer count                       ETH=25 LES=0 total=25 Your new account is locked with a password. Please give a password. Do not forget this password. Passphrase: **** Repeat passphrase: **** Address: {5f68298dd10e8ea45d64d973c8d90c3b60215e64} ...

 

In our case, the public address of the account generated is 5f68298dd10e8ea45d64d973c8d90c3b60215e64, it is important to copy this address somewhere because it will be used in the future to set up the running node. Once we have our account created we can initialise our node, to do so we will need the genesis file which will be provided by the openvino admin. Once we have it:

computer$ scp genesis.json pi@"ip of your raspberry":/home/pi/node/

 

To initialise the geth node we have to:

 

Once the node is initialised have to create a file with the description of the nodes it is going to be paired with. In our case, this file will be, once again, provided by the admins, so:

 

Now that we have all the necessary files, we can proceed to create and script that runs the node. 

 

Run.sh

(The missing information (1 and 2) will be given by the admins as they are private for our network)

 

 

Finally when this file is created we can check it by using the following command, I personally recommend to run this command during the first full synchronisation to check if it is working properly:

 

Once the node has already synchronised we can set up a systemctl service that runs on boot creating a ethereum-node.service file in /etc/systemd/system/ with this content:

 

ethereum-node.service

 

Finally now we just have to reload the daemon list and to test and enable it to run on boot using this commands:

 

Download Vinoblock package

To ease the installation we've packed some files in a github repository for you to download all the source files. To download and place it all in a proper hierarchy you can:

Create database tables and events

We'll now create the local database that will store a 1 day copy of the database so that it can be used for displaying purposes. This database will be formed by a basic table containing information gathered frequently and a table containing it's daily information. To create this tables we will:

 

Once this commands have been executed the tables will be created and a user named system too. Remember that the user is being created with the password 'raspberry' for testing purposes, in case you want to change it you can modify user creation command to fit your password.

Downloading and executing the app

With the database and the blockchain node working we have accomplished all the prerequisites to run the background app that will display data through the lcd 16x02 display. The python code packages for this purpose has been uploaded to: GitHub - jestape/vinoblock-package: Costaflores Global Vineyard node implementation . So we'll just have to:

(In case you have changed the system database user password you must modify the password parameter of line 10 in main.py)

 

Great! If you have connected everything properly your lcd 16x02 display should giving you some cool data to play with. It will be also sending this data to the costaflores private blockchain for auditing purposes and storing it in the database so that you can monitor it. So, now let's make it work on boot:

 

app.service

 

Finally now we just have to reload the daemon list and to test and enable it to run on boot using this commands:

 

Initialise and implement nodered front-end

Finally we have to set up our front-end web page that will allow us to see the dashboard of the data collected and control the raspberry pi via UI. This will be done via web browser so firstly you'll have to open a web browser and search: "http://"ip of your raspberry":1880. The following screen will appear:

 

Firstly we'll install some node-red extra packages that our platform is going to use, to do so we'll have to open the right top menu button and click onto the manage palette option:

 

A pop up screen will appear, there we'll have to go to the tab install and search and install the following packages:

 

We recomend you to wait for several minutes for packages to get installed. Once this is done we have to open the menu again, the import option and inside it the clipboard one. This will display the following screens/popup:

 

In this screen we have to copy paste the following code:

flow.json

 

Once we've added the code we can click onto import and it will automatically generate 3 flows for us. Now we just have to click onto deploy (top right corner) and check the result at: http://"your raspberry ip":1880/ui