receivePart method

bool receivePart(
  1. String s
)

Implementation

bool receivePart(String s) {
  if (result != null) {
    return false;
  }

  final components = parse(s);

  if (!validatePart(components[0])) {
    return false;
  }

  if (components[1].length == 1) {
    result = decodeBody(components[0], components[1][0]);
    return true;
  }

  if (components[1].length != 2) {
    throw InvalidPathLengthError();
  }

  final seq = components[1][0];
  final fragment = components[1][1];
  final seqComponents = parseSequenceComponent(seq);
  final cbor = bytewords.decode(fragment, style: bytewords.Styles.minimal);
  final part = FountainEncoderPart.fromCBOR(cbor);

  if (seqComponents[0] != part.seqNum || seqComponents[1] != part.seqLength) {
    return false;
  }

  if (!fountainDecoder.receivePart(part)) {
    return false;
  }

  if (fountainDecoder.isSuccess()) {
    result = UR(fountainDecoder.resultMessage(), components[0]);
  } else if (fountainDecoder.isFailure()) {
    error = InvalidSchemeError();
  }

  return true;
}