func (pool *BlockPool) RemovePeer(peerID p2p.ID, err error) {
	peer := pool.peers[peerID]
	if peer == nil {
		return
	}
	pool.logger.Info("removing peer", "peerID", peerID, "error", err)
	for h := range pool.peers[peerID].blocks {
		pool.rescheduleRequest(peerID, h)
	}
	oldMaxPeerHeight := pool.MaxPeerHeight
	pool.deletePeer(peer)
	if oldMaxPeerHeight > pool.MaxPeerHeight {
		for h := range pool.plannedRequests {
			if h > pool.MaxPeerHeight {
				delete(pool.plannedRequests, h)
			}
		}
		if pool.nextRequestHeight > pool.MaxPeerHeight {
			pool.nextRequestHeight = pool.MaxPeerHeight + 1
		}
	}
}
RemovePeer removes the blocks and requests from the peer, reschedules them and deletes the peer.
package v1
import (
	"sort"
	"github.com/line/ostracon/libs/log"
	"github.com/line/ostracon/p2p"
	"github.com/line/ostracon/types"
)
type BlockPool struct {
	logger log.Logger
	peers map[p2p.ID]*BpPeer
	blocks map[int64]p2p.ID
	plannedRequests   map[int64]struct{}  
	nextRequestHeight int64               
	Height        int64  
	MaxPeerHeight int64  
	toBcR         bcReactor
}
func NewBlockPool(height int64, toBcR bcReactor) *BlockPool {
	return &BlockPool{
		Height:            height,
		MaxPeerHeight:     0,
		peers:             make(map[p2p.ID]*BpPeer),
		blocks:            make(map[int64]p2p.ID),
		plannedRequests:   make(map[int64]struct{}),
		nextRequestHeight: height,
		toBcR:             toBcR,
	}
}
func (pool *BlockPool) SetLogger(l log.Logger) {
	pool.logger = l
}
func (pool *BlockPool) ReachedMaxHeight() bool {
	return pool.Height >= pool.MaxPeerHeight
}
func (pool *BlockPool) rescheduleRequest(peerID p2p.ID, height int64) {
	pool.logger.Info("reschedule requests made to peer for height ", "peerID", peerID, "height", height)
	pool.plannedRequests[height] = struct{}{}
	delete(pool.blocks, height)
	pool.peers[peerID].RemoveBlock(height)
}
func (pool *BlockPool) updateMaxPeerHeight() {
	var newMax int64
	for _, peer := range pool.peers {
		peerHeight := peer.Height
		if peerHeight > newMax {
			newMax = peerHeight
		}
	}
	pool.MaxPeerHeight = newMax
}
func (pool *BlockPool) UpdatePeer(peerID p2p.ID, base int64, height int64) error {
	peer := pool.peers[peerID]
	if peer == nil {
		if height < pool.Height {
			pool.logger.Info("Peer height too small",
				"peer", peerID, "height", height, "fsm_height", pool.Height)
			return errPeerTooShort
		}
		peer = NewBpPeer(peerID, base, height, pool.toBcR.sendPeerError, nil)
		peer.SetLogger(pool.logger.With("peer", peerID))
		pool.peers[peerID] = peer
		pool.logger.Info("added peer", "peerID", peerID, "base", base, "height", height, "num_peers", len(pool.peers))
	} else {
		if height < peer.Height {
			pool.RemovePeer(peerID, errPeerLowersItsHeight)
			return errPeerLowersItsHeight
		}
		peer.Base = base
		peer.Height = height
	}
	pool.updateMaxPeerHeight()
	return nil
}
func (pool *BlockPool) deletePeer(peer *BpPeer) {
	if peer == nil {
		return
	}
	peer.Cleanup()
	delete(pool.peers, peer.ID)
	if peer.Height == pool.MaxPeerHeight {
		pool.updateMaxPeerHeight()
	}
}