mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
need to clean up updating account balances functions
This commit is contained in:
parent
2abd54c29e
commit
3acdd3f5c5
3 changed files with 12 additions and 15 deletions
|
|
@ -147,7 +147,7 @@ func SWriteBlock(block *types.Block, receipts []*types.Receipt) error {
|
|||
for _, tx := range block.Transactions() {
|
||||
swriteTransactions(sqldb, tx, block.Header().Hash(), blockData.Number, receipts, age, blockData.GasLimit)
|
||||
if block.Transactions()[0].To() != nil {
|
||||
swriteFromBalance(sqldb, tx)
|
||||
swriteBalance(sqldb, tx)
|
||||
}
|
||||
if block.Transactions()[0].To() == nil {
|
||||
swriteContractBalance(sqldb, tx)
|
||||
|
|
@ -247,8 +247,8 @@ func swriteContractBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//writeFromBalance writes senders balance to accounts db
|
||||
func swriteFromBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
//writeBalance writes senders balance to accounts db
|
||||
func swriteBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||
sendAndReceiveData := SendAndReceive{
|
||||
To: tx.To().Hex(),
|
||||
From: tx.From().Hex(),
|
||||
|
|
@ -278,7 +278,6 @@ func adjustBalanceFromAddr(sqldb *sql.DB, s SendAndReceive, value *big.Int) {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var newBalanceSender, newAccountNonceSender big.Int
|
||||
var nonceIncrement = big.NewInt(1)
|
||||
|
||||
|
|
@ -335,13 +334,14 @@ func SWriteInternalTxBalances(sqldb *sql.DB, toAddr string, fromAddr string, amo
|
|||
From: fromAddr,
|
||||
Amount: amount,
|
||||
}
|
||||
|
||||
toAddressBalance, toAccountNonce, err := AccountExists(sqldb, sendAndReceiveData.To)
|
||||
|
||||
value := new(big.Int)
|
||||
value, _ = value.SetString(amount, 10)
|
||||
switch {
|
||||
case err == sql.ErrNoRows:
|
||||
accountNonce := "1"
|
||||
CreateAccount(sqldb, sendAndReceiveData.To, sendAndReceiveData.Amount, accountNonce)
|
||||
adjustBalanceFromAddr(sqldb, sendAndReceiveData, value)
|
||||
case err != nil:
|
||||
log.Fatal(err)
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ import (
|
|||
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/ShyftNetwork/go-empyrean/core"
|
||||
"github.com/gorilla/mux"
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// GetTransaction gets txs
|
||||
|
|
@ -239,7 +240,7 @@ func BroadcastTx(w http.ResponseWriter, r *http.Request) {
|
|||
fmt.Fprintln(w, "ERROR parsing json")
|
||||
}
|
||||
tx_hash := dat["result"]
|
||||
if(tx_hash == nil) {
|
||||
if tx_hash == nil {
|
||||
errMap := dat["error"].(map[string]interface{})
|
||||
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
|
|
|||
|
|
@ -362,7 +362,3 @@ func TestBlock(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
//Genesis.go functions
|
||||
// WriteBlockZero
|
||||
// WriteShyftGen
|
||||
|
|
|
|||
Loading…
Reference in a new issue