public void MigrarCid() { var conexao = Conexao.CreateSessionFactoryOracle(); CidsIntegracao defs = new CidsIntegracao(conexao.OpenSession()); var listaCidIntegracao = defs.All<CidMigracao>(); Cids repositorioCid = new Cids(Conexao.CreateSessionFactory().OpenSession()); List<Cid> listaCid = new List<Cid>(); foreach (var cidIntegracao in listaCidIntegracao) { var cid = new Cid(); cid.Code = cidIntegracao.CodigoCid; cid.Description = cidIntegracao.Descricao; listaCid.Add(cid); } repositorioCid.SalvarLista(listaCid); }
public void Deconstruct(out Delta delta, out Cid cid) { delta = Delta; cid = Cid; }
/// <inheritdoc /> public Task <Stream> ReadAsync(Cid cid, CancellationToken cancellationToken = default) { _logger.Debug("Reading content at path {0} from Ipfs", cid); return(_ipfs.FileSystem.ReadFileAsync(cid, cancellationToken)); }
/// <summary> /// Adds the <see cref="Cid"/> and <see cref="Peer"/> to the content routing system. /// </summary> /// <param name="cid"> /// The ID of some content that the <paramref name="provider"/> contains. /// </param> /// <param name="provider"> /// The peer ID that contains the <paramref name="cid"/>. /// </param> public void Add(Cid cid, MultiHash provider) { Add(cid, provider, DateTime.Now); }
public Task <IDataBlock> StatAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { throw new NotImplementedException(); }
/// <inheritdoc /> public async Task <Stream> ReadAsync(Cid cid, CancellationToken cancellationToken = default) { _logger.Debug("Reading content at path {0} from Dfs", cid); return(await _ipfs.FileSystem.ReadFileAsync(cid, cancellationToken).ConfigureAwait(false)); }
public async Task <bool> IsPinnedAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { return(await Store.ExistsAsync(id, cancel).ConfigureAwait(false)); }
public Task <IEnumerable <Cid> > RemoveAsync(Cid id, bool recursive = true, CancellationToken cancel = default(CancellationToken)) { throw new NotImplementedException(); }
public Task ProvideAsync(Cid cid, bool advertise = true, CancellationToken cancel = default(CancellationToken)) { throw new NotImplementedException(); }
private string Key(Cid cid) { return("/providers/" + cid.Hash.ToBase32()); }
public async Task <DagNode> GetAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { var block = await ipfs.Block.GetAsync(id, cancel).ConfigureAwait(false); return(new DagNode(block.DataStream)); }
public async Task <Stream> DataAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { var node = await GetAsync(id, cancel).ConfigureAwait(false); return(node.DataStream); }
public Task <IEnumerable <Peer> > FindProvidersAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { throw new NotImplementedException(); }
public async Task <IEnumerable <Peer> > FindProvidersAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { var stream = await ipfs.PostDownloadAsync("dht/findprovs", cancel, id); return(ProviderFromStream(stream)); }
/// <inheritdoc /> public async Task <string> ReadTextAsync(Cid cid, CancellationToken cancellationToken = default) { return(await _fileSystem.File.ReadAllTextAsync(Path.Combine(_baseFolder.FullName, cid), Encoding.UTF8, cancellationToken)); }
/// <inheritdoc /> public async Task <Stream> ReadAsync(Cid cid, CancellationToken cancellationToken = default) { return(await Task.FromResult(_fileSystem.File.OpenRead(Path.Combine(_baseFolder.FullName, cid))) .ConfigureAwait(false)); }
public string GetCandidateListCacheKey(Cid previousDeltaHash) { return(nameof(DeltaElector) + "-" + previousDeltaHash); }
public async Task UnwantAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { (await ipfs.BitswapService.ConfigureAwait(false)).Unwant(id); }
public static Cid ToCid(this byte[] cid) { return(Cid.Decode(MultiBase.Encode(cid, Encoding))); }
private static bool InternalCheckHash(byte[] data, Cid cid) => cid.Prefix.Sum(data) == cid;
/// <summary> /// Resolve an "IPFS path" to a content ID. /// </summary> /// <param name="path"> /// A IPFS path, such as "Qm...", "Qm.../a/b/c" or "/ipfs/QM..." /// </param> /// <param name="cancel"> /// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised. /// </param> /// <returns> /// The content ID of <paramref name="path"/>. /// </returns> /// <exception cref="ArgumentException"> /// The <paramref name="path"/> cannot be resolved. /// </exception> public async Task <Cid> ResolveIpfsPathToCidAsync(string path, CancellationToken cancel = default(CancellationToken)) { var r = await Generic.ResolveAsync(path, true, cancel).ConfigureAwait(false); return(Cid.Decode(r.Remove(0, 6))); // strip '/ipfs/'. }
public Task <Stream> DataAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { throw new NotImplementedException(); }
public Task <Cid> RemoveAsync(Cid id, bool ignoreNonexistent = false, CancellationToken cancel = default(CancellationToken)) { throw new NotImplementedException(); }
public Task <DagNode> GetAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { throw new NotImplementedException(); }
string Key(Cid cid) => "/providers/" + cid.Hash.ToBase32();
public Task <IEnumerable <IMerkleLink> > LinksAsync(Cid id, CancellationToken cancel = default(CancellationToken)) { throw new NotImplementedException(); }
/// <inheritdoc /> public Task <string> ReadTextAsync(Cid cid, CancellationToken cancellationToken = default) { _logger.Debug("Reading content at path {0} from IPFS", cid); return(_ipfs.FileSystem.ReadAllTextAsync(cid, cancellationToken)); }
public static Cid ToCid(this string cid) { //MultiBase.Encode(cid.ToUtf8Bytes(), Encoding) return(Cid.Decode(cid)); }
/// <summary> /// Get the strong ETag for a CID. /// </summary> protected EntityTagHeaderValue ETag(Cid id) { return(new EntityTagHeaderValue(new StringSegment("\"" + id + "\""), isWeak: false)); }
public async Task <IDataBlock> GetAsync(Cid id, CancellationToken cancel = default) { // Hack for empty object and empty directory object var emptyDirectory = GetEmptyDirectory(); if (id == emptyDirectory.Id) { return(emptyDirectory); } var emptyNode = GetEmptyNode(); if (id == emptyNode.Id) { return(emptyNode); } // If identity hash, then CID has the content. if (id.Hash.IsIdentityHash) { return(new DataBlock { DataBytes = id.Hash.Digest, Id = id, Size = id.Hash.Digest.Length }); } // Check the local filesystem for the block. var block = await Store.TryGetAsync(id, cancel).ConfigureAwait(false); if (block != null) { return(block); } // Query the network, via DHT, for peers that can provide the // content. As a provider peer is found, it is connected to and // the bitSwap want lists are exchanged. Hopefully the provider will // then send the block to us via bitSwap and the get task will finish. using (var queryCancel = CancellationTokenSource.CreateLinkedTokenSource(cancel)) { var bitswapGet = await _bitSwapApi.GetAsync(id, queryCancel.Token).ConfigureAwait(false); var _ = _dhtApi.FindProvidersAsync( id, 20, // TODO: remove this peer => { var __ = ProviderFoundAsync(peer, queryCancel.Token).ConfigureAwait(false); }, queryCancel.Token ); //log.Debug("bitswap got the block"); queryCancel.Cancel(false); // stop the network query. return(bitswapGet); } //using (var queryCancel = CancellationTokenSource.CreateLinkedTokenSource(cancel)) //{ // var bitSwapGet = _bitSwapApi.GetAsync(id, queryCancel.Token).ConfigureAwait(false); // var providers = await _dhtApi.FindProvidersAsync( // id: id, // cancel: queryCancel.Token // ); // var enumerable = providers as Peer[] ?? providers.ToArray(); // for (var index = 0; index < enumerable.ToArray().Length; index++) // { // var peer = enumerable.ToArray()[index]; // var _ = ProviderFoundAsync(peer, queryCancel.Token).ConfigureAwait(false); // } // var got = await bitSwapGet; // Log.Debug("bitSwap got the block"); // queryCancel.Cancel(false); // stop the network query. // return got; //} }
public async Task <Cid> PutAsync(byte[] data, string contentType = Cid.DefaultContentType, string multiHash = MultiHash.DefaultAlgorithmName, string encoding = MultiBase.DefaultAlgorithmName, bool pin = false, CancellationToken cancel = default) { if (data.Length > _dfsOptions.Block.MaxBlockSize) { throw new ArgumentOutOfRangeException($"data.Length", $@"Block length can not exceed {_dfsOptions.Block.MaxBlockSize.ToString()}."); } // Small enough for an inline CID? if (_dfsOptions.Block.AllowInlineCid && data.Length <= _dfsOptions.Block.InlineCidLimit) { return(new Cid { ContentType = contentType, Hash = MultiHash.ComputeHash(data, "identity") }); } // CID V1 encoding defaulting to base32 which is not var cid = new Cid { ContentType = contentType, Hash = MultiHash.ComputeHash(data, multiHash) }; if (encoding != "base58btc") { cid.Encoding = encoding; } var block = new DataBlock { DataBytes = data, Id = cid, Size = data.Length }; if (await Store.ExistsAsync(cid, cancel).ConfigureAwait(false)) { Log.DebugFormat("Block '{0}' already present", cid); } else { await Store.PutAsync(cid, block, cancel).ConfigureAwait(false); if (_dfsState.IsStarted) { await _dhtApi.ProvideAsync(cid, false, cancel).ConfigureAwait(false); } Log.DebugFormat("Added block '{0}'", cid); } // Inform the BitSwap service. _bitSwapApi.FoundBlock(block); // To pin or not. if (pin) { await PinApi.AddAsync(cid, false, cancel).ConfigureAwait(false); } else { await PinApi.RemoveAsync(cid, false, cancel).ConfigureAwait(false); } return(cid); }
public void TokenCallback(ParadoxParser parser, string token) { switch (token) { case "actual_added_value": actualAddedValue = parser.ReadInt32(); break; case "value": value = parser.ReadInt32(); break; case "from": from = parser.ReadInt32(); break; case "modifier": modifier = parser.Parse(new Cid()); break; } }