public async Task <Result <Pointer> > UpdateAsync(string type, MdLocator location) { var(pointer, value) = (await _dataTree.GetAllPointerValuesAsync().ConfigureAwait(false)) .Single(c => c.Item1.MdKey == type); var mdResult = await MdAccess.LocateAsync(pointer.MdLocator).ConfigureAwait(false); if (!mdResult.HasValue) { return(Result.Fail <Pointer>(mdResult.ErrorCode.Value, mdResult.ErrorMsg)); } value.Payload = location.Json(); return(await mdResult.Value.SetAsync(type, value).ConfigureAwait(false)); }
public static IMd Locate(MdLocator location) { // try find on network var key = location.Json(); if (!_allMds.ContainsKey(key)) // if not found, create with level 0 { var md = InMemoryMd.Create(level: 0); _allMds[md.MdLocator.Json()] = md; return(md); } return(_allMds[key]); }
public static Task <Result <IMd> > LocateAsync(MdLocator location) { return(_locator(location)); }
private InMemoryMd(int level) { MdLocator = new MdLocator(new byte[32], DataProtocol.DEFAULT_PROTOCOL); _rand.NextBytes(MdLocator.XORName); _valueFields["0"] = new StoredValue(level); }
public async Task AddAsync(string type, MdLocator location) { var value = new StoredValue(location); await _dataTree.AddAsync(type, value).ConfigureAwait(false); }