/// <summary>
/// Block file stream with read access
/// </summary>
- private Stream reader;
-
- /// <summary>
- /// Block file stream with write access
- /// </summary>
- private Stream writer;
+ private Stream fStreamReadWrite;
/// <summary>
/// Init the block storage manager.
bool firstInit = !File.Exists(strDbFile);
dbConn = new SQLiteConnection(new SQLitePlatformGeneric(), strDbFile);
- var fStreamReadWrite = File.Open(strBlockFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
- writer = new BinaryWriter(fStreamReadWrite).BaseStream;
- reader = new BinaryReader(fStreamReadWrite).BaseStream;
+ fStreamReadWrite = File.Open(strBlockFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
if (firstInit)
{
public bool GetTransaction(Hash256 TxID, ref CTransaction tx)
{
+ var reader = new BinaryReader(fStreamReadWrite).BaseStream;
var QueryTx = dbConn.Query<CTransactionStoreItem>("select * from [TransactionStorage] where [TransactionHash] = ?", (byte[])TxID);
if (QueryTx.Count == 1)
private bool AddItemToIndex(ref CBlockStoreItem itemTemplate, ref CBlock block)
{
+ var writer = new BinaryWriter(fStreamReadWrite).BaseStream;
var blockHash = new ScryptHash256(itemTemplate.Hash);
if (blockMap.ContainsKey(blockHash))
{
// Handle trasactions
+ if (!block.vtx[i].VerifyScripts())
+ {
+ return false;
+ }
+
var nTxOffset = itemTemplate.nBlockPos + block.GetTxOffset(i);
TxType txnType = TxType.TX_USER;
public bool GetBlock(ScryptHash256 blockHash, ref CBlock block)
{
+ var reader = new BinaryReader(fStreamReadWrite).BaseStream;
+
var QueryBlock = dbConn.Query<CBlockStoreItem>("select * from [BlockStorage] where [Hash] = ?", (byte[])blockHash);
if (QueryBlock.Count == 1)
{
// Free other state (managed objects).
- reader.Dispose();
- writer.Dispose();
+ fStreamReadWrite.Dispose();
}
if (dbConn != null)