github.com/turingchain2020/turingchain@v1.1.21/p2p/utils/utils.go (about)

     1  // Copyright Turing Corp. 2018 All Rights Reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package utils p2p utils
     6  package utils
     7  
     8  const (
     9  	versionMask = 0xFFFF
    10  )
    11  
    12  // CalcChannelVersion  calc channel version
    13  func CalcChannelVersion(channel, version int32) int32 {
    14  	return channel<<16 + version
    15  }
    16  
    17  // DecodeChannelVersion decode channel version
    18  func DecodeChannelVersion(channelVersion int32) (channel int32, version int32) {
    19  	channel = channelVersion >> 16
    20  	version = channelVersion & versionMask
    21  	return
    22  }