func (pool *BlockPool) AddBlock(peerID p2p.ID, block *types.Block, blockSize int) error {
	peer, ok := pool.peers[peerID]
	if !ok {
		pool.logger.Error("block from unknown peer", "height", block.Height, "peer", peerID)
		return errBadDataFromPeer
	}
	if wantPeerID, ok := pool.blocks[block.Height]; ok && wantPeerID != peerID {
		pool.logger.Error("block received from wrong peer", "height", block.Height,
			"peer", peerID, "expected_peer", wantPeerID)
		return errBadDataFromPeer
	}

	return peer.AddBlock(block, blockSize)
}
// AddBlock validates that the block comes from the peer it was expected from and stores it in the 'blocks' map.
AddBlock validates that the block comes from the peer it was expected from and stores it in the 'blocks' map.
// AddBlock validates that the block comes from the peer it was expected from and stores it in the ' blocks ' map .
func (pool *BlockPool) AddBlock(peerID p2p.ID, block *types.Block, blockSize int) error {
	peer, ok := pool.peers[peerID]
	if !ok {
		pool.logger.Error("block from unknown peer", "height", block.Height, "peer", peerID)
		return errBadDataFromPeer
	}
	if wantPeerID, ok := pool.blocks[block.Height]; ok && wantPeerID != peerID {
		pool.logger.Error("block received from wrong peer", "height", block.Height,
			"peer", peerID, "expected_peer", wantPeerID)
		return errBadDataFromPeer
	}
	return peer.AddBlock(block, blockSize)
}
func ( pool * BlockPool ) AddBlock ( peerID p2p . ID , block * types . Block , blockSize int ) error { peer , ok := pool . peers [ peerID ] if ! ok { pool . logger . Error ( " " , " " , block . Height , " " , peerID ) return errBadDataFromPeer } if wantPeerID , ok := pool . blocks [ block . Height ] ; ok && wantPeerID != peerID { pool . logger . Error ( " " , " " , block . Height , " " , peerID , " " , wantPeerID ) return errBadDataFromPeer } return peer . AddBlock ( block , blockSize ) }
AddBlock validates that the block comes from the peer it was expected from and stores it in the 'blocks' map.
AddBlock validates that the block comes from the peer it was expected from and stores it in the ' blocks ' map .