requestBlock method

  1. @override
Future<PeerI?> requestBlock(
  1. Hash blockHash
)
override

Request a block from the best available peer Returns the peer handling the request, or null if no peers available

Implementation

@override
Future<PeerI?> requestBlock(Hash blockHash) async {
  if (_isShutdown) {
    return null;
  }

  final peer = _selectBestPeer();
  if (peer == null) {
    logger.warning('No available peers for block request');
    return null;
  }

  try {
    await peer.requestBlock(blockHash);
    logger.fine('Requested block $blockHash from $peer');
    return peer;
  } catch (e) {
    logger.warning('Failed to request block from $peer: $e');
    return null;
  }
}