本文整理汇总了C#中Record.GetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# Record.GetHeader方法的具体用法?C# Record.GetHeader怎么用?C# Record.GetHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.GetHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRecord
/// <exception cref="BitCoinSharp.BlockStoreException" />
/// <exception cref="System.IO.IOException" />
/// <exception cref="BitCoinSharp.ProtocolException" />
private Record GetRecord(Sha256Hash hash)
{
var startPos = _channel.Position;
// Use our own file pointer within the tight loop as updating channel positions is really expensive.
var pos = startPos;
var record = new Record();
do
{
if (!record.Read(_channel, pos, _buf))
throw new IOException("Failed to read buffer");
if (record.GetHeader(_params).Hash.SequenceEqual(hash.Hash))
{
// Found it. Update file position for next time.
_channel.Position = pos;
return record;
}
// Did not find it.
if (pos == 1 + 32)
{
// At the start so wrap around to the end.
pos = _channel.Length - Record.Size;
}
else
{
// Move backwards.
pos = pos - Record.Size;
Debug.Assert(pos >= 1 + 32, pos.ToString());
}
} while (pos != startPos);
// Was never stored.
_channel.Position = pos;
return null;
}