本文整理汇总了C#中UInt256.ToDbByteArray方法的典型用法代码示例。如果您正苦于以下问题:C# UInt256.ToDbByteArray方法的具体用法?C# UInt256.ToDbByteArray怎么用?C# UInt256.ToDbByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UInt256
的用法示例。
在下文中一共展示了UInt256.ToDbByteArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryReadValue
public bool TryReadValue(UInt256 txHash, out Transaction transaction)
{
using (var conn = this.OpenConnection())
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = @"
SELECT TxBytes
FROM BlockTransactions
WHERE TxHash = @txHash";
cmd.Parameters.SetValue("@txHash", FbDbType.Char, FbCharset.Octets, 32).Value = txHash.ToDbByteArray();
using (var reader = cmd.ExecuteReader())
{
if (reader.Read())
{
var txBytes = reader.GetBytes(0);
transaction = StorageEncoder.DecodeTransaction(txBytes.ToMemoryStream(), txHash);
return true;
}
else
{
transaction = default(Transaction);
return false;
}
}
}
}
示例2: TryReadValue
public bool TryReadValue(UInt256 blockHash, out ImmutableArray<Transaction> blockTransactions)
{
using (var conn = this.OpenConnection())
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = @"
SELECT TxHash, TxBytes
FROM BlockTransactions
WHERE BlockHash = @blockHash
ORDER BY TxIndex ASC";
cmd.Parameters.SetValue("@blockHash", FbDbType.Char, FbCharset.Octets, 32).Value = blockHash.ToDbByteArray();
using (var reader = cmd.ExecuteReader())
{
var blockTransactionsBuilder = ImmutableArray.CreateBuilder<Transaction>();
while (reader.Read())
{
var txHash = reader.GetUInt256(0);
var txBytes = reader.GetBytes(1);
blockTransactionsBuilder.Add(StorageEncoder.DecodeTransaction(txBytes.ToMemoryStream(), txHash));
}
blockTransactions = blockTransactionsBuilder.ToImmutable();
return blockTransactions.Length > 0;
}
}
}
示例3: TryReadValue
public bool TryReadValue(UInt256 blockHash, out BlockHeader blockHeader)
{
using (var conn = this.OpenConnection())
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = @"
SELECT HeaderBytes
FROM BlockHeaders
WHERE BlockHash = @blockHash";
cmd.Parameters.SetValue("@blockHash", SqlDbType.Binary, 32).Value = blockHash.ToDbByteArray();
using (var reader = cmd.ExecuteReader())
{
if (reader.Read())
{
var headerBytes = reader.GetBytes(0);
blockHeader = StorageEncoder.DecodeBlockHeader(headerBytes.ToMemoryStream(), blockHash);
return true;
}
else
{
blockHeader = default(BlockHeader);
return false;
}
}
}
}
示例4: TryReadValue
public bool TryReadValue(UInt256 blockHash, out ImmutableArray<Transaction> blockTransactions)
{
using (var conn = this.OpenConnection())
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = @"
SELECT MinTxIndex, MaxTxIndex, TxChunkBytes
FROM BlockTransactionsChunked
WHERE BlockHash = @blockHash
ORDER BY MinTxIndex ASC";
cmd.Parameters.SetValue("@blockHash", SqlDbType.Binary, 32).Value = blockHash.ToDbByteArray();
using (var reader = cmd.ExecuteReader())
{
var blockTransactionsBuilder = ImmutableArray.CreateBuilder<Transaction>();
while (reader.Read())
{
var minTxIndex = reader.GetInt32(0);
var maxTxIndex = reader.GetInt32(1);
var txChunkBytes = reader.GetBytes(2);
var txChunkStream = txChunkBytes.ToMemoryStream();
for (var i = minTxIndex; i <= maxTxIndex; i++)
{
blockTransactionsBuilder.Add(StorageEncoder.DecodeTransaction(txChunkStream));
}
}
blockTransactions = blockTransactionsBuilder.ToImmutable();
return blockTransactions.Length > 0;
}
}
}
示例5: TryReadValue
public bool TryReadValue(UInt256 blockHash, out ChainedBlock chainedBlock)
{
using (var conn = this.OpenConnection())
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = @"
SELECT PreviousBlockHash, Height, TotalWork
FROM ChainedBlocks
WHERE BlockHash = @blockHash";
cmd.Parameters.SetValue("@blockHash", FbDbType.Char, FbCharset.Octets, 32).Value = blockHash.ToDbByteArray();
using (var reader = cmd.ExecuteReader())
{
if (reader.Read())
{
var previousBlockHash = reader.GetUInt256(0);
var height = reader.GetInt32(1);
var totalWork = reader.GetBigInteger(2);
chainedBlock = new ChainedBlock
(
blockHash,
previousBlockHash,
height,
totalWork
);
return true;
}
else
{
chainedBlock = default(ChainedBlock);
return false;
}
}
}
}