public Block(Block block, bool thawChildren) { ContractsCommon.NotNull(block, "block"); Contract.Ensures(this.Version == block.Version); Contract.Ensures(this.PreviousBlockHash == block.PreviousBlockHash); Contract.Ensures(this.Timestamp == block.Timestamp); Contract.Ensures(this.DifficultyBits == block.DifficultyBits); Contract.Ensures(this.Nonce == block.Nonce); Contract.Ensures(this.Transactions.SequencedEquals(block.Transactions)); Contract.Ensures(this.MerkleRoot == block.MerkleRoot); ContractsCommon.ChildrenThawed(Transactions, thawChildren); this._version = block._version; this._previousBlockHash = block._previousBlockHash; this._timestamp = block._timestamp; this._difficultyBits = block._difficultyBits; this._nonce = block._nonce; if (block._merkleTree != null) { var tree = new ArrayList <Hash256>(block._merkleTree.Count); tree.AddAll(block._merkleTree); this._merkleTree = new GuardedList <Hash256>(tree); } var transactions = new HashedArrayList <Transaction>(block.Transactions.Count); transactions.AddAll(FreezableExtensions.ThawChildren(block.Transactions, thawChildren)); transactions.CollectionChanged += InvalidateMerkleTree; this.Transactions = transactions; }
protected override void Deserialize(Stream stream) { Version = ReadUInt32(stream); PreviousBlockHash = new Hash256(stream); new Hash256(stream); // Throw away the Merkle Root Timestamp = ReadUInt32(stream); DifficultyBits = ReadUInt32(stream); Nonce = ReadUInt32(stream); var transactionsArr = ReadVarArray <Transaction>(stream); var transactions = new HashedArrayList <Transaction>(transactionsArr.Length); transactions.AddAll(transactionsArr); transactions.CollectionChanged += InvalidateMerkleTree; Transactions = transactions; Freeze(); }
protected override void Deserialize(Stream stream) { Version = ReadUInt32(stream); var transactionInputsArr = ReadVarArray <TransactionInput>(stream); var transactionInputs = new HashedArrayList <TransactionInput>(transactionInputsArr.Length); transactionInputs.AddAll(transactionInputsArr); transactionInputs.CollectionChanged += InputOutputChanged; TransactionInputs = transactionInputs; var transactionOutputsArr = ReadVarArray <TransactionOutput>(stream); var transactionOutputs = new HashedArrayList <TransactionOutput>(transactionOutputsArr.Length); transactionOutputs.AddAll(transactionOutputsArr); transactionOutputs.CollectionChanged += InputOutputChanged; TransactionOutputs = transactionOutputs; LockTime = ReadUInt32(stream); Freeze(); }
public static Sediment Extract(string bstDirectory, GeoRect region, float resolution, PercentProgress progress = null) { if (progress != null) lock (progress) progress.Report(0); var north = (float)Math.Round(region.North + 1); var south = (float)Math.Round(region.South - 1); var east = (float)Math.Round(region.East + 1); var west = (float)Math.Round(region.West - 1); if (progress != null) progress.MaximumValue = (((north - south) * (east - west)) + 3); var totalProgress = 0; var fileId = H5F.open(bstDirectory, H5F.OpenMode.ACC_RDONLY); var highResGroup = H5G.open(fileId, "0.10000/G/UNCLASSIFIED/"); var lowResGroup = H5G.open(fileId, "5.00000/G/UNCLASSIFIED/"); var dedupeList = new HashedArrayList<SedimentSample>(); for (var lat = south; lat < north; lat++) for (var lon = west; lon < east; lon++) { //var data = ReadDataset(highResGroup, 0.1, lowResGroup, 5.0, resolution, (int)lat, (int)lon); var data = ReadDatasetHierarchical(highResGroup, 0.1, lowResGroup, 5.0, resolution, (int)lat, (int)lon); if (data != null) dedupeList.AddAll(data); if (progress != null) lock (progress) progress.Report(totalProgress++); } var sediment = new Sediment(); if (progress != null) lock (progress) progress.Report(totalProgress++); sediment.Samples.AddRange(dedupeList); sediment.Samples.Sort(); sediment.Samples.TrimToNearestPoints(region); if (progress != null) lock (progress) progress.Report(totalProgress++); if (lowResGroup != null) H5G.close(lowResGroup); if (highResGroup != null) H5G.close(highResGroup); H5F.close(fileId); if (progress != null) lock (progress) progress.Report(totalProgress); return sediment; }