// Seek to the end and then append magic bytes there.
writer.Seek(0, SeekOrigin.End);
writer.Write(magicBytes, 0, magicBytes.Length);
+ writer.Write(blkLenBytes, 0, blkLenBytes.Length);
// Save block size and current position in the block cursor fields.
nBlockPos = writer.Position;
nBlockSize = blockBytes.Length;
// Write block and flush the stream.
- writer.Write(blkLenBytes, 0, blkLenBytes.Length);
writer.Write(blockBytes, 0, blockBytes.Length);
writer.Flush();
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;
+ var fStreamReadWrite = File.Open(strBlockFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
reader = new BinaryReader(fStreamReadWrite).BaseStream;
+ writer = new BinaryWriter(fStreamReadWrite).BaseStream;
if (firstInit)
{
{
// Handle trasactions
+ if (!block.vtx[i].VerifyScripts())
+ {
+ return false;
+ }
+
var nTxOffset = itemTemplate.nBlockPos + block.GetTxOffset(i);
TxType txnType = TxType.TX_USER;
uint nHeight = prevBlockCursor.nHeight + 1;
// Check timestamp against prev
- if (NetUtils.FutureDrift(block.header.nTime) < prevBlockHeader.nTime)
+ if (NetInfo.FutureDrift(block.header.nTime) < prevBlockHeader.nTime)
{
// block's timestamp is too early
return false;
// Free other state (managed objects).
reader.Dispose();
- writer.Dispose();
+ reader.Dispose();
}
if (dbConn != null)
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>Build</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Compile Include="CScriptID.cs" />
<Compile Include="Hash.cs" />
<Compile Include="Interop.cs" />
- <Compile Include="NetUtils.cs" />
+ <Compile Include="NetInfo.cs" />
<Compile Include="RIPEMD160.cs" />
<Compile Include="ScryptHash256.cs" />
<Compile Include="SHA1.cs" />
<Compile Include="CKeyStore.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />