/// <summary> /// Calls <paramref name="reader"/> on the block represented by the /// realm and hash. /// </summary> /// <exception cref="MissingBlockException"> /// If the block is not present in the scratch space, or was corrupted /// and failed a checksum check. /// </exception> public T Read <T>(uint realm, Hash hash, WithSpan.ReadOnlyReturns <T> reader) { var addr = _index.Get(realm, hash); try { if (_wheel.TryWithBlockAtAddress(addr, realm, hash, reader, out var result)) { return(result); } } // 'MissingBlock' and 'ChecksumFailed', if they happen inside, should // converted to a 'MissingBlock' and ensure that the broken block is // removed. catch (MissingBlockException) {} catch (CheckSumFailedException) {} _index.Remove(realm, hash, addr); throw new MissingBlockException(realm, hash); }
public void empty_contains_nothing() => Assert.True(_index.Get(0, HashInBucket(0, 0)).IsNone());