# <center>2nd Week</center>
---
## Monday, July 8th 2019
[IOTA Full Node Installation wiki](https://iri-playbook.readthedocs.io/en/master/)
Discussion with Mr.Denny:
>- what happen if the storage of bitcoin is full?
>- what happen if the storage of IOTA is full?
>- what the Light node do, what the Full node do?
>This week target:
>1. test build a light node in a VM 1st
>2. Implement it to Raspberry Pi
Discussion build light node with IOTA expert in Discord:
>we can use these libs to communicate to any IOTA node and You don't need to use your own
>we can running nodes from home/internal network
https://docs.iota.org/docs/client-libraries/0.1/introduction/overview
https://patriq.gitbook.io/iota/
**Chat Log** [here](https://hackmd.io/o72J17fORGCfZNrgtqmtSA)
---
Problem to build a full node:
- need a Virtual Private Server (which can buy or by build own VPS with high cost)
- 24/7 machine running
- Highspeed Network and High specs of computer
---
### IOTA Seed
Seed is the combination of 81 Characters of Trytes which work as the username and password of an account of IOTA. This is the example of Seed:
**LZQOPWMHGGGDBDGWRKABFSARXDBSNPAWK9FYFZK0DVEWVNPKLQXNTUOKBCBQTLGUENHZDVKLNIZKMNGOL**
The Seed should never be exposed, and in order to receive or send tokens you never need to disclose it to anyone. During a transaction, your seed is not transmitted anywhere.
It could be generated by Trinity Wallet or generate by online seed generator, but its need to turn off internet connection while generating for better security. Once generated it should be saved in the
By using Linux
```cat /dev/urandom |tr -dc A-Z9|head -c${1:-81}```
By using Mac
```cat /dev/urandom |LC_ALL=C tr -dc 'A-Z9' | fold -w 81 | head -n 1```
---
**Trinity Wallet**
1. Choose need a seed for new user

2. Generate Seed

3. Account Name

4. Back Up Your Seed - Choose Print paper copy and save it to PDF (for easy usage) or Export SeedVault for easy drag and drop file (remember to make a safe key)-

5. Enter the generated Seed before
If you use SeedVault before just drag and drop the file to here

6. Create wallet password
7. Done

---
**Configure and install the iota swarm node in local virtual machine**
[iota-swarm-node configuration](https://github.com/yillkid/iota-swarm-node)
Result: the configuration was failed due to uncompleted program/file in the github itself
---
## Tuesday, July 9th 2019
### Vagrant
Vagrant is a tool for building and managing virtual machine environments in a single workflow. Its help to build development evironment easily and lower the setup time
By Vagrant, The OS, Database, and required installment can be done with few of command because of automation
Vagrant "Box" is a packet format for Vagrant Environment. Box is the technology stack wrapper with all its configurations.
It contained various OS, Programming Language, server and database. Such Laravel Homestead(Laravel + Nginx etc) and Scocth Box (LAMP Stack + Node JS + MongoDB etc)
Vagrant goal is to solve the problem of different environment of production and development
>it works on my machine but doesn't work on production or itw works on my machine it doesn't work on the other developers machine that happens because somewhere there's might be on a different OS, like the main machine is Mac or Windows and pushing to Linux server which can cause problem
The Vagrant provisioning script is going to set up the differences between staging server or production server and the virtual machine to have a same environment such version or any software that need to be configured
So when the project code works on VM, it pretty much will works on the production environment (github, stage, production)
---
### Docker
Docker is a tool which used to automate the deployment of application lightweight containers so that applications can work efficiently in different environment
**How Docker Works**
Docker uses Client/Server Architecture communicate with REST API
Docker Client is a service which run commands. The one who install the docker product. The commands is translated using REST API and send to Docker Diamon.
Dokcer Diamon is the server that check the client request and interact with operating system in order to create or manage containers.
#### Docker vs Virtual Machine

| Criteria | Virtual Machine | Docker |
| -------- | -------- | -------- |
| OS Support | Occupies a lot of memory space | Docker Containers Occupy less space |
| Boot-Up time | Long | Short |
| Performance | Running multiple virtual Machine leads to unstable performance | Containers |
| Scaling | Difficult to Scale Up| Easy to Scale Up |
| Efficiency | Low | High |
| Portability | Compatibility issues while porting across different platform | Easily portable across different platforms |
| Space Allocation | Data Volumes cannot be shared | Data volumes can be shared and reused among multiple containers |
### Bitcoin Issue
**51% attack**
51% attack is an attack by specific group or person who can do a 51% hashing power than everybody else.
Impact:
- Double Spending, The transaction that being has can be done publicly and privately. The longest chain will announce publicly to bitcoin with the entire cost that has been used for the chain and bitcoin will pay it, but the other hand because of the 51% faster and powerful hashing it can be done by rpivately with longer chain and after that publish to the bitcoin network and network surely will accept the chain and got the fee again.
- Monopoly of mining, others miner drop out because the person can mine all the future blocks and get all the block rewards then the others miners out of business. In the future, It will become 60% and keep increasing due to less competitors
## Wednesday, July 10th 2019
Weekly Report Presentation at 09:20 AM - 11:30
Presentation: [Slides](https://drive.google.com/file/d/1SY5yAob0NgVLA1ccONniAjA6wZb3naHB/view?usp=sharing)
Discussion with Professor RT Wang about cloud server at 11:30-12:00
Result:
- Virtual Server in cloud with Public IP Address
- Implement it to raspberry Pi
- Try Improvised the IOTA technology after implementation
- Prepare a Resume/CV
Learning the Cloud environment
- CentOS command
Learning about software parts by using arduino and raspberry Pi
[Raspberry Pi](https://www.mobilefish.com/developer/iota/iota_quickguide_raspi_mam.html)
[Arduino](https://www.mobilefish.com/developer/iota/iota_quickguide_arduino_mam.html)
## Thursday, July 11th 2019
### Node.js
What is Node.js
>Node.js is an opensource server environment that runs on various platform (Windows, Linux, Unix, Mac, etc.). Node.js uses JavaScript on the server
>
>A common task for a web server can be to open a file on the server and return the content to the client.
>Node.js eliminates the waiting, and simply continues with the next request. It runs single-threaded, non-blocking, asynchronously programming, which is very memory efficient.
What can Node.js do?
>Node.js can generate dynamic page content.
>Node.js can create, open, read, write, delete, and close files on the server
>Node.js can collect form data
>Node.js can add, delete, modify data in your database
How Node.js handles a file request?
>1. Sends the task to the computer's file system
>2. Ready to handle the next request
>3. When the file system has opened and read the file, the server returns the content to the client.
Create Raspberry Pi VM in Virtual Box
>The real device is still on the way, so simulate and modify the software part in VM
Make sure your virtual box is having 64bit Debian. if there is no 64-bit, go to options “turn windows feature on or off” and uncheck the Hyper-V, restart it or [look this](https://www.youtube.com/watch?v=2Kg2GDzee-0)
1. Download The Raspbian Image
https://www.raspberrypi.org/downloads/raspberry-pi-desktop/

2. Create New Virtual Machine

3. Choose Memory size 512 or 1024

4. Just click Next till the window finish
5. Click settings on the raspy VM

6. Choose Storage and click on the Disc Icon and Click “Choose Virtual Optical Disk File”

7. Search for the Raspbian image that have been downloaded before and click “OK”

8. Launch the Raspbian Virtual Machine
Choose Install

9. Partition Disk




Choose “Yes” Write to changes disk

Install the GRUB

Choose /dev/sda to automatically installation

The installation done

If the Window Prompt update just press update or next

**Rapberry Pi Terminal**
1. Install Node
```
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v
```


2. build the BCM2835 library in the Raspberry Pi for communication with DHT11 temperature sensor module.
`wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.56.tar.gz
tar zxvf bcm2835-1.56.tar.gz
cd bcm2835-1.56
./configure
make
sudo make check
sudo make install`


3. Install git
```sudo apt-get install git```
4. Install DHT11 project from github
`cd ~
git clone https://github.com/robertlie/dht11-raspi3.git
cd dht11-raspi3
npm install`

5. a. There is missing repository in the package.json

b. Fixed the missing repository in the package.json


6. Error when publishing MAM

Tomorrow Plan: Fixing the error
## Friday, July 12th 2019
By newest references of Raspberry Pi to Publish transaction to IOTA
This tutorial can use for any raspberry pi, just modify the program in temp.py
Start From the raspberry terminal
1. install the node and git
2. Clone repository
`git clone https://github.com/iota-community/raspberrypi-pubsub`
3. Change into the raspberrypi-pubsub directory
`cd raspberrypi-pubsub`
4. Install the dependencies
`npm install`
5. Modify the code
> - file temp.py
> 
> - Index.js
> if Error
> 
> At IOTA API, Change from “ https://nodes.devnet.iota.org:443/ “
> 
> To “https://nodes.devnet.thetangle.org:443/” or the other active tangle node
> 
> **Optional** Change the IOTA Seed with your own seed that has been generated in trinity wallet or etc.
> 
6. Run the node to publish
`node index.js`
If successful

7. Check the transaction on the devnet tangle, copy the target address and paste it into the search bar of the devnet explorer

You can check, Do the transaction is yours or not by matching the tag and bundle.
8. The tangle visualization

The transaction just verify 1 because "both referenced hashes are the same, so it’s only one transaction. Both tips are chosen independently from each other. If the tip pool is not that big the chances are not that low to get the same tip for branch and trunk."
Fully explanation of source code
https://github.com/vincentsanjaya/raspberrypi_iota.git