"github.com/bytom/vapor/consensus"
dbm "github.com/bytom/vapor/database/leveldb"
+ "github.com/bytom/vapor/errors"
"github.com/bytom/vapor/netsync/peers"
"github.com/bytom/vapor/p2p/security"
+ "github.com/bytom/vapor/protocol"
"github.com/bytom/vapor/protocol/bc"
"github.com/bytom/vapor/protocol/bc/types"
)
}
isOrphan, err := bk.chain.ProcessBlock(block)
- if err != nil {
+ if err != nil && errors.Root(err) != protocol.ErrDoubleSignBlock {
bk.peers.ProcessIllegal(bk.syncPeer.ID(), security.LevelMsgIllegal, err.Error())
return err
}
"github.com/bytom/vapor/errors"
"github.com/bytom/vapor/netsync/peers"
"github.com/bytom/vapor/p2p/security"
+ "github.com/bytom/vapor/protocol"
)
var errOrphanBlock = errors.New("fast sync inserting orphan block")
return errOrphanBlock
}
- if err != nil {
+ if err != nil && errors.Root(err) != protocol.ErrDoubleSignBlock {
bp.peers.ProcessIllegal(blockStorage.peerID, security.LevelMsgIllegal, err.Error())
}
return err
)
var (
- errDoubleSignBlock = errors.New("the consensus is double sign in same height of different block")
+ // ErrDoubleSignBlock represent the consensus is double sign in same height of different block
+ ErrDoubleSignBlock = errors.New("the consensus is double sign in same height of different block")
errInvalidSignature = errors.New("the signature of block is invalid")
- errSignForkChain = errors.New("can not sign fork before the irreversible block")
)
func signCacheKey(blockHash, pubkey string) string {
}
if blockHeader.BlockWitness.Get(consensusNode.Order) != nil {
- return errDoubleSignBlock
+ return ErrDoubleSignBlock
}
}
return nil
}
}
- if err := c.checkNodeSign(&block.BlockHeader, node, block.Get(node.Order)); err == errDoubleSignBlock {
+ if err := c.checkNodeSign(&block.BlockHeader, node, block.Get(node.Order)); err == ErrDoubleSignBlock {
log.WithFields(log.Fields{"module": logModule, "blockHash": blockHash.String(), "pubKey": pubKey}).Warn("the consensus node double sign the same height of different block")
// if the blocker double sign & become the mainchain, that means
// all the side chain will reject the main chain make the chain
block.BlockWitness.Delete(node.Order)
continue
}
+
+ return err
} else if err != nil {
return err
}
return nil, nil
}
- if err := c.checkDoubleSign(blockHeader, node.XPub.String()); err == errDoubleSignBlock {
+ if err := c.checkDoubleSign(blockHeader, node.XPub.String()); err == ErrDoubleSignBlock {
log.WithFields(log.Fields{"module": logModule, "blockHash": blockHash.String()}).Warn("current node has double sign the block")
return nil, nil
} else if err != nil {