コード例 #1
0
ファイル: MessageManager.cs プロジェクト: 19317362/Amoeba
        public Task Upload(Tag tag, ChatMessage chatMessage, DigitalSignature digitalSignature, TimeSpan miningTime, CancellationToken token)
        {
            if (tag == null)
            {
                throw new ArgumentNullException(nameof(tag));
            }
            if (chatMessage == null)
            {
                throw new ArgumentNullException(nameof(chatMessage));
            }
            if (digitalSignature == null)
            {
                throw new ArgumentNullException(nameof(digitalSignature));
            }

            return(_coreManager.VolatileSetStream(ContentConverter.ToStream(chatMessage), TimeSpan.FromDays(360), token)
                   .ContinueWith(task =>
            {
                MulticastMetadata multicastMetadata;

                try
                {
                    var miner = new Miner(CashAlgorithm.Version1, -1, miningTime);
                    multicastMetadata = new MulticastMetadata("ChatMessage", tag, DateTime.UtcNow, task.Result, digitalSignature, miner, token);
                }
                catch (MinerException)
                {
                    return;
                }

                _coreManager.UploadMetadata(multicastMetadata);
            }));
        }
コード例 #2
0
ファイル: MessageManager.cs プロジェクト: 19317362/Amoeba
        public Task Upload(Store store, DigitalSignature digitalSignature, CancellationToken token)
        {
            if (store == null)
            {
                throw new ArgumentNullException(nameof(store));
            }
            if (digitalSignature == null)
            {
                throw new ArgumentNullException(nameof(digitalSignature));
            }

            return(_coreManager.VolatileSetStream(ContentConverter.ToStream(store), TimeSpan.FromDays(360), token)
                   .ContinueWith(task =>
            {
                _coreManager.UploadMetadata(new BroadcastMetadata("Store", DateTime.UtcNow, task.Result, digitalSignature));
            }));
        }