当前位置: 首页>>代码示例>>C#>>正文


C# Record.GetHeader方法代码示例

本文整理汇总了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;
 }
开发者ID:aklein53,项目名称:bitcoinsharp,代码行数:36,代码来源:BoundedOverheadBlockStore.cs


注:本文中的Record.GetHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。