Beispiel #1
0
        public async Task <List <TransactionHeaderBase> > GetTransactionHeadersInfo(ulong syncBlockHeight, ulong round)
        {
            List <TransactionHeaderBase> transactionInfos = new List <TransactionHeaderBase>();

            int order = 0;
            AsyncServerStreamingCall <TransactionRegistryBlockInfo> asyncServerStreaming = _syncManagerClient.GetTransactionRegistryBlockInfos(new FullBlockRequest {
                SyncBlockHeight = syncBlockHeight, Round = round
            });

            while (await asyncServerStreaming.ResponseStream.MoveNext().ConfigureAwait(false))
            {
                TransactionRegistryBlockInfo item = asyncServerStreaming.ResponseStream.Current;

                switch (item.HeaderCase)
                {
                case TransactionRegistryBlockInfo.HeaderOneofCase.AccountedHeader:
                    transactionInfos.Add(new AccountedTransactionHeaderInfo
                    {
                        OrderInBlock    = order++,
                        SyncBlockHeight = item.AccountedHeader.SyncBlockHeight,
                        BlockHeight     = item.AccountedHeader.ReferencedHeight,
                        PacketType      = (PacketType)item.AccountedHeader.ReferencedPacketType,
                        BlockType       = (ushort)item.AccountedHeader.ReferencedBlockType,
                        Target          = item.AccountedHeader.ReferencedTarget.ToByteArray().ToHexString()
                    });
                    break;

                case TransactionRegistryBlockInfo.HeaderOneofCase.UtxoHeader:
                    transactionInfos.Add(new UtxoTransactionHeaderInfo
                    {
                        OrderInBlock    = order++,
                        SyncBlockHeight = item.UtxoHeader.SyncBlockHeight,
                        PacketType      = (PacketType)item.UtxoHeader.ReferencedPacketType,
                        BlockType       = (ushort)item.UtxoHeader.ReferencedBlockType,
                        TransactionKey  = item.UtxoHeader.ReferencedTransactionKey.ToByteArray().ToHexString(),
                        KeyImage        = item.UtxoHeader.KeyImage.ToByteArray().ToHexString(),
                        Target          = item.UtxoHeader.ReferencedTarget.ToByteArray().ToHexString()
                    });
                    break;
                }
            }

            return(transactionInfos);
        }
Beispiel #2
0
        public override Task GetTransactionRegistryBlockInfos(FullBlockRequest request, IServerStreamWriter <TransactionRegistryBlockInfo> responseStream, ServerCallContext context)
        {
            return(Task.Run(async() =>
            {
                RegistryFullBlock registryFullBlock = (RegistryFullBlock)_registryChainDataService.Get(new DoubleHeightKey(request.SyncBlockHeight, request.Round));

                foreach (RegistryRegisterBlock transactionWitness in registryFullBlock.StateWitnesses)
                {
                    TransactionRegistryBlockInfo blockInfo = new TransactionRegistryBlockInfo();

                    blockInfo.AccountedHeader = new AccountedTransactionHeaderDescriptor
                    {
                        SyncBlockHeight = transactionWitness.SyncBlockHeight,
                        ReferencedBlockType = transactionWitness.ReferencedBlockType,
                        ReferencedPacketType = (uint)transactionWitness.ReferencedPacketType,
                        ReferencedTarget = ByteString.CopyFrom(transactionWitness.ReferencedTarget),
                        ReferencedHeight = transactionWitness.BlockHeight
                    };

                    await responseStream.WriteAsync(blockInfo);
                }

                foreach (RegistryRegisterUtxoConfidential transactionWitness in registryFullBlock.UtxoWitnesses)
                {
                    TransactionRegistryBlockInfo blockInfo = new TransactionRegistryBlockInfo();

                    blockInfo.UtxoHeader = new UtxoTransactionHeaderDescriptor
                    {
                        SyncBlockHeight = transactionWitness.SyncBlockHeight,
                        ReferencedBlockType = transactionWitness.ReferencedBlockType,
                        ReferencedPacketType = (uint)transactionWitness.ReferencedPacketType,
                        ReferencedTarget = ByteString.CopyFrom(transactionWitness.DestinationKey),
                        ReferencedTransactionKey = ByteString.CopyFrom(transactionWitness.TransactionPublicKey),
                        KeyImage = ByteString.CopyFrom(transactionWitness.KeyImage.Value.ToArray())
                    };

                    await responseStream.WriteAsync(blockInfo);
                }
            }));
        }