本文整理汇总了C#中UInt256.ToByteArrayBE方法的典型用法代码示例。如果您正苦于以下问题:C# UInt256.ToByteArrayBE方法的具体用法?C# UInt256.ToByteArrayBE怎么用?C# UInt256.ToByteArrayBE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UInt256
的用法示例。
在下文中一共展示了UInt256.ToByteArrayBE方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EncodeBlockHashTxIndex
public static byte[] EncodeBlockHashTxIndex(UInt256 blockHash, int txIndex)
{
var blockHashTxIndexBytes = new byte[37];
blockHashTxIndexBytes[0] = BLOCK_TX_PREFIX;
blockHash.ToByteArrayBE(blockHashTxIndexBytes, 1);
Buffer.BlockCopy(EncodeInt32(txIndex), 0, blockHashTxIndexBytes, 33, 4);
return blockHashTxIndexBytes;
}
示例2: EncodeUInt256
public static byte[] EncodeUInt256(UInt256 value)
{
return value.ToByteArrayBE();
}
示例3: MakeExistsKey
private byte[] MakeExistsKey(UInt256 blockHash)
{
var key = new byte[33];
key[0] = EXISTS_PREFIX;
blockHash.ToByteArrayBE(key, 1);
return key;
}
示例4: MakeBlockInvalidKey
private byte[] MakeBlockInvalidKey(UInt256 blockHash)
{
var key = new byte[33];
key[0] = BLOCK_INVALID_PREFIX;
blockHash.ToByteArrayBE(key, 1);
return key;
}
示例5: MakeHeaderKey
private byte[] MakeHeaderKey(UInt256 blockHash)
{
var key = new byte[33];
key[0] = HEADER_PREFIX;
blockHash.ToByteArrayBE(key, 1);
return key;
}
示例6: MakeTotalWorkKey
// TotalWork is stored in bytes as [prefix][totalWork big endian][blockHash big endian]
// putting total work first ensures that entries are sorted by total work
// including the blockHash ensures no coordination is needed to update the index
private byte[] MakeTotalWorkKey(UInt256 blockHash, BigInteger totalWork)
{
if (totalWork < 0)
throw new ArgumentOutOfRangeException(nameof(totalWork));
var totalWorkBytes = totalWork.ToByteArray();
if (totalWorkBytes.Length > 64)
throw new ArgumentOutOfRangeException(nameof(totalWork));
else if (totalWorkBytes.Length < 64)
Array.Resize(ref totalWorkBytes, 64);
Array.Reverse(totalWorkBytes);
var key = new byte[1 + 64 + 32];
key[0] = TOTAL_WORK_PREFIX;
Buffer.BlockCopy(totalWorkBytes, 0, key, 1, 64);
blockHash.ToByteArrayBE(key, 65);
return key;
}