mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
now allows contracts to be written as txes in the tx table
This commit is contained in:
parent
f2f3ff8929
commit
e5c2cd1eaf
1 changed files with 18 additions and 6 deletions
|
|
@ -102,19 +102,31 @@ func WriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.Ha
|
||||||
|
|
||||||
txHash := txData.TxHash.Hex()
|
txHash := txData.TxHash.Hex()
|
||||||
from := txData.From.Hex()
|
from := txData.From.Hex()
|
||||||
to := txData.To.Hex()
|
|
||||||
blockHasher := txData.BlockHash
|
blockHasher := txData.BlockHash
|
||||||
amount := txData.Amount.String()
|
amount := txData.Amount.String()
|
||||||
gasPrice := txData.GasPrice.String()
|
gasPrice := txData.GasPrice.String()
|
||||||
nonce := txData.Nonce
|
nonce := txData.Nonce
|
||||||
gas := txData.Gas
|
gas := txData.Gas
|
||||||
data := txData.Data
|
data := txData.Data
|
||||||
|
to := txData.To
|
||||||
|
if(to == nil){
|
||||||
|
var retNonce string
|
||||||
|
sqlStatement := `INSERT INTO txs(txhash, from_addr, blockhash, amount, gasprice, gas, nonce, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8)) RETURNING nonce`
|
||||||
|
qerr := sqldb.QueryRow(sqlStatement, txHash, from, blockHasher, amount, gasPrice, gas, nonce, data).Scan(&retNonce)
|
||||||
|
|
||||||
sqlStatement := `INSERT INTO txs(txhash, to_addr, from_addr, blockhash, amount, gasprice, gas, nonce, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9)) RETURNING nonce`
|
if qerr != nil {
|
||||||
qerr := sqldb.QueryRow(sqlStatement, txHash, to, from, blockHasher, amount, gasPrice, gas, nonce, data).Scan(&nonce)
|
panic(qerr)
|
||||||
if qerr != nil {
|
}
|
||||||
panic(qerr)
|
} else {
|
||||||
|
var retNonce string
|
||||||
|
sqlStatement := `INSERT INTO txs(txhash, from_addr, to_addr, blockhash, amount, gasprice, gas, nonce, data) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9)) RETURNING nonce`
|
||||||
|
qerr := sqldb.QueryRow(sqlStatement, txHash, from, to.Hex(), blockHasher, amount, gasPrice, gas, nonce, data).Scan(&retNonce)
|
||||||
|
|
||||||
|
if qerr != nil {
|
||||||
|
panic(qerr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue