OSDN Git Service

Add connection peer spv flag check
authorYahtoo Ma <yahtoo.ma@gmail.com>
Wed, 22 Aug 2018 10:53:18 +0000 (18:53 +0800)
committerYahtoo Ma <yahtoo.ma@gmail.com>
Wed, 22 Aug 2018 10:53:18 +0000 (18:53 +0800)
consensus/server_flag.go
netsync/handle.go

index b1442f3..3f9034c 100644 (file)
@@ -9,13 +9,13 @@ const (
        SFFullNode ServiceFlag = 1 << iota
        // SFFastSync indicate peer support header first mode
        SFFastSync
-       SFSpvNode
+       //SFSpvProof indicate peer support spv proof
+       SFSpvProof
        // DefaultServices is the server that this node support
-       DefaultServices = SFFullNode | SFFastSync
+       DefaultServices = SFFastSync
 )
 
 // IsEnable check does the flag support the input flag function
 func (f ServiceFlag) IsEnable(checkFlag ServiceFlag) bool {
        return f&checkFlag == checkFlag
 }
-
index 9fd9c74..6c9b00a 100644 (file)
@@ -295,10 +295,10 @@ func (sm *SyncManager) handleStatusResponseMsg(basePeer BasePeer, msg *StatusRes
                }).Warn("fail hand shake due to differnt genesis")
                return
        }
-       if basePeer.ServiceFlag().IsEnable(consensus.SFFullNode) == false {
+       if basePeer.ServiceFlag().IsEnable(consensus.SFFullNode|consensus.SFSpvProof) == false {
                log.WithFields(log.Fields{
                        "peer ServiceFlag": basePeer.ServiceFlag(),
-               }).Warn("fail hand shake due to remote peer is not full node")
+               }).Warn("fail hand shake due to remote peer is not full node support spv proof")
                return
        }
        sm.peers.addPeer(basePeer, msg.Height, msg.GetHash())
@@ -377,7 +377,7 @@ func (sm *SyncManager) makeNodeInfo(listenerStatus bool) *p2p.NodeInfo {
                Moniker: sm.config.Moniker,
                Network: sm.config.ChainID,
                Version: version.Version,
-               Other:   []string{strconv.FormatUint(uint64(consensus.SFSpvNode), 10)},
+               Other:   []string{strconv.FormatUint(uint64(consensus.DefaultServices), 10)},
        }
 
        if !sm.sw.IsListening() {