public void Execute(int transactionId)
        {
            var freebal = new TableName
            {
                MethodName = "FreeBalance",
                ModuleName = "Balances"
            };

            var curValueRow = new TableRow
            {
                RowName     = "value",
                BlockNumber = _pex.BlockNumber
            };

            BigInteger curValue = 0;
            var        sval     = _dbAdapter.GetLastStorageValue(freebal, curValueRow);

            if (!sval.Equals(""))
            {
                curValue = BigInteger.Parse(sval);
            }

            var part1 = new TableRow
            {
                RowName     = "value",
                BlockNumber = _pex.BlockNumber,
                Value       = new List <string> {
                    (amount + curValue).ToString()
                }
            };

            _dbAdapter.InsertIntoStorage(freebal, part1);

            var transactionSenderKey = new TableRow
            {
                RowIndex = 0,
                RowName  = "Sender",
                Value    = new List <string> {
                    sk
                }
            };

            var transfer = new TableName
            {
                MethodName = "bond_extra",
                ModuleName = "Staking"
            };

            var tid = new TableRow
            {
                RowIndex = 1,
                RowName  = "transactionindex",
                Value    = new List <string> {
                    transactionId.ToString()
                }
            };

            var maxAdditional = new TableRow
            {
                RowIndex = 1,
                RowName  = "max_additional",
                Value    = new List <string> {
                    amount.ToString()
                }
            };

            var blocknumber = new TableRow
            {
                RowIndex = 1,
                RowName  = "blocknumber",
                Value    = new List <string> {
                    _pex.BlockNumber.ToString()
                }
            };

            var nonce = new TableRow
            {
                RowIndex = 0,
                RowName  = "Nonce",
                Value    = new List <string> {
                    _pex.Nonce.ToString()
                }
            };

            var signatureKey = new TableRow
            {
                RowIndex = 0,
                RowName  = "Signature",
                Value    = new List <string> {
                    _pex.Signature
                }
            };

            var status = new TableRow
            {
                RowIndex = 0,
                RowName  = "Status",
                Value    = new List <string> {
                    _pex.Status.ToString()
                }
            };

            var blockHash = new TableRow
            {
                RowIndex = 0,
                RowName  = "Block",
                Value    = new List <string> {
                    _pex.BlockHash.ToString()
                }
            };

            _dbAdapter.InsertIntoCall(transfer, new List <TableRow> {
                blockHash, tid, signatureKey, status, nonce, transactionSenderKey, maxAdditional, blocknumber
            });
        }
Exemple #2
0
        public void Execute(int transactionId)
        {
            // Set FREEBALANCE for participants
            // Add transfer value

            var freebal = new TableName
            {
                MethodName = "FreeBalance",
                ModuleName = "Balances"
            };

            var curValueRow = new TableRow
            {
                RowName     = "value",
                BlockNumber = _pex.BlockNumber
            };

            BigInteger curValue = 0;
            var        sval     = _dbAdapter.GetLastStorageValue(freebal, curValueRow);

            if (!sval.Equals(""))
            {
                curValue = BigInteger.Parse(sval);
            }

            var intAmount = BigInteger.Parse(amount);

            var part1 = new TableRow
            {
                RowName     = "value",
                BlockNumber = _pex.BlockNumber,
                Value       = new List <string> {
                    (curValue - intAmount).ToString()
                }
            };

            var part2 = new TableRow
            {
                RowName     = "value",
                BlockNumber = _pex.BlockNumber,
                Value       = new List <string> {
                    (curValue + intAmount).ToString()
                }
            };

            _dbAdapter.InsertIntoStorage(freebal, part1);
            _dbAdapter.InsertIntoStorage(freebal, part2);

            var transfer = new TableName
            {
                MethodName = "transfer",
                ModuleName = "Balances"
            };

            var nonce = new TableRow
            {
                RowIndex = 0,
                RowName  = "Nonce",
                Value    = new List <string> {
                    _pex.Nonce.ToString()
                }
            };

            var blockHash = new TableRow
            {
                RowIndex = 0,
                RowName  = "Block",
                Value    = new List <string> {
                    _pex.BlockHash.ToString()
                }
            };

            var signatureKey = new TableRow
            {
                RowIndex = 0,
                RowName  = "Signature",
                Value    = new List <string> {
                    _pex.Signature
                }
            };

            var status = new TableRow
            {
                RowIndex = 0,
                RowName  = "Status",
                Value    = new List <string> {
                    _pex.Status.ToString()
                }
            };

            var transactionSenderKey = new TableRow
            {
                RowIndex = 0,
                RowName  = "Sender",
                Value    = new List <string> {
                    sk
                }
            };

            var transactionDest = new TableRow
            {
                RowIndex = 0,
                RowName  = "dest",
                Value    = new List <string> {
                    rk
                }
            };

            var transactionValue = new TableRow
            {
                RowIndex = 1,
                RowName  = "value",
                Value    = new List <string> {
                    amount
                }
            };

            var blocknumber = new TableRow
            {
                RowIndex = 0,
                RowName  = "blocknumber",
                Value    = new List <string> {
                    _pex.BlockNumber.ToString()
                }
            };

            var tid = new TableRow
            {
                RowIndex = 1,
                RowName  = "transactionindex",
                Value    = new List <string> {
                    transactionId.ToString()
                }
            };

            _dbAdapter.InsertIntoCall(transfer, new List <TableRow> {
                blockHash, tid, status, blocknumber, nonce, signatureKey, transactionDest, transactionValue, transactionSenderKey
            });
        }