本文整理匯總了C#中Block.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# Block.Equals方法的具體用法?C# Block.Equals怎麽用?C# Block.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Block
的用法示例。
在下文中一共展示了Block.Equals方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: btnAdd_Click
private void btnAdd_Click(object sender, EventArgs e)
{
int count=0;
int discardCount=0;
bool Good;
Block newBlock;
do
{
do
{
newBlock = new Block(trackBar1.Value);
Good = true;
foreach (Block value in blockList)
{
if (newBlock.Equals(value)&&discardCount<1000)
{
Good = false;
discardCount++;
ProgressBar1.Value = discardCount;
ProgressBar1.Refresh();
}
}
}
while(!Good);
if (discardCount < 1000)
{
blockList.Add(newBlock);
newBlock.AddBlock();
count++;
Block.blockSwitch = false;
}
}
while (count < 25 && discardCount <1000);
}
示例2: Load
/// <exception cref="IOException"/>
/// <exception cref="BlockStoreException"/>
private void Load(FileInfo file)
{
_log.InfoFormat("Reading block store from {0}", file);
using (var input = file.OpenRead())
{
// Read a version byte.
var version = input.Read();
if (version == -1)
{
// No such file or the file was empty.
throw new FileNotFoundException(file.Name + " does not exist or is empty");
}
if (version != 1)
{
throw new BlockStoreException("Bad version number: " + version);
}
// Chain head pointer is the first thing in the file.
var chainHeadHash = new byte[32];
if (input.Read(chainHeadHash) < chainHeadHash.Length)
throw new BlockStoreException("Truncated block store: cannot read chain head hash");
_chainHead = new Sha256Hash(chainHeadHash);
_log.InfoFormat("Read chain head from disk: {0}", _chainHead);
var now = Environment.TickCount;
// Rest of file is raw block headers.
var headerBytes = new byte[Block.HeaderSize];
try
{
while (true)
{
// Read a block from disk.
if (input.Read(headerBytes) < 80)
{
// End of file.
break;
}
// Parse it.
var b = new Block(_params, headerBytes);
// Look up the previous block it connects to.
var prev = Get(b.PrevBlockHash);
StoredBlock s;
if (prev == null)
{
// First block in the stored chain has to be treated specially.
if (b.Equals(_params.GenesisBlock))
{
s = new StoredBlock(_params.GenesisBlock.CloneAsHeader(), _params.GenesisBlock.GetWork(), 0);
}
else
{
throw new BlockStoreException("Could not connect " + b.Hash + " to " + b.PrevBlockHash);
}
}
else
{
// Don't try to verify the genesis block to avoid upsetting the unit tests.
b.VerifyHeader();
// Calculate its height and total chain work.
s = prev.Build(b);
}
// Save in memory.
_blockMap[b.Hash] = s;
}
}
catch (ProtocolException e)
{
// Corrupted file.
throw new BlockStoreException(e);
}
catch (VerificationException e)
{
// Should not be able to happen unless the file contains bad blocks.
throw new BlockStoreException(e);
}
var elapsed = Environment.TickCount - now;
_log.InfoFormat("Block chain read complete in {0}ms", elapsed);
}
}