BlockHash.fromState constructor

BlockHash.fromState(
  1. BlockHash source
)

Copies the running state of source (buffered bytes included).

Only running states can be copied: finish repurposes the block buffer for padding, so a finished hash no longer has a resumable state to snapshot.

Implementation

BlockHash.fromState(BlockHash source)
  : _totalBytes = source._totalBytes,
    _bufferLength = source._bufferLength {
  if (source._finished) {
    throw StateError('copy() after finish()');
  }
  _buffer.setRange(0, source._bufferLength, source._buffer);
}