From 9b2c97a5f909b9a7bd52347b019b7b35256c45df Mon Sep 17 00:00:00 2001 From: Berk Gokden Date: Tue, 10 Aug 2021 16:09:51 +0200 Subject: [PATCH] Add logs, remove conn block, increase max procs --- node/node.go | 3 ++- node/nodeservice.go | 2 +- util/connpool.go | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/node/node.go b/node/node.go index 1e40dad..5b85666 100644 --- a/node/node.go +++ b/node/node.go @@ -17,7 +17,7 @@ import ( data "github.com/bgokden/veri/data" ) -const MINGOMAXPROCS = 32 +const MINGOMAXPROCS = 128 func GetIdOfPeer(p *pb.Peer) string { return SerializeStringArray(p.GetAddressList()) @@ -262,6 +262,7 @@ func (n *Node) SyncWithPeers() { } } state.Ready = true + log.Printf("Synced with peers") // fmt.Println(n.Info()) } diff --git a/node/nodeservice.go b/node/nodeservice.go index c81b82a..753ab84 100644 --- a/node/nodeservice.go +++ b/node/nodeservice.go @@ -179,7 +179,6 @@ func (n *Node) SendJoinRequest(id string) error { } // This is a speacial case that doesn't use connection pool conn, err := grpc.Dial(id, - grpc.WithBlock(), grpc.WithInsecure(), grpc.WithTimeout(time.Duration(1000)*time.Millisecond), ) @@ -187,6 +186,7 @@ func (n *Node) SendJoinRequest(id string) error { return err } if conn == nil { + log.Printf("Failed Join request to %v", id) return errors.New("Connection failure") } defer conn.Close() diff --git a/util/connpool.go b/util/connpool.go index 01e20f6..6dd57c9 100644 --- a/util/connpool.go +++ b/util/connpool.go @@ -101,7 +101,6 @@ func (cp *ConnectionPool) NewConnection(address string) *Connection { return nil } conn, err := grpc.Dial(address, - grpc.WithBlock(), grpc.WithInsecure(), grpc.WithTimeout(time.Duration(200)*time.Millisecond), ) @@ -141,7 +140,7 @@ func (cp *ConnectionPool) GetWithRetry(count int) *Connection { } if conn, ok := connectionInterface.(*Connection); ok { if conn != nil && conn.Conn != nil { - if conn.Conn.GetState() == connectivity.Ready { + if conn.Conn.GetState() == connectivity.Ready || conn.Conn.GetState() == connectivity.Connecting { return conn } else { err := conn.Conn.Close()