From 03162fa64da5a5db317a0471e588259d66f1315d Mon Sep 17 00:00:00 2001
From: cubedro <contact@siteshop.ro>
Date: Thu, 2 Apr 2015 18:44:36 +0300
Subject: [PATCH 1/4] pm2 json refactoring

---
 processes.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/processes.json b/processes.json
index c6489b0..875130f 100644
--- a/processes.json
+++ b/processes.json
@@ -3,10 +3,11 @@
 		"name"						: "eth",
 		"cwd"						: "/home/ubuntu/bin/www/",
 		"script"					: "bin/eth.sh",
+		"log_date_format"			: "YYYY-MM-DD HH:mm Z",
 		"log_file"					: "/home/ubuntu/logs/eth-log.log",
 		"out_file"					: "/home/ubuntu/logs/eth-out.log",
 		"error_file"				: "/home/ubuntu/logs/eth-err.log",
-		"merge_logs"				: true,
+		"merge_logs"				: false,
 		"watch"						: false,
 		"cron_restart"				: "0 0 * * *",
 		"exec_interpreter"			: "bash",
@@ -21,7 +22,6 @@
 		"error_file"				: "/home/ubuntu/logs/node-app-err.log",
 		"merge_logs"				: true,
 		"watch"						: false,
-		// "cron_restart"				: "0 0 * * *",
 		"exec_interpreter"			: "node",
 		"exec_mode"					: "fork_mode",
 		"env":

From 23750fcff4193debdd5f04427290661bbef1210d Mon Sep 17 00:00:00 2001
From: cubedro <contact@siteshop.ro>
Date: Thu, 2 Apr 2015 18:58:53 +0300
Subject: [PATCH 2/4] updated propagation time

---
 lib/node.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/node.js b/lib/node.js
index cea4b4c..d5bda0c 100644
--- a/lib/node.js
+++ b/lib/node.js
@@ -183,7 +183,7 @@ Node.prototype.getBlock = function(number)
 
 	try {
 		block = web3.eth.getBlock(number, true);
-		block.arrival = Date.now();
+		block.arrival = (new Date()).getTime();
 		block.propagation = block.arrival - (block.timestamp * 1000);
 
 		if(block.hash != '?' && typeof block.difficulty !== 'undefined')

From 716f2838aeeae41f3494f5540643a67569633eaf Mon Sep 17 00:00:00 2001
From: cubedro <contact@siteshop.ro>
Date: Thu, 2 Apr 2015 21:11:55 +0300
Subject: [PATCH 3/4] added time update to build shells

---
 bin/build-go.sh | 11 ++++++++++-
 bin/build.sh    | 10 +++++++++-
 bin/eth.sh      |  2 +-
 lib/node.js     | 20 ++++++++++----------
 4 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/bin/build-go.sh b/bin/build-go.sh
index 1a66ea2..61a70d5 100644
--- a/bin/build-go.sh
+++ b/bin/build-go.sh
@@ -3,7 +3,7 @@
 # update repository & install dependencies
 sudo apt-get update -y
 sudo apt-get upgrade -y
-sudo apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev nodejs npm
+sudo apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev nodejs npm ntp
 
 # add ethereum repos
 sudo add-apt-repository -y ppa:ethereum/ethereum-qt
@@ -29,3 +29,12 @@ npm install
 npm install pm2 -g
 
 cp -b ./processes-go.json ./../processes.json
+
+# set up time update cronjob
+cat > /etc/cron.hourly/ntpdate << EOF
+#!/bin/sh
+sudo service ntp stop
+sudo ntpdate -s ntp.ubuntu.com
+sudo service ntp start
+EOF
+sudo chmod 755 /etc/cron.hourly/ntpdate
diff --git a/bin/build.sh b/bin/build.sh
index cefe98f..d0f4f53 100644
--- a/bin/build.sh
+++ b/bin/build.sh
@@ -16,7 +16,7 @@ sudo add-apt-repository -y ppa:ethereum/ethereum-dev
 sudo apt-get -y update
 sudo apt-get -y upgrade
 
-sudo apt-get -y install build-essential g++-4.8 git cmake libboost-all-dev automake unzip libgmp-dev libtool libleveldb-dev yasm libminiupnpc-dev libreadline-dev scons libncurses5-dev libcurl4-openssl-dev wget qtbase5-dev qt5-default qtdeclarative5-dev libqt5webkit5-dev libcryptopp-dev libjson-rpc-cpp-dev libmicrohttpd-dev libjsoncpp-dev libargtable2-dev clang-3.5 lldb-3.5 nodejs npm
+sudo apt-get -y install build-essential g++-4.8 git cmake libboost-all-dev automake unzip libgmp-dev libtool libleveldb-dev yasm libminiupnpc-dev libreadline-dev scons libncurses5-dev libcurl4-openssl-dev wget qtbase5-dev qt5-default qtdeclarative5-dev libqt5webkit5-dev libcryptopp-dev libjson-rpc-cpp-dev libmicrohttpd-dev libjsoncpp-dev libargtable2-dev clang-3.5 lldb-3.5 nodejs npm ntp
 
 # add node symlink
 sudo ln -s /usr/bin/nodejs /usr/bin/node
@@ -55,3 +55,11 @@ npm install
 npm install pm2 -g
 
 cp -b ./processes.json ./..
+# set up time update cronjob
+cat > /etc/cron.hourly/ntpdate << EOF
+#!/bin/sh
+sudo service ntp stop
+sudo ntpdate -s ntp.ubuntu.com
+sudo service ntp start
+EOF
+sudo chmod 755 /etc/cron.hourly/ntpdate
diff --git a/bin/eth.sh b/bin/eth.sh
index 6bd399b..14bc8ae 100644
--- a/bin/eth.sh
+++ b/bin/eth.sh
@@ -2,7 +2,7 @@
 trap "exit" INT
 if [ -f /usr/bin/ethereum ]
 then
-	ethereum -rpc true
+	geth --rpc true
 else
 	eth -x 15 -l 30303 -n off -m off -v 1 -j
 fi
\ No newline at end of file
diff --git a/lib/node.js b/lib/node.js
index d5bda0c..95a5b05 100644
--- a/lib/node.js
+++ b/lib/node.js
@@ -100,7 +100,7 @@ function Node()
 		console.error('Socket connection closed');
 	})
 	.on('error', function error(err) {
-		console.error(err);
+		console.error("socket:", err);
 	})
 	.on('reconnecting', function reconnecting(opts) {
 		console.warn('We are scheduling a reconnect operation', opts);
@@ -143,7 +143,7 @@ Node.prototype.isActive = function()
 			code: '1',
 			msg: err
 		});
-		console.error(err);
+		console.error("peerCount:", err);
 	}
 
 	this.stats.active = false;
@@ -177,7 +177,7 @@ Node.prototype.getBlock = function(number)
 				code: '3',
 				msg: err
 			});
-			console.error(err);
+			console.error("blockNumber:", err);
 		}
 	}
 
@@ -196,7 +196,7 @@ Node.prototype.getBlock = function(number)
 			code: '2',
 			msg: err
 		});
-		console.error(err);
+		console.error("getBlock:", err);
 	}
 
 	return block;
@@ -307,11 +307,11 @@ Node.prototype.getStats = function()
 		if(this.stats.block.number > 0)
 			this.getLatestBlocks();
 
-		try {
-			this.stats.pending = web3.eth.getBlockTransactionCount('pending');
-		} catch (err) {
-			console.error(err);
-		}
+		// try {
+		// 	this.stats.pending = web3.eth.getBlockTransactionCount('pending');
+		// } catch (err) {
+		// 	console.error("getBlockTransactionCount('pending'):", err);
+		// }
 		this.stats.mining = web3.eth.mining;
 		this.stats.gasPrice = web3.eth.gasPrice.toString(10);
 		this.stats.listening = web3.net.listening;
@@ -392,7 +392,7 @@ Node.prototype.emit = function(message, payload)
 			socket.emit(message, payload);
 		}
 		catch (err) {
-			console.error(err);
+			console.error("socket.emit:", err);
 		}
 	}
 }

From 3cc54ee9ef1965dd0be0f7ebd0fb9649f8689a30 Mon Sep 17 00:00:00 2001
From: cubedro <contact@siteshop.ro>
Date: Thu, 2 Apr 2015 23:52:55 +0300
Subject: [PATCH 4/4] added back pending transactions

---
 lib/node.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/node.js b/lib/node.js
index 95a5b05..71b5b41 100644
--- a/lib/node.js
+++ b/lib/node.js
@@ -307,11 +307,11 @@ Node.prototype.getStats = function()
 		if(this.stats.block.number > 0)
 			this.getLatestBlocks();
 
-		// try {
-		// 	this.stats.pending = web3.eth.getBlockTransactionCount('pending');
-		// } catch (err) {
-		// 	console.error("getBlockTransactionCount('pending'):", err);
-		// }
+		try {
+			this.stats.pending = web3.eth.getBlockTransactionCount('pending');
+		} catch (err) {
+			console.error("getBlockTransactionCount('pending'):", err);
+		}
 		this.stats.mining = web3.eth.mining;
 		this.stats.gasPrice = web3.eth.gasPrice.toString(10);
 		this.stats.listening = web3.net.listening;