Beispiel #1
0
        public bool GetDeployment(DeploymentProvider deployer)
        {
            //var newTrustedPeer = new MultiAddress("/ip4/178.79.181.244/tcp/4001/ipfs/QmSxrFXq85asEujMX7HpRRZP98cPsYDCnpTtqBuCh5DBKk");
            //client.TrustedPeers.Add(newTrustedPeer);

            var rootNode = AsyncContext.Run(() => _client.FileSystem.ListFileAsync(deployer.Hash));

            if (rootNode.IsDirectory)
            {
                foreach (var node in rootNode.Links)
                {
                    GetIpfsFile(deployer, node.Hash, node.Size, node.Name);
                }
            }
            else
            {
                GetIpfsFile(deployer, rootNode.Hash, rootNode.Size, rootNode.Name);
            }

            deployer.Decompress();

            deployer.SetComplete();

            return(true);
        }
Beispiel #2
0
        private void GetIpfsFile(DeploymentProvider deployer, string hash, long size, string name)
        {
            L.Info("Requesting data stream from IPFS (" + size + " bytes)");

            using (var f = AsyncContext.Run(() => _client.FileSystem.ReadFileAsync(hash)))
            {
                deployer.GetFromStream(f, size, name);
            }

            PinIpfsFile(hash);
        }
Beispiel #3
0
        private IpfsDeployStatus GetProject(string projectKey, Action onNewAssets = null)
        {
            var projectHash = RetrieveHashFromDns(projectKey);

            if (projectHash == null)
            {
                return(IpfsDeployStatus.DnsFailed);
            }

            Deployer = new DeploymentProvider(projectKey, projectHash, L);

            if (Deployer.IsRetrieved)
            {
                L.Info(projectKey + " is up to date.");
                return(IpfsDeployStatus.Completed);
            }

            if (!_raisedUi)
            {
                _raiseUi.Invoke();
            }

            _raisedUi = true;

            Daemon.Start();

            var state = TransferAssets();

            if (state.IsFailed)
            {
                return(state);
            }

            onNewAssets?.Invoke();

            if (state.IsCompleted)
            {
                L.Info(projectKey + " is updated.");
            }

            return(state);
        }