Exemple #1
0
        public static async Task <Result <IMd> > LocateAsync(MdLocator location, NetworkDataOps networkDataOp)
        {
            var mdResult = await networkDataOp.LocatePublicMd(location.XORName, location.TypeTag);

            if (!mdResult.HasValue)
            {
                return(new KeyNotFound <IMd>($"Could not locate md: {location.TypeTag}, {location.XORName}"));
            }

            var mdInfo = mdResult.Value;
            var md     = new MdOps(mdInfo, networkDataOp.Session);
            await md.GetOrAddMetadata();

            return(Result.OK((IMd)md));
        }
Exemple #2
0
        public static async Task <IMd> CreateNewMdOpsAsync(int level, NetworkDataOps networkDataOps, ulong protocol)
        {
            var session = networkDataOps.Session;

            // Create Permissions
            using (var permissionsHandle = await session.MDataPermissions.NewAsync())
            {
                using (var appSignPkH = await session.Crypto.AppPubSignKeyAsync())
                {
                    await session.MDataPermissions.InsertAsync(permissionsHandle, appSignPkH, networkDataOps.GetFullPermissions());
                }

                var mdInfo = await networkDataOps.CreateEmptyRandomPrivateMd(permissionsHandle, protocol);

                var newMd = new MdOps(mdInfo, session);
                await newMd.Initialize(level).ConfigureAwait(false);

                return(newMd);
            }
        }
 public Task <Result <IMd> > LocateMdOps(MdLocator location)
 {
     return(MdOps.LocateAsync(location, new NetworkDataOps(Session)));
 }
 public Task <IMd> CreateNewMdOps(int level, ulong protocol)
 {
     return(MdOps.CreateNewMdOpsAsync(level, new NetworkDataOps(Session), protocol));
 }