Пример #1
0
        public void PublishRestrictedTest()
        {
            var iota = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };
            var mam = new Mam(iota);
            string sideKey = "IREALLYENJOYPOTATORELATEDPRODUCTS";

            // Initialise MAM State
            var mamState = mam.InitMamState();
            mamState.ChangeMode(MamMode.Restricted, sideKey);

            // Create MAM Payload
            var mamMessage = mam.CreateMamMessage(mamState, "POTATO");

            Console.WriteLine($"Root: {mamMessage.Root}");
            Console.WriteLine($"Address: {mamMessage.Address}");

            // Attach the payload
            mam.Attach(mamMessage.Payload, mamMessage.Address);

            // Fetch Stream Async to Test
            var result = mam.Fetch(mamMessage.Root, MamMode.Restricted, sideKey);

            Console.WriteLine("Fetch result:");
            foreach (var message in result.Item1)
            {
                Console.WriteLine(message);
            }

            Console.WriteLine($"NextRoot:{result.Item2}");
        }
Пример #2
0
        public void PublishPublicTest()
        {
            var iota = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };
            var mam = new Mam(iota);
            string seed = "CNHIRWBWVPDBGHKYZDJEZVIRDBSEDTCRBESFXOGRSWWDQVRNQATQUKIVDUDINJKKNCULQFCWWIG9LAEHQ";

            // ReSharper disable once RedundantArgumentDefaultValue
            var mamState = mam.InitMamState(seed, 2);
            
            // Create MAM Payload
            var mamMessage = mam.CreateMamMessage(mamState, TrytesConverter.AsciiToTrytes("POTATO"));

            Console.WriteLine($"Root: {mamMessage.Root}");
            Console.WriteLine($"Address: {mamMessage.Address}");

            // Attach the payload
            mam.Attach(mamMessage.Payload, mamMessage.Address);

            // Fetch Stream Async to Test
            var result = mam.Fetch(mamMessage.Root, MamMode.Public);

            Console.WriteLine("Fetch result:");
            foreach (var message in result.Item1)
            {
                Console.WriteLine(message);
            }

            Console.WriteLine($"NextRoot:{result.Item2}");

        }