public async Task <ActionResult> GetChainServiceDynamicHandlerRaw(int chainid, string path)
        {
            Result result      = null;
            var    serviceHost = _node.ChainManager.GetServiceHost(chainid);

            if (serviceHost != null)
            {
                var uriProvider = serviceHost?.UriHandler;
                if (uriProvider != null && !string.IsNullOrEmpty(path))
                {
                    var r = await uriProvider.QueryDynamicUriData(path);

                    if (r != null)
                    {
                        result = new PackableResult <IPackable>(r);
                    }
                }

                if (result == null)
                {
                    result = Result.DataNotFound;
                }
            }
            else
            {
                result = Result.ChainNotFound;
            }

            return(File(result.ToByteArray(), "application/octet-stream", "result.data"));
        }
Beispiel #2
0
        public ActionResult GetRevokeableServiceAccountKey(int chainid, long accountid, string publicKey)
        {
            Result result;

            var chain = _node.ChainManager.GetServiceChain(chainid);

            if (chain != null)
            {
                var pk = Key.Restore(publicKey);
                if (chain.GetRevokealbeServiceAccountKey(accountid, pk, out var isValidAccount, out var revokeableKey))
                {
                    result = new PackableResult <RevokeablePublicServiceAccountKey>(revokeableKey);
                }
                else
                {
                    if (!isValidAccount)
                    {
                        result = Result.AccountNotFound;
                    }
                    else
                    {
                        result = Result.DataNotFound;
                    }
                }
            }
        public ActionResult GetServiceInfo(int chainid)
        {
            Result result = null;

            var chainContainer = _node.ChainManager.GetContainer(chainid);

            if (chainContainer != null)
            {
                var serviceInfo = chainContainer?.ServiceHost?.ServiceInfo;
                if (serviceInfo != null)
                {
                    result = new PackableResult <ServiceInfo>(serviceInfo);
                }
                else
                {
                    result = Result.DataNotFound;
                }
            }
            else
            {
                result = Result.ChainNotFound;
            }

            return(File(result.ToByteArray(), "application/octet-stream", "result.data"));
        }
Beispiel #4
0
        [Route("static/servicechain/{chainid:int}/account/{accountid:long}/key/{keyindex:int}/valid/result.data")] // keyindex:short throws asp exception
        public ActionResult GetValidServiceAccountKey(int chainid, long accountid, int keyindex)
        {
            Result result;

            var chain = _node.ChainManager.GetServiceChain(chainid);

            if (chain != null)
            {
                var key = chain.GetValidServiceAccountKey(accountid, (short)keyindex, Time.Timestamp);
                if (key != null)
                {
                    result = new PackableResult <PublicServiceAccountKey>(key);
                }
                else
                {
                    result = Result.AccountNotFound;
                }
            }
            else
            {
                result = Result.ChainNotFound;
            }

            return(File(result.ToByteArray(), "application/octet-stream", "result.data"));
        }
Beispiel #5
0
        public async Task <Download <PackableResult <T> > > QueryStaticServiceData <T>(int chainId, string path) where T : IPackable
        {
            try
            {
                var data = await DownloadBinary($"static/{GetChainTypeName(ChainType.Service)}/{chainId}/service/querydata/{path}");

                using (var unpacker = new Unpacker(data))
                {
                    var result = new PackableResult <T>(unpacker, (u) => (T)Activator.CreateInstance(typeof(T), u));
                    return(new Download <PackableResult <T> >(result));
                }
            }
            catch (Exception exception)
            {
                return(Download <PackableResult <T> > .HandleException(exception));
            }
        }
Beispiel #6
0
        public async Task <Download <PackableResult <AccountRevenueInfo> > > DownloadRevenueInfo(int chainId, long accountId)
        {
            try
            {
                var data = await DownloadBinary($"dynamic/{GetChainTypeName(ChainType.Maintain)}/{chainId}/revenue/{accountId}/result.data");

                using (var unpacker = new Unpacker(data))
                {
                    var chainInfo = new PackableResult <AccountRevenueInfo>(unpacker, (u) => new AccountRevenueInfo(u));
                    return(new Download <PackableResult <AccountRevenueInfo> >(chainInfo));
                }
            }
            catch (Exception exception)
            {
                return(Download <PackableResult <AccountRevenueInfo> > .HandleException(exception));
            }
        }
Beispiel #7
0
        public async Task <Download <PackableResult <RevokeablePublicServiceAccountKey> > > DownloadRevokeableServiceAccountKey(long accountId, int chainId, short keyIndex)
        {
            try
            {
                var data = await DownloadBinary($"dynamic/{GetChainTypeName(ChainType.Service)}/{chainId}/account/{accountId}/key/{keyIndex}/revokeable/result.data");

                using (var unpacker = new Unpacker(data))
                {
                    var chainKey = new PackableResult <RevokeablePublicServiceAccountKey>(unpacker, (u) => new RevokeablePublicServiceAccountKey(accountId, chainId, u));
                    return(new Download <PackableResult <RevokeablePublicServiceAccountKey> >(chainKey));
                }
            }
            catch (Exception exception)
            {
                return(Download <PackableResult <RevokeablePublicServiceAccountKey> > .HandleException(exception));
            }
        }
Beispiel #8
0
        public async Task <Download <PackableResult <ServiceInfo> > > DownloadServiceInfo(int chainId)
        {
            try
            {
                var data = await DownloadBinary($"dynamic/{GetChainTypeName(ChainType.Service)}/{chainId}/service/info/result.data");

                using (var unpacker = new Unpacker(data))
                {
                    var chainInfo = new PackableResult <ServiceInfo>(unpacker, (u) => new ServiceInfo(u));
                    return(new Download <PackableResult <ServiceInfo> >(chainInfo));
                }
            }
            catch (Exception exception)
            {
                return(Download <PackableResult <ServiceInfo> > .HandleException(exception));
            }
        }
        public ActionResult GetServiceInfo(int chainid, long accountid)
        {
            Result result = null;

            var maintainChain = _node.ChainManager.GetMaintainChain(chainid);

            if (maintainChain != null)
            {
                if (maintainChain.GetAccountRevenueInfo(accountid, out var accountRevenueInfo))
                {
                    result = new PackableResult <AccountRevenueInfo>(accountRevenueInfo);
                }
                else
                {
                    result = Result.AccountNotFound;
                }
            }
            else
            {
                result = Result.ChainNotFound;
            }

            return(File(result.ToByteArray(), "application/octet-stream", "result.data"));
        }