getVersionDescription method

VersionDescription? getVersionDescription(
  1. int blockNumber
)

Returns the VersionDescription for the blockNumber

If the blockNumber is not having any related VersionDescription then it returns null.

Implementation

VersionDescription? getVersionDescription(int blockNumber) {
  // List of block numbers
  final blockNumberList = _versionDescriptionMap.keys.toList(growable: false);

  int next = -1;
  for (var index = 0; index < blockNumberList.length; index++) {
    if (blockNumberList[index] >= blockNumber) {
      next = index;
      break;
    }
  }
  VersionDescription? vd;

  if (blockNumberList.isNotEmpty &&
      next != 0 &&
      next < blockNumberList.length) {
    // get the blocknumber from the index
    final int resultBlockNumber = next < 0
        ? blockNumberList[blockNumberList.length - 1]
        : blockNumberList[next - 1];

    vd = _versionDescriptionMap[resultBlockNumber];
  }
  return vd;
}