Example #1
0
        protected override IEnumerable <TransactionDeclarationEntity> Transform(DataTransformationContext context)
        {
            var signedLedgerState = context.SignedLedgerState;

            var list               = new List <TransactionDeclarationEntity>();
            var processed          = new ProcessedDeclarations();
            var declarationContext = new TransactionDeclarationContext();
            var transactions       = signedLedgerState.Ledger.Ledger.Block.Transactions;

            foreach (var transaction in transactions)
            {
                var hash  = transaction.Hash;
                var index = 0;
                foreach (var declaration in transaction.Transaction.Declarations)
                {
                    var entity = new TransactionDeclarationEntity(hash, index++, GetDeclarationId(declaration, processed));
                    list.Add(entity);
                    processed.Add(entity, declaration);
                    declarationContext.TryAdd(entity, declaration);
                }
            }

            context.SetDeclarations(declarationContext);

            return(list);
        }
Example #2
0
        protected override IEnumerable <TxInputOutputFull> Transform(DataTransformationContext context)
        {
            var signedLedgerState = context.SignedLedgerState;
            var list         = new List <TxInputOutputFull>();
            var transactions = signedLedgerState.Ledger.Ledger.Block.Transactions;

            foreach (var transaction in transactions)
            {
                var hash = transaction.Hash;

                if (transaction.Transaction.Fees != null)
                {
                    list.Add(new TxInputOutputFull(transaction.Transaction.Fees, hash, 0));
                }

                byte index = 1;
                foreach (var input in transaction.Transaction.Inputs)
                {
                    list.Add(new TxInputOutputFull(input, hash, index++));
                }

                foreach (var input in transaction.Transaction.Outputs)
                {
                    list.Add(new TxInputOutputFull(input, hash, index++));
                }
            }

            return(list);
        }
Example #3
0
        protected override IEnumerable <MultiSignatureEntity> Transform(DataTransformationContext context)
        {
            var multiSignatures = context.SignedLedgerState.State.MultiSignatures;
            var declarations    = context.GetDeclarations();
            var list            = new List <MultiSignatureEntity>();

            foreach (var multiSignature in multiSignatures)
            {
                list.Add(new MultiSignatureEntity(GetDeclarationId(declarations.AddressDeclarations, multiSignature.Address), multiSignature.Hash, new MultiSignatureAccount(multiSignature.Address, multiSignature.Required)));
            }
            return(list);
        }
Example #4
0
        protected override IEnumerable <HashLockEntity> Transform(DataTransformationContext context)
        {
            var hashlocks    = context.SignedLedgerState.State.HashLocks;
            var list         = new List <HashLockEntity>();
            var declarations = context.GetDeclarations();

            foreach (var locker in hashlocks)
            {
                list.Add(new HashLockEntity(GetDeclarationId(declarations.AddressDeclarations, locker.Address), new HashLockAccount(locker.Address, locker.SecretHash)));
            }
            return(list);
        }
        protected override IEnumerable <SignedTransactionSimple> Transform(DataTransformationContext context)
        {
            var signedLedgerState = context.SignedLedgerState;
            var list         = new List <SignedTransactionSimple>();
            var transactions = signedLedgerState.Ledger.Ledger.Block.Transactions;

            foreach (var transaction in transactions)
            {
                list.Add(new SignedTransactionSimple(transaction.Hash, signedLedgerState.Ledger.Ledger.LedgerLight.Height, transaction.Transaction.Expire, signedLedgerState.Ledger.Ledger.LedgerLight.Timestamp));
            }
            return(list);
        }
        protected override IEnumerable <VendingMachineEntity> Transform(DataTransformationContext context)
        {
            var machines = context.SignedLedgerState.State.VendingMachines;
            var list     = new List <VendingMachineEntity>();

            var declarations = context.GetDeclarations();

            foreach (var machine in machines)
            {
                list.Add(new VendingMachineEntity(GetDeclarationId(declarations.AddressDeclarations, machine.Address), new VendingMachineAccount(machine.Address, machine.Owner, machine.CurrencyIn, machine.CurrencyOut, machine.Rate)));
            }
            return(list);
        }
        protected override IEnumerable <MultiSignatureSigner> Transform(DataTransformationContext context)
        {
            var multiSignatures = context.SignedLedgerState.State.MultiSignatures;
            var list            = new List <MultiSignatureSigner>();

            foreach (var multiSignature in multiSignatures)
            {
                foreach (var signer in multiSignature.Signers)
                {
                    list.Add(new MultiSignatureSigner(multiSignature.Address, signer));
                }
            }
            return(list);
        }
        protected override IEnumerable <TransactionSignature> Transform(DataTransformationContext context)
        {
            var signedLedgerState = context.SignedLedgerState;
            var list         = new List <TransactionSignature>();
            var transactions = signedLedgerState.Ledger.Ledger.Block.Transactions;

            foreach (var transaction in transactions)
            {
                var hash = transaction.Hash;
                foreach (var signature in transaction.Signatures)
                {
                    list.Add(new TransactionSignature(signature, hash));
                }
            }
            return(list);
        }
        protected override IEnumerable <TransactionMessageEntity> Transform(DataTransformationContext context)
        {
            var signedLedgerState = context.SignedLedgerState;
            var list         = new List <TransactionMessageEntity>();
            var transactions = signedLedgerState.Ledger.Ledger.Block.Transactions;

            foreach (var transaction in transactions)
            {
                var hash = transaction.Hash;
                if (transaction.Transaction.Message != null && !transaction.Transaction.Message.Equals(TransactionMessage.Empty)) // TODO we don't really want to save empty messages, right?
                {
                    list.Add(new TransactionMessageEntity(hash, transaction.Transaction.Message));
                }
            }
            return(list);
        }
Example #10
0
        protected override IEnumerable <DeclarationEntity> Transform(DataTransformationContext context)
        {
            var signedLedgerState = context.SignedLedgerState;

            var list         = new List <DeclarationEntity>();
            var transactions = signedLedgerState.Ledger.Ledger.Block.Transactions;
            var declarations = context.GetDeclarations();
            var index        = 0;

            foreach (var transaction in transactions)
            {
                foreach (var declaration in transaction.Transaction.Declarations)
                {
                    list.Add(new DeclarationEntity(GetDeclarationId(declarations.Declarations, index), declaration.Type));
                    index++;
                }
            }
            return(list.Distinct());
        }
        protected override IEnumerable <SecretRevelationEntity> Transform(DataTransformationContext context)
        {
            var signedLedgerState = context.SignedLedgerState;
            var list         = new List <SecretRevelationEntity>();
            var transactions = signedLedgerState.Ledger.Ledger.Block.Transactions;
            var declarations = context.GetDeclarations();
            var index        = 0;

            foreach (var transaction in transactions)
            {
                foreach (var declaration in transaction.Transaction.Declarations)
                {
                    if (declaration.Type == DeclarationType.Secret)
                    {
                        var secret = (SecretRevelation)declaration;
                        list.Add(new SecretRevelationEntity(GetDeclarationId(declarations.Declarations, index), new SecretRevelation(secret.Secret)));
                    }
                    index++;
                }
            }
            return(list);
        }
Example #12
0
        protected override IEnumerable <BlockEntity> Transform(DataTransformationContext context)
        {
            var signedLedgerState = context.SignedLedgerState;

            return(new [] { new BlockEntity(signedLedgerState.Ledger.Ledger.Block) });
        }
 protected abstract IEnumerable <TItem> Transform(DataTransformationContext context);
        private void ProcessSave(DataTransformationContext context)
        {
            var transaction = new Database.SqlTransactions.TransformerSqlTransaction <TItem>(Transform(context), Repository, context.SignedLedgerState.Ledger.Ledger.LedgerLight.Height, Logger);

            DatabaseService.SqlTransactionManager.ExecuteTransaction(transaction);
        }
 public void ProcessNext(DataTransformationContext context)
 {
     queue.Enqueue(context);
     trigger.Set();
 }