func InitProtocol(env *protocol.P2PEnv) {
	exRT, _ := kbt.NewRoutingTable(20, kbt.ConvertPeerID(env.Host.ID()), time.Minute, env.Host.Peerstore(), time.Hour, nil)
	p := &Protocol{
		P2PEnv:               env,
		chunkToSync:          make(chan *types.ChunkInfoMsg, 1024),
		chunkToDelete:        make(chan *types.ChunkInfoMsg, 1024),
		chunkToDownload:      make(chan *types.ChunkInfoMsg, 1024),
		wakeup:               make(map[string]chan struct{}),
		chunkInfoCache:       make(map[string]*types.ChunkInfoMsg),
		peerAddrRequestTrace: make(map[peer.ID]map[peer.ID]time.Time),
		chunkRequestTrace:    make(map[string]map[peer.ID]time.Time),
		chunkProviderCache:   make(map[string]map[peer.ID]time.Time),
		extendRoutingTable:   exRT,
	}
	if env.SubConfig.Percentage < types2.MinPercentage || env.SubConfig.Percentage > types2.MaxPercentage {
		env.SubConfig.Percentage = types2.DefaultPercentage
	}
	p.initLocalChunkInfoMap()
	protocol.RegisterStreamHandler(p.Host, requestPeerInfoForChunk, p.handleStreamRequestPeerInfoForChunk)
	protocol.RegisterStreamHandler(p.Host, responsePeerInfoForChunk, p.handleStreamResponsePeerInfoForChunk)
	protocol.RegisterStreamHandler(p.Host, requestPeerAddr, p.handleStreamRequestPeerAddr)
	protocol.RegisterStreamHandler(p.Host, responsePeerAddr, p.handleStreamResponsePeerAddr)
	protocol.RegisterStreamHandler(p.Host, fetchPeerAddr, protocol.HandlerWithRW(p.handleStreamPeerAddr))
	protocol.RegisterStreamHandler(p.Host, fetchActivePeer, protocol.HandlerWithWrite(p.handleStreamFetchActivePeer))
	protocol.RegisterStreamHandler(p.Host, fetchShardPeer, protocol.HandlerWithRW(p.handleStreamFetchShardPeers))
	protocol.RegisterStreamHandler(p.Host, getHeaderOld, p.handleStreamGetHeaderOld)
	protocol.RegisterStreamHandler(p.Host, getHeader, protocol.HandlerWithAuthAndSign(p.handleStreamGetHeader))
	if !p.SubConfig.DisableShard {
		protocol.RegisterStreamHandler(p.Host, fullNode, protocol.HandlerWithWrite(p.handleStreamIsFullNode))
		protocol.RegisterStreamHandler(p.Host, fetchChunk, p.handleStreamFetchChunk)  
		protocol.RegisterStreamHandler(p.Host, getChunkRecord, protocol.HandlerWithAuthAndSign(p.handleStreamGetChunkRecord))
	}
	protocol.RegisterEventHandler(types.EventNotifyStoreChunk, p.handleEventNotifyStoreChunk)
	protocol.RegisterEventHandler(types.EventGetChunkBlock, p.handleEventGetChunkBlock)
	protocol.RegisterEventHandler(types.EventGetChunkBlockBody, p.handleEventGetChunkBlockBody)
	protocol.RegisterEventHandler(types.EventGetChunkRecord, p.handleEventGetChunkRecord)
	protocol.RegisterEventHandler(types.EventFetchBlockHeaders, p.handleEventGetHeaders)
	go p.processLocalChunk()
	go p.updateRoutine()
	go p.refreshRoutine()
	go p.debugLog()
	go p.processLocalChunkOldVersion()
}
InitProtocol initials the protocol.
package p2pstore
import (
	"encoding/hex"
	"sync"
	"time"
	"github.com/33cn/chain33/common/log/log15"
	"github.com/33cn/chain33/system/p2p/dht/protocol"
	types2 "github.com/33cn/chain33/system/p2p/dht/types"
	"github.com/33cn/chain33/types"
	"github.com/libp2p/go-libp2p-core/peer"
	kbt "github.com/libp2p/go-libp2p-kbucket"
)
const (
	fetchActivePeer = "/chain33/fetch-active-peer/1.0.0"
	fetchShardPeer  = "/chain33/fetch-shard-peer/1.0.0"
	fetchChunk      = "/chain33/fetch-chunk/1.0.0"
	getHeader      = "/chain33/headers/1.0.0"
	getChunkRecord = "/chain33/chunk-record/1.0.0"
	fullNode       = "/chain33/full-node/1.0.0"
	fetchPeerAddr  = "/chain33/fetch-peer-addr/1.0.0"
	getHeaderOld = "/chain33/headerinfoReq/1.0.0"
	requestPeerAddr          = "/chain33/request-peer-addr/1.0.0"
	responsePeerAddr         = "/chain33/response-peer-addr/1.0.0"
	requestPeerInfoForChunk  = "/chain33/request-peer-info-for-chunk/1.0.0"
	responsePeerInfoForChunk = "/chain33/response-peer-info-for-chunk/1.0.0"
)
const maxConcurrency = 10
var log = log15.New("module", "protocol.p2pstore")
type Protocol struct {
	*protocol.P2PEnv  
	chunkToSync     chan *types.ChunkInfoMsg
	chunkToDelete   chan *types.ChunkInfoMsg
	chunkToDownload chan *types.ChunkInfoMsg
	wakeup      map[string]chan struct{}
	wakeupMutex sync.Mutex
	chunkInfoCache      map[string]*types.ChunkInfoMsg
	chunkInfoCacheMutex sync.Mutex
	localChunkInfo      map[string]LocalChunkInfo
	localChunkInfoMutex sync.RWMutex
	concurrency int64
	extendRoutingTable *kbt.RoutingTable
	peerAddrRequestTrace      map[peer.ID]map[peer.ID]time.Time  
	peerAddrRequestTraceMutex sync.RWMutex
	chunkRequestTrace      map[string]map[peer.ID]time.Time  
	chunkRequestTraceMutex sync.RWMutex
	chunkProviderCache      map[string]map[peer.ID]time.Time  
	chunkProviderCacheMutex sync.RWMutex
}
func init() {
	protocol.RegisterProtocolInitializer(InitProtocol)
}