mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
updating accounts from internal txs
This commit is contained in:
parent
3f6bdfc0e4
commit
ab8d98ad91
3 changed files with 54 additions and 17 deletions
|
|
@ -259,11 +259,20 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
|
||||||
log.Info("Writing custom genesis block")
|
log.Info("Writing custom genesis block")
|
||||||
}
|
}
|
||||||
block, err := genesis.Commit(db)
|
block, err := genesis.Commit(db)
|
||||||
|
//@NOTE:SHYFT SWITCH CASE ENSURES SHYFT GENESIS FUNCTIONS ARE ONLY CALLED ONCE
|
||||||
|
sqldb, _ := DBConnection()
|
||||||
|
serror := BlockExists(sqldb, block.Hash().String())
|
||||||
|
switch {
|
||||||
|
case serror == sql.ErrNoRows:
|
||||||
//@NOTE:SHYFT WRITE TO BLOCK ZERO DB
|
//@NOTE:SHYFT WRITE TO BLOCK ZERO DB
|
||||||
WriteShyftBlockZero(block, genesis)
|
WriteShyftBlockZero(block, genesis)
|
||||||
//@NOTE:SHYFT WRITE TO DB
|
//@NOTE:SHYFT WRITE TO DB
|
||||||
WriteShyftGen(genesis, block)
|
WriteShyftGen(genesis, block)
|
||||||
|
case serror != nil:
|
||||||
|
panic(serror)
|
||||||
|
default:
|
||||||
|
log.Info("Genesis Block Written")
|
||||||
|
}
|
||||||
return genesis.Config, block.Hash(), err
|
return genesis.Config, block.Hash(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import (
|
||||||
Rewards "github.com/ShyftNetwork/go-empyrean/consensus/ethash"
|
Rewards "github.com/ShyftNetwork/go-empyrean/consensus/ethash"
|
||||||
"github.com/ShyftNetwork/go-empyrean/shyfttracerinterface"
|
"github.com/ShyftNetwork/go-empyrean/shyfttracerinterface"
|
||||||
"strings"
|
"strings"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var IShyftTracer shyfttracerinterface.IShyftTracer
|
var IShyftTracer shyfttracerinterface.IShyftTracer
|
||||||
|
|
@ -40,6 +41,19 @@ type SBlock struct {
|
||||||
Blocks []SBlock
|
Blocks []SBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type InteralWrite struct {
|
||||||
|
Hash string
|
||||||
|
Type string
|
||||||
|
From string
|
||||||
|
To string
|
||||||
|
Value string
|
||||||
|
Gas uint64
|
||||||
|
GasUsed uint64
|
||||||
|
Input string
|
||||||
|
Output string
|
||||||
|
Time string
|
||||||
|
}
|
||||||
|
|
||||||
//blockRes struct
|
//blockRes struct
|
||||||
type blockRes struct {
|
type blockRes struct {
|
||||||
hash string
|
hash string
|
||||||
|
|
@ -482,4 +496,14 @@ func InsertTx (sqldb *sql.DB, txData ShyftTxEntryPretty) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InsertInternalTx(sqldb *sql.DB, i InteralWrite) {
|
||||||
|
var returnValue string
|
||||||
|
sqlStatement := `INSERT INTO internaltxs(type, txhash, from_addr, to_addr, amount, gas, gasUsed, time, input, output) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10)) RETURNING txHash`
|
||||||
|
qerr := sqldb.QueryRow(sqlStatement, i.Type, i.Hash, i.From, i.To, i.Value, i.Gas, i.GasUsed, i.Time, i.Input, i.Output).Scan(&returnValue)
|
||||||
|
if qerr != nil {
|
||||||
|
fmt.Println(qerr)
|
||||||
|
panic(qerr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -603,18 +603,22 @@ func (i *Internals) SWriteInteralTxs(hash common.Hash) {
|
||||||
value, _ := hexutil.DecodeUint64(i.Value)
|
value, _ := hexutil.DecodeUint64(i.Value)
|
||||||
amount := strconv.FormatUint(value, 10)
|
amount := strconv.FormatUint(value, 10)
|
||||||
|
|
||||||
//@TODO WRITE OVER TRANSACTION STRUCT
|
iTx := core.InteralWrite{
|
||||||
|
Hash: hash.Hex(),
|
||||||
core.SWriteInternalTxBalances(sqldb, i.To, i.From, amount)
|
Type: i.Type,
|
||||||
|
From: i.From,
|
||||||
var returnValue string
|
To: i.To,
|
||||||
sqlStatement := `INSERT INTO internaltxs(type, txhash, from_addr, to_addr, amount, gas, gasUsed, time, input, output) VALUES(($1), ($2), ($3), ($4), ($5), ($6), ($7), ($8), ($9), ($10)) RETURNING txHash`
|
Value: amount,
|
||||||
qerr := sqldb.QueryRow(sqlStatement, i.Type, hash.Hex(), i.From, i.To, amount, gas, gasUsed, i.Time, i.Input, i.Output).Scan(&returnValue)
|
Gas: gas,
|
||||||
|
GasUsed: gasUsed,
|
||||||
if qerr != nil {
|
Input: i.Input,
|
||||||
fmt.Println(qerr)
|
Output: i.Output,
|
||||||
panic(qerr)
|
Time: i.Time,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//@TODO WRITE OVER TRANSACTION STRUCT
|
||||||
|
core.SWriteInternalTxBalances(sqldb, i.To, i.From, amount)
|
||||||
|
core.InsertInternalTx(sqldb, iTx)
|
||||||
}
|
}
|
||||||
|
|
||||||
//@NOTE:SHYFT
|
//@NOTE:SHYFT
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue