本文整理汇总了C#中NBitcoin.uint256类的典型用法代码示例。如果您正苦于以下问题:C# uint256类的具体用法?C# uint256怎么用?C# uint256使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
uint256类属于NBitcoin命名空间,在下文中一共展示了uint256类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeChecksum
public void ComputeChecksum(uint256 hashBlock)
{
MemoryStream ms = new MemoryStream();
hashBlock.ReadWrite(ms, true);
this.ReadWrite(ms, true);
CalculatedChecksum = Hashes.Hash256(ms.ToArray());
}
示例2: GetBlock
public Block GetBlock(uint256 id, List<byte[]> searchedData)
{
var block = Get(id);
if(block == null)
return null;
return block;
}
示例3: GetFromCache
public Transaction GetFromCache(uint256 txId)
{
using(@lock.LockRead())
{
return _Transactions.TryGet(txId);
}
}
示例4: GetHeader
public BlockHeader GetHeader(uint256 hash)
{
var pos = _Index.Get<DiskBlockPos>(hash.ToString());
if(pos == null)
return null;
var stored = _Store.Enumerate(false, new DiskBlockPosRange(pos)).FirstOrDefault();
if(stored == null)
return null;
return stored.Item.Header;
}
示例5: Put
public static void Put(this ITransactionRepository repo, uint256 txId, Transaction tx)
{
try
{
repo.PutAsync(txId, tx).Wait();
}
catch(AggregateException aex)
{
ExceptionDispatchInfo.Capture(aex.InnerException).Throw();
}
}
示例6: uint256
public uint256(uint256 b)
{
pn0 = b.pn0;
pn1 = b.pn1;
pn2 = b.pn2;
pn3 = b.pn3;
pn4 = b.pn4;
pn5 = b.pn5;
pn6 = b.pn6;
pn7 = b.pn7;
}
示例7: PutAsync
public Task PutAsync(uint256 txId, Transaction tx)
{
using(@lock.LockWrite())
{
if(!_Transactions.ContainsKey(txId))
_Transactions.AddOrReplace(txId, tx);
else
_Transactions[txId] = tx;
}
return _Inner.PutAsync(txId, tx);
}
示例8: Get
public static Transaction Get(this ITransactionRepository repo, uint256 txId)
{
try
{
return repo.GetAsync(txId).Result;
}
catch(AggregateException aex)
{
ExceptionDispatchInfo.Capture(aex.InnerException).Throw();
return null;
}
}
示例9: GetAsync
public async Task<Transaction> GetAsync(uint256 txId)
{
using(HttpClient client = new HttpClient())
{
var tx = await client.GetAsync(BaseUri.AbsoluteUri + "transactions/" + txId + "?format=raw").ConfigureAwait(false);
if(tx.StatusCode == System.Net.HttpStatusCode.NotFound)
return null;
tx.EnsureSuccessStatusCode();
var bytes = await tx.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
return new Transaction(bytes);
}
}
示例10: PartialMerkleTree
// Construct a partial merkle tree from a list of transaction id's, and a mask that selects a subset of them
public PartialMerkleTree(uint256[] vTxid, bool[] vMatch)
{
fBad = false;
nTransactions = (uint)vTxid.Length;
// calculate height of tree
int nHeight = 0;
while(CalcTreeWidth(nHeight) > 1)
nHeight++;
// traverse the partial tree
TraverseAndBuild(nHeight, 0, vTxid, vMatch);
}
示例11: PartialMerkleTree
public PartialMerkleTree(uint256[] vTxid, bool[] vMatch)
{
if(vMatch.Length != vTxid.Length)
throw new ArgumentException("The size of the array of txid and matches is different");
TransactionCount = (uint)vTxid.Length;
MerkleNode root = MerkleNode.GetRoot(vTxid);
BitWriter flags = new BitWriter();
MarkNodes(root, vMatch);
BuildCore(root, flags);
Flags = flags.ToBitArray();
}
示例12: CheckMerkleBranch
public static uint256 CheckMerkleBranch(uint256 hash, List<uint256> vMerkleBranch, int nIndex)
{
if(nIndex == -1)
return 0;
foreach(var otherside in vMerkleBranch)
{
if((nIndex & 1) != 0)
hash = Hash(otherside, hash);
else
hash = Hash(hash, otherside);
nIndex >>= 1;
}
return hash;
}
示例13: MerkleBlock
public MerkleBlock(Block block, uint256[] txIds)
{
header = block.Header;
List<bool> vMatch = new List<bool>();
List<uint256> vHashes = new List<uint256>();
for(int i = 0 ; i < block.Transactions.Count ; i++)
{
var hash = block.Transactions[i].GetHash();
vHashes.Add(hash);
vMatch.Add(txIds.Contains(hash));
}
_PartialMerkleTree = new PartialMerkleTree(vHashes.ToArray(), vMatch.ToArray());
}
示例14: TryParse
public static bool TryParse(string hex, out uint256 result)
{
if(hex == null)
throw new ArgumentNullException("hex");
result = null;
if(hex.Length != WIDTH_BYTE * 2)
return false;
if(!((HexEncoder)Encoders.Hex).IsValid(hex))
return false;
var ret = new uint256();
ret.SetHex(hex);
result = ret;
return true;
}
示例15: TryParse
public static bool TryParse(string hex, out uint256 result)
{
if(hex == null)
throw new ArgumentNullException("hex");
if (hex.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
hex = hex.Substring(2);
result = null;
if(hex.Length != WIDTH_BYTE * 2)
return false;
if(!((HexEncoder)Encoders.Hex).IsValid(hex))
return false;
result = new uint256(hex);
return true;
}