Esempio n. 1
0
 public TxMessage(byte[] txHash, TransactionValidation.PointedTransaction ptx, TxStateEnum state)
 {
     BlockChainTrace.Information("To wallet: " + state, txHash);
     TxHash = txHash;
     Ptx    = ptx;
     State  = state;
 }
Esempio n. 2
0
        public void AddRef(byte[] txHash, ACSItem acsItem)
        {
            BlockChainTrace.Information("contract ref added", acsItem.Hash);
            BlockChainTrace.Information(" by", txHash);

            if (!ContainsKey(acsItem.Hash))
            {
                this[acsItem.Hash] = ContractsPoolItem.FromACSItem(acsItem);
            }

            var contractsPoolItem = this[acsItem.Hash];

            contractsPoolItem.Refs++;

            _Txs[txHash] = acsItem.Hash;
        }
Esempio n. 3
0
        public Keyed <Types.Block> GetBlock(TransactionContext transactionContext, byte[] key)
        {
            var _block = Get(transactionContext, key);

            if (_block == null)
            {
                BlockChainTrace.Information("Block not found: " + Convert.ToBase64String(key));
                return(null);
            }
            else
            {
                var txs = _block.Value.TxHashes.Select(t => TxStore.Get(transactionContext, t).Value).ToList();

                var block = new Types.Block(_block.Value.BlockHeader, ListModule.OfSeq <Types.Transaction>(txs.Select(t => t.Tx)));

                return(new Keyed <Types.Block>(key, block));
            }
        }
Esempio n. 4
0
        public void MoveToICTxPool(HashSet activeContracts)
        {
            foreach (var item in this.ToList())
            {
                byte[] contractHash;

                if (BlockChain.IsContractGeneratedTx(item.Value, out contractHash) == BlockChain.IsContractGeneratedTxResult.ContractGenerated &&
                    !activeContracts.Contains(contractHash))
                {
                    BlockChainTrace.Information("inactive contract-generated tx moved to ICTxPool", contractHash);
                    Remove(item.Key);
                    ICTxPool.Add(item.Key, item.Value);

                    GetDependencies(item.Key)
                    .Where(t => t.Item1 is KnownTxPool)
                    .ToList().ForEach(t => ((KnownTxPool)t.Item1).MoveToOrphansWithDependencies(t.Item2));
                }
            }
        }
Esempio n. 5
0
        public new void Remove(byte[] txHash)
        {
            if (!_Txs.ContainsKey(txHash))
            {
                return;
            }

            var contractHash = _Txs[txHash];
            var contract     = this[contractHash];

            _Txs.Remove(txHash);
            contract.Refs--;

            if (contract.Refs == 0)
            {
                BlockChainTrace.Information("contract ref removed", contractHash);
                BlockChainTrace.Information(" to", txHash);
                base.Remove(contractHash);
            }
        }