diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index fbd783ea31..14c6a34874 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -576,20 +576,35 @@ func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, er } type Internals struct { + Type string From string To string Value string Gas string GasUsed string + Input string + Output string + Time string Calls []*Internals } +//func (i *Internals) SWriteInteralTxs() { +// connStr := "user=postgres dbname=shyftdb sslmode=disable" +// sqldb, err := sql.Open("postgres", connStr) +// if err != nil { +// return +// } +// +// 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))` +// qerr := sqldb.QueryRow(sqlStatement, i.Type, txHash, i.From, i.To, i.Value, i.Gas, i.GasUsed, i.Time, i.Input, i.Output) +// +// if qerr != nil { +// panic(qerr) +// } +//} func (i *Internals) InternalRecursive() { - fmt.Println("[Internal To]", i.To) - fmt.Println("[Internal From]", i.From) lengthOfCalls := len(i.Calls) - fmt.Println("[LENGTH OF CALLS]", lengthOfCalls) if lengthOfCalls == 0 { return } diff --git a/shyft-cli/postgres_setup/create_tables.psql b/shyft-cli/postgres_setup/create_tables.psql index b746384bdc..259a95b23e 100644 --- a/shyft-cli/postgres_setup/create_tables.psql +++ b/shyft-cli/postgres_setup/create_tables.psql @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS blocks ( ); CREATE TABLE IF NOT EXISTS txs ( - txHash text, + txHash text primary key unique, to_addr text, from_addr text, blockhash text references blocks(hash), @@ -39,3 +39,20 @@ CREATE TABLE IF NOT EXISTS accounts ( txCountAccount numeric ); +CREATE TABLE IF NOT EXISTS contracts ( + txHash text +); + +CREATE TABLE IF NOT EXISTS internalTxs ( + id SERIAL PRIMARY KEY, + txHash text references txs(txHash), + type text, + to_addr text, + from_addr text, + amount text, + gas numeric, + gasUsed numeric, + time text, + input text, + output text +) \ No newline at end of file diff --git a/shyft-cli/postgres_setup/drop_tables.psql b/shyft-cli/postgres_setup/drop_tables.psql index 41563522dd..8826b85093 100644 --- a/shyft-cli/postgres_setup/drop_tables.psql +++ b/shyft-cli/postgres_setup/drop_tables.psql @@ -1,3 +1,5 @@ +DROP TABLE internalTxs; DROP TABLE txs; DROP TABLE blocks; DROP TABLE accounts; +DROP TABLE contracts; \ No newline at end of file