Compare commits

...

3 Commits

Author SHA1 Message Date
stasatdaglabs
b55cfee8c8 [NOD-1229] Fix node crashing if AntiPastHashesBetween lowHigh or highHash are not found in the DAG (#849)
* [NOD-1229] Fix node crashing if AntiPastHashesBetween lowHigh or highHash are not found in the DAG

* [NOD-1229] Rename InvalidParameterError to ErrInvalidParameter.

* [NOD-1229] Lowercasify errors.
2020-08-09 09:36:29 +03:00
stasatdaglabs
420c3d4258 [NOD-1222] Turn on gzip in gRPC. (#850) 2020-08-06 17:28:40 +03:00
Mike Zak
b92943a98c Update to version v0.6.1 2020-08-06 15:16:05 +03:00
5 changed files with 15 additions and 5 deletions

View File

@@ -1851,14 +1851,14 @@ func (dag *BlockDAG) antiPastHashesBetween(lowHash, highHash *daghash.Hash, maxH
func (dag *BlockDAG) antiPastBetween(lowHash, highHash *daghash.Hash, maxEntries uint64) ([]*blockNode, error) {
lowNode, ok := dag.index.LookupNode(lowHash)
if !ok {
return nil, errors.Errorf("Couldn't find low hash %s", lowHash)
return nil, errors.Wrapf(ErrInvalidParameter, "couldn't find low hash %s", lowHash)
}
highNode, ok := dag.index.LookupNode(highHash)
if !ok {
return nil, errors.Errorf("Couldn't find high hash %s", highHash)
return nil, errors.Wrapf(ErrInvalidParameter, "couldn't find high hash %s", highHash)
}
if lowNode.blueScore >= highNode.blueScore {
return nil, errors.Errorf("Low hash blueScore >= high hash blueScore (%d >= %d)",
return nil, errors.Wrapf(ErrInvalidParameter, "low hash blueScore >= high hash blueScore (%d >= %d)",
lowNode.blueScore, highNode.blueScore)
}

View File

@@ -287,3 +287,7 @@ func (e RuleError) Error() string {
func ruleError(c ErrorCode, desc string) error {
return errors.WithStack(RuleError{ErrorCode: c, Description: desc})
}
// ErrInvalidParameter signifies that an invalid parameter has been
// supplied to one of the BlockDAG functions.
var ErrInvalidParameter = errors.New("invalid parameter")

View File

@@ -3,6 +3,7 @@ package grpcserver
import (
"context"
"fmt"
"google.golang.org/grpc/encoding/gzip"
"net"
"time"
@@ -87,7 +88,7 @@ func (s *gRPCServer) Connect(address string) (server.Connection, error) {
}
client := protowire.NewP2PClient(gRPCConnection)
stream, err := client.MessageStream(context.Background())
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)
}

View File

@@ -1,6 +1,7 @@
package ibd
import (
"errors"
"github.com/kaspanet/kaspad/blockdag"
"github.com/kaspanet/kaspad/netadapter/router"
"github.com/kaspanet/kaspad/protocol/protocolerrors"
@@ -95,6 +96,10 @@ func (flow *handleRequestBlocksFlow) buildMsgIBDBlocks(lowHash *daghash.Hash,
const maxHashesInMsgIBDBlocks = wire.MaxInvPerMsg
blockHashes, err := flow.DAG().AntiPastHashesBetween(lowHash, highHash, maxHashesInMsgIBDBlocks)
if err != nil {
if errors.Is(err, blockdag.ErrInvalidParameter) {
return nil, protocolerrors.Wrapf(true, err, "could not get antiPast between "+
"%s and %s", lowHash, highHash)
}
return nil, err
}

View File

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