Exemplo n.º 1
0
        // TODO replace with two functions:
        // IsContractActive(contractHash), which checks if the contract is in the ACS on disk or in the contractpool;
        // bool IsContractGeneratedTransactionValid(dbtx, contracthash, ptx), which raises an exception if called with a missing contract
        //public static bool IsContractGeneratedTransactionValid(TransactionContext dbTx, TransactionValidation.PointedTransaction ptx, byte[] contractHash)
        //{
        //	var chainTip = new ChainTip().Context(dbTx).Value;
        //	var tipBlockHeader = chainTip == null ? null : new BlockStore().GetBlock(dbTx, chainTip).Value.header;
        //	return xValid(ptx, contractHash, utxos, tipBlockHeader);
        //}

        public void InitBlockTimestamps(TransactionContext dbTx)
        {
            if (Tip != null)
            {
                var timestamps = new List <long>();
                var itr        = Tip.Value;

                while (itr != null && timestamps.Count < BlockTimestamps.SIZE)
                {
                    timestamps.Add(itr.header.timestamp);

                    if (itr.header.parent.Length == 0)
                    {
                        break;
                    }

                    var bk = BlockStore.GetBlock(dbTx, itr.header.parent);

                    System.Diagnostics.Debug.Assert(bk != null);

                    itr = bk.Value;
                }
                Timestamps.Init(timestamps.ToArray());
            }
        }