Compare commits

..

5 Commits

Author SHA1 Message Date
Ori Newman
a32a9011c7 [NOD-1305] Close client connection on disconnect (#909) 2020-08-31 15:57:11 +03:00
stasatdaglabs
5da957f16e Update to version 0.6.8 2020-08-30 11:31:43 +03:00
Ori Newman
505d264603 [NOD-1322] Fix compilation on windows (#905) 2020-08-27 18:04:54 +03:00
Ori Newman
883361fea3 [NOD-1323] Always save new block reachability data (#906) 2020-08-27 18:03:50 +03:00
stasatdaglabs
13a6872a45 Update to version 0.6.7 2020-08-26 12:13:43 +03:00
7 changed files with 30 additions and 24 deletions

View File

@@ -1,10 +1,10 @@
package ping
import (
"github.com/kaspanet/kaspad/app/protocol/common"
"time"
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/protocol/common"
peerpkg "github.com/kaspanet/kaspad/app/protocol/peer"
"github.com/kaspanet/kaspad/app/protocol/protocolerrors"
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"

View File

@@ -268,6 +268,9 @@ func (rtn *reachabilityTreeNode) addChild(child *reachabilityTreeNode, reindexRo
rtn.children = append(rtn.children, child)
child.parent = rtn
modifiedNodes[rtn] = struct{}{}
modifiedNodes[child] = struct{}{}
// Temporarily set the child's interval to be empty, at
// the start of rtn's remaining interval. This is done
// so that child-of-rtn checks (e.g.
@@ -312,8 +315,6 @@ func (rtn *reachabilityTreeNode) addChild(child *reachabilityTreeNode, reindexRo
return err
}
child.interval = allocated
modifiedNodes[rtn] = struct{}{}
modifiedNodes[child] = struct{}{}
return nil
}

View File

@@ -13,11 +13,11 @@ import (
)
type gRPCConnection struct {
server *gRPCServer
address *net.TCPAddr
isOutbound bool
stream grpcStream
router *router.Router
server *gRPCServer
address *net.TCPAddr
stream grpcStream
router *router.Router
lowLevelClientConnection *grpc.ClientConn
// streamLock protects concurrent access to stream.
// Note that it's an RWMutex. Despite what the name
@@ -34,14 +34,16 @@ type gRPCConnection struct {
isConnected uint32
}
func newConnection(server *gRPCServer, address *net.TCPAddr, isOutbound bool, stream grpcStream) *gRPCConnection {
func newConnection(server *gRPCServer, address *net.TCPAddr, stream grpcStream,
lowLevelClientConnection *grpc.ClientConn) *gRPCConnection {
connection := &gRPCConnection{
server: server,
address: address,
isOutbound: isOutbound,
stream: stream,
stopChan: make(chan struct{}),
isConnected: 1,
server: server,
address: address,
stream: stream,
stopChan: make(chan struct{}),
isConnected: 1,
lowLevelClientConnection: lowLevelClientConnection,
}
return connection
@@ -83,7 +85,7 @@ func (c *gRPCConnection) SetOnInvalidMessageHandler(onInvalidMessageHandler serv
}
func (c *gRPCConnection) IsOutbound() bool {
return c.isOutbound
return c.lowLevelClientConnection != nil
}
// Disconnect disconnects the connection
@@ -98,7 +100,7 @@ func (c *gRPCConnection) Disconnect() {
close(c.stopChan)
if c.isOutbound {
if c.IsOutbound() {
c.closeSend()
log.Debugf("Disconnected from %s", c)
}
@@ -138,5 +140,8 @@ func (c *gRPCConnection) closeSend() {
defer c.streamLock.Unlock()
clientStream := c.stream.(protowire.P2P_MessageStreamClient)
_ = clientStream.CloseSend() // ignore error because we don't really know what's the status of the connection
// ignore error because we don't really know what's the status of the connection
_ = clientStream.CloseSend()
_ = c.lowLevelClientConnection.Close()
}

View File

@@ -90,12 +90,12 @@ func (s *gRPCServer) Connect(address string) (server.Connection, error) {
ctx, cancel := context.WithTimeout(context.Background(), dialTimeout)
defer cancel()
gRPCConnection, err := grpc.DialContext(ctx, address, grpc.WithInsecure(), grpc.WithBlock())
gRPCClientConnection, err := grpc.DialContext(ctx, address, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
return nil, errors.Wrapf(err, "error connecting to %s", address)
}
client := protowire.NewP2PClient(gRPCConnection)
client := protowire.NewP2PClient(gRPCClientConnection)
stream, err := client.MessageStream(context.Background(), grpc.UseCompressor(gzip.Name))
if err != nil {
return nil, errors.Wrapf(err, "error getting client stream for %s", address)
@@ -110,7 +110,7 @@ func (s *gRPCServer) Connect(address string) (server.Connection, error) {
return nil, errors.Errorf("non-tcp addresses are not supported")
}
connection := newConnection(s, tcpAddress, true, stream)
connection := newConnection(s, tcpAddress, stream, gRPCClientConnection)
err = s.onConnectedHandler(connection)
if err != nil {

View File

@@ -29,7 +29,7 @@ func (p *p2pServer) MessageStream(stream protowire.P2P_MessageStreamServer) erro
return errors.Errorf("non-tcp connections are not supported")
}
connection := newConnection(p.server, tcpAddress, false, stream)
connection := newConnection(p.server, tcpAddress, stream, nil)
err := p.server.onConnectedHandler(connection)
if err != nil {

View File

@@ -68,7 +68,7 @@ func (s *kaspadService) Execute(args []string, r <-chan svc.ChangeRequest, chang
// be properly logged
doneChan := make(chan error)
startedChan := make(chan struct{})
spawn(func() {
spawn("kaspadMain-windows", func() {
err := kaspadMain(startedChan)
doneChan <- err
})

View File

@@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
const (
appMajor uint = 0
appMinor uint = 6
appPatch uint = 6
appPatch uint = 8
)
// appBuild is defined as a variable so it can be overridden during the build