Ejemplo n.º 1
0
        public DataChain(int chainId, uint chainIndex, Node.Node node, CoreChain coreChain, ServiceChain serviceChain, ChainKeyStore keyStore, int attachementKey) : base(ChainType.Data, chainId, chainIndex, node)
        {
            _coreChain    = coreChain;
            _serviceChain = serviceChain;
            Attachements  = node.AttachementManager;

            ChainKeyIndex = keyStore.KeyIndex;
            ChainKey      = keyStore.DecryptedKey;
            KeyStore      = keyStore;

            AttachementKey = attachementKey;

            var endPoints = new HashSet <AvailableEndPoint>();

            var chainInfo = _coreChain.GetChainInfo(ChainId);

            if (chainInfo != null)
            {
                var cep = chainInfo.GetPublicEndpoints();
                foreach (var ep in cep)
                {
                    var e = new Uri(ep);
                    if (IsValidAvailableEndPoint(e))
                    {
                        endPoints.Add(new AvailableEndPoint(e));
                    }
                }
            }

            AvailableEndpoints = new List <AvailableEndPoint>(endPoints);
        }
Ejemplo n.º 2
0
 public ChainContainer(ServiceChain serviceChain, Dictionary <uint, DataChain> dataChains, MaintainChain maintainChain, ServiceHost serviceHost)
 {
     ServiceChain  = serviceChain;
     DataChains    = dataChains;
     MaintainChain = maintainChain;
     ServiceHost   = serviceHost;
 }
Ejemplo n.º 3
0
        public ServiceBlockCouncil(Node.Node node, int chainId, ServiceChain serviceChain, MaintainChain maintainChain, short keyIndex, Key key) : base(node, Chain.ChainType.Service, chainId, 0, keyIndex, key)
        {
            _serviceChain  = serviceChain;
            _maintainChain = maintainChain;

            var chainInfo = node.ChainManager.CoreChain.GetChainInfo(chainId);

            if (chainInfo != null)
            {
                _chainAccountId = chainInfo.AccountId;
            }
        }
        public ServiceBlockGenerator(CoreChain coreChain, ServiceChain serviceChain, MaintainChain maintainChain, ServiceBlock lastBlock)
        {
            ChainId = serviceChain.ChainId;

            _blockInfo     = new ServiceBlockInfo(serviceChain);
            _coreChain     = coreChain;
            _serviceChain  = serviceChain;
            _maintainChain = maintainChain;
            _lastBlock     = lastBlock;
            _chainInfo     = coreChain.GetChainInfo(ChainId);
            _blockState    = _chainInfo.LastState;
        }
Ejemplo n.º 5
0
 public MaintainChain(ServiceChain serviceChain, Node.Node node) : base(ChainType.Maintain, serviceChain.ChainId, 0, node)
 {
     ServiceChain = serviceChain;
 }
            public bool AddRevenue(RequestRevenueServiceTransaction revenueTransaction, ServiceAccount serviceAccount, ServiceChain serviceChain)
            {
                var accountId = revenueTransaction.AccountId;

                if (!Revenues.ContainsKey(accountId))
                {
                    Revenues[accountId] = revenueTransaction;
                    Transactions.Add(revenueTransaction);
                    FeatureGenerator.AddTransaction(BlockTransactionGeneratorMode.Preprocess, serviceChain, revenueTransaction, serviceAccount);

                    return(true);
                }

                return(false);
            }
            public bool AddPurchase(PurchaseServiceTransaction purchaseTransaction, ServiceAccount serviceAccount, ServiceChain serviceChain)
            {
                var accountId = purchaseTransaction.AccountId;

                if (!Purchases.ContainsKey(accountId))
                {
                    Purchases[accountId] = purchaseTransaction;
                    Transactions.Add(purchaseTransaction);
                    FeatureGenerator.AddTransaction(BlockTransactionGeneratorMode.Preprocess, serviceChain, purchaseTransaction, serviceAccount);

                    return(true);
                }
                return(false);
            }
            public bool AddJoin(JoinServiceTransaction joinTransaction, ServiceAccount serviceAccount, ServiceChain serviceChain)
            {
                var accountId = joinTransaction.AccountId;

                if (!Joins.ContainsKey(accountId))
                {
                    Joins[accountId] = joinTransaction;
                    Transactions.Add(joinTransaction);
                    FeatureGenerator.AddTransaction(BlockTransactionGeneratorMode.Preprocess, serviceChain, joinTransaction, serviceAccount);

                    return(true);
                }
                return(false);
            }
 public ServiceBlockInfo(ServiceChain serviceChain)
 {
     FeatureGenerator = new BlockTransactionGenerator(serviceChain);
 }