From 163d506c4cdcb08e14505dfc4286269d9886a8c0 Mon Sep 17 00:00:00 2001
From: Robert Martin-Legene <robert@nic.ar>
Date: Fri, 27 Sep 2019 17:19:17 -0300
Subject: [PATCH] Primeros cambios para cambiar para utilizar ipc en lugar de
 RPC

---
 bin/libbfa.js            | 6 ++++--
 bin/libbfa.sh            | 2 +-
 network/config.toml      | 4 ++--
 test2network/config.toml | 4 ++--
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/bin/libbfa.js b/bin/libbfa.js
index 6cdd2e9..02a7aeb 100644
--- a/bin/libbfa.js
+++ b/bin/libbfa.js
@@ -9,6 +9,7 @@ module.exports = class Libbfa
     constructor() {
         this.fs                         =   require('fs');
         this.Web3                       =   require('web3');
+        var     net                     =   require('net');
         //
         // BFAHOME
         if ( undefined == process.env.BFAHOME )
@@ -47,6 +48,8 @@ module.exports = class Libbfa
         //
         this.netport                    =   Number.parseInt( this.setfromfile( this.nodedir+'/netport', 30303 ));
         this.rpcport                    =   Number.parseInt( this.setfromfile( this.nodedir+'/rpcport',  8545 ));
+        //this.provider                 =   'http://127.0.0.1:' + this.rpcport; // old
+        this.provider                   =   new this.Web3.providers.IpcProvider(this.nodedir+'/geth.ipc', net)
         this.account                    =   process.env.BFAACCOUNT;
     }
 
@@ -78,8 +81,7 @@ module.exports = class Libbfa
 
     newweb3()
     {
-        var     provider        =   'http://127.0.0.1:' + this.rpcport;
-        var     w3              =   new this.Web3( provider );
+        var     w3              =   new this.Web3( this.provider );
         w3.rpcreq               =   function( opname, params, callback )
         {
             var     extra       =   params.join(',');
diff --git a/bin/libbfa.sh b/bin/libbfa.sh
index c451c55..6ee139d 100644
--- a/bin/libbfa.sh
+++ b/bin/libbfa.sh
@@ -194,7 +194,7 @@ test    -n "$BFANODEDIR"        ||  BFANODEDIR="${BFANETWORKDIR}/node"
 if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
 then
     echo "Node is not initialised. Initialising with genesis."
-    geth --cache 0 --datadir "${BFANODEDIR}" init "${BFANETWORKDIR}/genesis.json"
+    geth --cache 0 --datadir "${BFANODEDIR}" --networkid ${BFANETWORKID} init "${BFANETWORKDIR}/genesis.json"
 fi
 #
 # netport
diff --git a/network/config.toml b/network/config.toml
index a414c48..3c85b8b 100644
--- a/network/config.toml
+++ b/network/config.toml
@@ -60,10 +60,10 @@ omitempty = ""
 IPCPath = "geth.ipc"
 HTTPPort = 8545
 HTTPVirtualHosts = ["localhost"]
-HTTPModules = ["net", "web3", "eth", "shh", "clique", "admin", "miner", "personal"]
+HTTPModules = ["net", "web3", "eth", "clique"]
 WSHost = "127.0.0.1"
 WSPort = 8546
-WSModules = ["net", "web3", "eth", "shh", "clique", "admin", "miner", "personal"]
+WSModules = ["net", "web3", "eth", "clique"]
 GraphQLPort = 8547
 GraphQLVirtualHosts = ["localhost"]
 
diff --git a/test2network/config.toml b/test2network/config.toml
index e94490c..31d7a61 100644
--- a/test2network/config.toml
+++ b/test2network/config.toml
@@ -60,10 +60,10 @@ omitempty = ""
 IPCPath = "geth.ipc"
 HTTPPort = 8545
 HTTPVirtualHosts = ["localhost"]
-HTTPModules = ["net", "web3", "eth", "shh", "clique", "admin", "miner", "personal"]
+HTTPModules = ["net", "web3", "eth", "clique"]
 WSHost = "127.0.0.1"
 WSPort = 8546
-WSModules = ["net", "web3", "eth", "shh", "clique", "admin", "miner", "personal"]
+WSModules = ["net", "web3", "eth", "clique"]
 GraphQLPort = 8547
 GraphQLVirtualHosts = ["localhost"]
 
-- 
GitLab