示例#1
0
        public async Task <IMdNode> CreateNewMdNodeAsync(MdMetadata metadata)
        {
            var mdInfo = await _networkOps.CreateEmptyMd(DataProtocol.DEFAULT_AD_PROTOCOL).ConfigureAwait(false);

            var dataOps = new MdDataOps(this, _networkOps, mdInfo);
            var newMd   = new MdNode(dataOps, _snapshotter);
            await newMd.Initialize(metadata).ConfigureAwait(false);

            return(newMd);
        }
示例#2
0
        public async Task <Result <IMdNode> > LocateAsync(MdLocator location)
        {
            // var mdResult = await networkDataOps.LocatePublicMd(location.XORName, location.TypeTag);
            var mdResult = await _networkOps.LocatePrivateMd(location.XORName, location.TypeTag, location.SecEncKey, location.Nonce)
                           .ConfigureAwait(false);

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

            var mdInfo  = mdResult.Value;
            var dataOps = new MdDataOps(this, _networkOps, mdInfo);
            var md      = new MdNode(dataOps, _snapshotter);
            await md.Initialize(metadata : null).ConfigureAwait(false);

            return(Result.OK((IMdNode)md));
        }