Skip to content

Commit

Permalink
Merge pull request #101 from bgokden/develop
Browse files Browse the repository at this point in the history
Add logs, remove conn block, increase max procs
  • Loading branch information
bgokden committed Aug 10, 2021
2 parents 66937aa + 9b2c97a commit fc8371c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -262,6 +262,7 @@ func (n *Node) SyncWithPeers() {
}
}
state.Ready = true
log.Printf("Synced with peers")
// fmt.Println(n.Info())
}

Expand Down
2 changes: 1 addition & 1 deletion node/nodeservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ 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),
)
if err != nil {
return err
}
if conn == nil {
log.Printf("Failed Join request to %v", id)
return errors.New("Connection failure")
}
defer conn.Close()
Expand Down
3 changes: 1 addition & 2 deletions util/connpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit fc8371c

Please sign in to comment.