mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
internals are being seen
This commit is contained in:
parent
3eab46ee8c
commit
fbf3fa25c7
6 changed files with 154 additions and 291 deletions
|
|
@ -265,15 +265,11 @@ func GetBlockReceipts(db DatabaseReader, hash common.Hash, number uint64) types.
|
||||||
// GetTxLookupEntry retrieves the positional metadata associated with a transaction
|
// GetTxLookupEntry retrieves the positional metadata associated with a transaction
|
||||||
// hash to allow retrieving the transaction or receipt by hash.
|
// hash to allow retrieving the transaction or receipt by hash.
|
||||||
func GetTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64) {
|
func GetTxLookupEntry(db DatabaseReader, hash common.Hash) (common.Hash, uint64, uint64) {
|
||||||
fmt.Println("[GetTxLookupEntry FUNCTION RAN]")
|
|
||||||
// Load the positional metadata from disk and bail if it fails
|
// Load the positional metadata from disk and bail if it fails
|
||||||
//fmt.Println("INSIDE GetTxLookupEntry ")
|
//fmt.Println("INSIDE GetTxLookupEntry ")
|
||||||
//fmt.Println("the db is ")
|
//fmt.Println("the db is ")
|
||||||
//fmt.Println(db)
|
//fmt.Println(db)
|
||||||
fmt.Println("the hash is", hash.String())
|
|
||||||
data, _ := db.Get(append(lookupPrefix, hash.Bytes()...))
|
data, _ := db.Get(append(lookupPrefix, hash.Bytes()...))
|
||||||
fmt.Println("the data is ")
|
|
||||||
fmt.Println(data)
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
return common.Hash{}, 0, 0
|
return common.Hash{}, 0, 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ _ "github.com/lib/pq"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
Rewards "github.com/ethereum/go-ethereum/consensus/ethash"
|
Rewards "github.com/ethereum/go-ethereum/consensus/ethash"
|
||||||
"github.com/ethereum/go-ethereum/shyfttracerinterface"
|
"github.com/ethereum/go-ethereum/shyfttracerinterface"
|
||||||
"reflect"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var IShyftTracer shyfttracerinterface.IShyftTracer
|
var IShyftTracer shyfttracerinterface.IShyftTracer
|
||||||
|
|
@ -174,11 +173,9 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H
|
||||||
}
|
}
|
||||||
|
|
||||||
hash := txData.TxHash
|
hash := txData.TxHash
|
||||||
fmt.Println(reflect.TypeOf(hash))
|
|
||||||
txHash := txData.TxHash.Hex()
|
txHash := txData.TxHash.Hex()
|
||||||
|
|
||||||
//prayer, _ := IShyftTracer.GetTracerToRun(hash)
|
IShyftTracer.GetTracerToRun(hash)
|
||||||
//fmt.Printf("%+v\n", prayer)
|
|
||||||
|
|
||||||
//var stack *node.Node
|
//var stack *node.Node
|
||||||
//var cfg *eth.Config
|
//var cfg *eth.Config
|
||||||
|
|
@ -292,6 +289,25 @@ func writeContractBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func writeContractBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, string, string) {
|
||||||
|
sendAndReceiveData := SendAndReceive{
|
||||||
|
From: tx.From().Hex(),
|
||||||
|
Amount: tx.Value().String(),
|
||||||
|
}
|
||||||
|
|
||||||
|
fromAddr := sendAndReceiveData.From
|
||||||
|
getAccountBalanceSender:= SGetAccount(sqldb, fromAddr)
|
||||||
|
|
||||||
|
var senderBalance SendAndReceive
|
||||||
|
if err := json.Unmarshal([]byte(getAccountBalanceSender), &senderBalance); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
balanceSender := senderBalance.Balance
|
||||||
|
accountNonceSender := senderBalance.TxCountAccount
|
||||||
|
|
||||||
|
return sendAndReceiveData, balanceSender, accountNonceSender
|
||||||
|
}
|
||||||
|
|
||||||
//writeFromBalance writes senders balance to accounts db
|
//writeFromBalance writes senders balance to accounts db
|
||||||
func writeFromBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
func writeFromBalance(sqldb *sql.DB, tx *types.Transaction) error {
|
||||||
sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := writeBalanceHelper(sqldb, tx)
|
sendAndReceiveData, balanceRec, balanceSen, accountNonceRec, accountNonceSen := writeBalanceHelper(sqldb, tx)
|
||||||
|
|
@ -375,8 +391,9 @@ func writeBalanceHelper(sqldb *sql.DB, tx *types.Transaction) (SendAndReceive, s
|
||||||
|
|
||||||
toAddr := sendAndReceiveData.To
|
toAddr := sendAndReceiveData.To
|
||||||
fromAddr := sendAndReceiveData.From
|
fromAddr := sendAndReceiveData.From
|
||||||
getAccountBalanceReceiver := GetAccount(sqldb, toAddr)
|
|
||||||
getAccountBalanceSender:= GetAccount(sqldb, fromAddr)
|
getAccountBalanceReceiver := SGetAccount(sqldb, toAddr)
|
||||||
|
getAccountBalanceSender:= SGetAccount(sqldb, fromAddr)
|
||||||
|
|
||||||
var receiverBalance SendAndReceive
|
var receiverBalance SendAndReceive
|
||||||
if err := json.Unmarshal([]byte(getAccountBalanceReceiver), &receiverBalance); err != nil {
|
if err := json.Unmarshal([]byte(getAccountBalanceReceiver), &receiverBalance); err != nil {
|
||||||
|
|
@ -495,7 +512,7 @@ func storeReward(sqldb *sql.DB, address string, reward *big.Int) {
|
||||||
//Look into postgres functions array_to_json(array_agg(lap))
|
//Look into postgres functions array_to_json(array_agg(lap))
|
||||||
//Example select array_to_json(array_agg(lap))
|
//Example select array_to_json(array_agg(lap))
|
||||||
//from ( select * from blocks)lap;
|
//from ( select * from blocks)lap;
|
||||||
func GetAllBlocks(sqldb *sql.DB) string {
|
func SGetAllBlocks(sqldb *sql.DB) string {
|
||||||
var arr blockRes
|
var arr blockRes
|
||||||
var blockArr string
|
var blockArr string
|
||||||
rows, err := sqldb.Query(`
|
rows, err := sqldb.Query(`
|
||||||
|
|
@ -616,7 +633,7 @@ func SGetBlock(sqldb *sql.DB, blockNumber string) string {
|
||||||
return string(json)
|
return string(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRecentBlock(sqldb *sql.DB) string {
|
func SGetRecentBlock(sqldb *sql.DB) string {
|
||||||
sqlStatement := `SELECT * FROM blocks WHERE number=(SELECT MAX(number) FROM blocks);`
|
sqlStatement := `SELECT * FROM blocks WHERE number=(SELECT MAX(number) FROM blocks);`
|
||||||
row := sqldb.QueryRow(sqlStatement)
|
row := sqldb.QueryRow(sqlStatement)
|
||||||
var hash string
|
var hash string
|
||||||
|
|
@ -669,7 +686,7 @@ func GetRecentBlock(sqldb *sql.DB) string {
|
||||||
return string(json)
|
return string(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
|
func SGetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
|
||||||
var arr txRes
|
var arr txRes
|
||||||
var txx string
|
var txx string
|
||||||
sqlStatement := `SELECT * FROM txs WHERE blocknumber=$1`
|
sqlStatement := `SELECT * FROM txs WHERE blocknumber=$1`
|
||||||
|
|
@ -737,7 +754,7 @@ func GetAllTransactionsFromBlock(sqldb *sql.DB, blockNumber string) string {
|
||||||
return txx
|
return txx
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string {
|
func SGetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string {
|
||||||
var arr blockRes
|
var arr blockRes
|
||||||
var blockArr string
|
var blockArr string
|
||||||
sqlStatement := `SELECT * FROM blocks WHERE coinbase=$1`
|
sqlStatement := `SELECT * FROM blocks WHERE coinbase=$1`
|
||||||
|
|
@ -804,7 +821,7 @@ func GetAllBlocksMinedByAddress(sqldb *sql.DB, coinbase string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetAllTransactions getter fn for API
|
//GetAllTransactions getter fn for API
|
||||||
func GetAllTransactions(sqldb *sql.DB) string {
|
func SGetAllTransactions(sqldb *sql.DB) string {
|
||||||
var arr txRes
|
var arr txRes
|
||||||
var txx string
|
var txx string
|
||||||
rows, err := sqldb.Query(`
|
rows, err := sqldb.Query(`
|
||||||
|
|
@ -931,7 +948,7 @@ func SGetTransaction(sqldb *sql.DB, txHash string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetAccount returns account balances
|
//GetAccount returns account balances
|
||||||
func GetAccount(sqldb *sql.DB, address string) string {
|
func SGetAccount(sqldb *sql.DB, address string) string {
|
||||||
sqlStatement := `SELECT * FROM accounts WHERE addr=$1;`
|
sqlStatement := `SELECT * FROM accounts WHERE addr=$1;`
|
||||||
row := sqldb.QueryRow(sqlStatement, address)
|
row := sqldb.QueryRow(sqlStatement, address)
|
||||||
var addr string
|
var addr string
|
||||||
|
|
@ -952,7 +969,7 @@ func GetAccount(sqldb *sql.DB, address string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetAllAccounts returns all accounts and balances
|
//GetAllAccounts returns all accounts and balances
|
||||||
func GetAllAccounts(sqldb *sql.DB) string {
|
func SGetAllAccounts(sqldb *sql.DB) string {
|
||||||
var array accountRes
|
var array accountRes
|
||||||
var accountsArr string
|
var accountsArr string
|
||||||
var txCountAccount string
|
var txCountAccount string
|
||||||
|
|
@ -991,7 +1008,7 @@ func GetAllAccounts(sqldb *sql.DB) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetAccount returns account balances
|
//GetAccount returns account balances
|
||||||
func GetAccountTxs(sqldb *sql.DB, address string) string {
|
func SGetAccountTxs(sqldb *sql.DB, address string) string {
|
||||||
var arr txRes
|
var arr txRes
|
||||||
var txx string
|
var txx string
|
||||||
sqlStatement := `SELECT * FROM txs WHERE to_addr=$1 OR from_addr=$1;`
|
sqlStatement := `SELECT * FROM txs WHERE to_addr=$1 OR from_addr=$1;`
|
||||||
|
|
|
||||||
|
|
@ -532,189 +532,6 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (*
|
||||||
// TraceTransaction returns the structured logs created during the execution of EVM
|
// TraceTransaction returns the structured logs created during the execution of EVM
|
||||||
// and returns them as a JSON object.
|
// and returns them as a JSON object.
|
||||||
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Hash, config *TraceConfig) (interface{}, error) {
|
||||||
fmt.Println("TRACE TRANSACTION ++++++!+!+!+!+!+!+!+!+!+!+!+!++!")
|
|
||||||
_, file, no, ok := runtime.Caller(1)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(2)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(3)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(4)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(5)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(6)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(7)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(8)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(9)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(10)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(11)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(12)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(13)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(14)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(15)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(16)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(17)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(18)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(19)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(20)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(21)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(22)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(23)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(24)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(25)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(26)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(27)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(28)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(29)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(30)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(31)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(32)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(33)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(34)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(35)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(36)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(37)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(38)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(39)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(40)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
fmt.Println("////////////// ++++++++++++++++ /////////////////// Phantom *(!*!*!*!*!*!**!*!*")
|
|
||||||
_, file, no, ok = runtime.Caller(41)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(42)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(43)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
_, file, no, ok = runtime.Caller(44)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
fmt.Println("////////////// ++++++++++++++++ /////////////////// TraceTransaction *(!*!*!*!*!*!**!*!*")
|
|
||||||
_, file, no, ok = runtime.Caller(45)
|
|
||||||
if ok {
|
|
||||||
fmt.Printf("called from %s#%d\n", file, no)
|
|
||||||
}
|
|
||||||
// NOTE:SHYFT
|
// NOTE:SHYFT
|
||||||
//fmt.Printf("\n\t[API_TRACER.GO api.config] %+v", api.config)
|
//fmt.Printf("\n\t[API_TRACER.GO api.config] %+v", api.config)
|
||||||
//fmt.Printf("\n\t[API_TRACER.GO api.eth] %+v\n", api.eth)
|
//fmt.Printf("\n\t[API_TRACER.GO api.eth] %+v\n", api.eth)
|
||||||
|
|
@ -729,7 +546,6 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha
|
||||||
return nil, fmt.Errorf("transaction %x not found", hash)
|
return nil, fmt.Errorf("transaction %x not found", hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("TX IN TRACETRANSACTION", tx)
|
|
||||||
reexec := defaultTraceReexec
|
reexec := defaultTraceReexec
|
||||||
if config != nil && config.Reexec != nil {
|
if config != nil && config.Reexec != nil {
|
||||||
reexec = *config.Reexec
|
reexec = *config.Reexec
|
||||||
|
|
@ -746,8 +562,6 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, hash common.Ha
|
||||||
// be tracer dependent.
|
// be tracer dependent.
|
||||||
func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, vmctx vm.Context, statedb *state.StateDB, config *TraceConfig) (interface{}, error) {
|
func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, vmctx vm.Context, statedb *state.StateDB, config *TraceConfig) (interface{}, error) {
|
||||||
// Assemble the structured logger or the JavaScript tracer
|
// Assemble the structured logger or the JavaScript tracer
|
||||||
fmt.Println("\n [API_TRACER.GO traceTX func]")
|
|
||||||
// fmt.Printf("%+v", config, "THIS IS CONFIG")
|
|
||||||
var (
|
var (
|
||||||
tracer vm.Tracer
|
tracer vm.Tracer
|
||||||
err error
|
err error
|
||||||
|
|
@ -756,23 +570,23 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
|
||||||
case config != nil && config.Tracer != nil:
|
case config != nil && config.Tracer != nil:
|
||||||
// Define a meaningful timeout of a single transaction trace
|
// Define a meaningful timeout of a single transaction trace
|
||||||
timeout := defaultTraceTimeout
|
timeout := defaultTraceTimeout
|
||||||
|
fmt.Println(timeout)
|
||||||
if config.Timeout != nil {
|
if config.Timeout != nil {
|
||||||
if timeout, err = time.ParseDuration(*config.Timeout); err != nil {
|
if timeout, err = time.ParseDuration(*config.Timeout); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Constuct the JavaScript tracer to execute with
|
// Constuct the JavaScript tracer to execute with
|
||||||
fmt.Printf("%+v \n", *config.Tracer)
|
|
||||||
if tracer, err = tracers.New(*config.Tracer); err != nil {
|
if tracer, err = tracers.New(*config.Tracer); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Handle timeouts and RPC cancellations
|
// Handle timeouts and RPC cancellations
|
||||||
deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
|
//deadlineCtx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
go func() {
|
//go func() {
|
||||||
<-deadlineCtx.Done()
|
// <-deadlineCtx.Done()
|
||||||
tracer.(*tracers.Tracer).Stop(errors.New("execution timeout"))
|
// tracer.(*tracers.Tracer).Stop(errors.New("execution timeout"))
|
||||||
}()
|
//}()
|
||||||
defer cancel()
|
//defer cancel()
|
||||||
|
|
||||||
case config == nil:
|
case config == nil:
|
||||||
tracer = vm.NewStructLogger(nil)
|
tracer = vm.NewStructLogger(nil)
|
||||||
|
|
@ -798,7 +612,6 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
case *tracers.Tracer:
|
case *tracers.Tracer:
|
||||||
fmt.Println("THIS RAN MF")
|
|
||||||
return tracer.GetResult()
|
return tracer.GetResult()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var EthereumObject interface{}
|
var EthereumObject interface{}
|
||||||
|
|
@ -26,7 +25,6 @@ func (st ShyftTracer) GetTracerToRun (hash common.Hash) (interface{}, error) {
|
||||||
Timeout: nil,
|
Timeout: nil,
|
||||||
Reexec: nil,
|
Reexec: nil,
|
||||||
}
|
}
|
||||||
fmt.Printf("%+v", config, "THIS IS CONFIG IN SHYFT_TRACER")
|
|
||||||
//var fullNode *Ethereum
|
//var fullNode *Ethereum
|
||||||
fullNode, _ := SNew(Global_config)
|
fullNode, _ := SNew(Global_config)
|
||||||
privateAPI := NewPrivateDebugAPI(config2, fullNode)
|
privateAPI := NewPrivateDebugAPI(config2, fullNode)
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
duktape "gopkg.in/olebedev/go-duktape.v3"
|
"gopkg.in/olebedev/go-duktape.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js.
|
// bigIntegerJS is the minified version of https://github.com/peterolson/BigInteger.js.
|
||||||
|
|
@ -307,13 +307,10 @@ type Tracer struct {
|
||||||
// which must evaluate to an expression returning an object with 'step', 'fault'
|
// which must evaluate to an expression returning an object with 'step', 'fault'
|
||||||
// and 'result' functions.
|
// and 'result' functions.
|
||||||
func New(code string) (*Tracer, error) {
|
func New(code string) (*Tracer, error) {
|
||||||
fmt.Println("\n [TRACER.GO New func]", code)
|
|
||||||
// Resolve any tracers by name and assemble the tracer object
|
// Resolve any tracers by name and assemble the tracer object
|
||||||
if tracer, ok := tracer(code); ok {
|
if tracer, ok := tracer(code); ok {
|
||||||
code = tracer
|
code = tracer
|
||||||
fmt.Println("\n [ok]", ok)
|
|
||||||
}
|
}
|
||||||
fmt.Println("\n [tracer]", tracer)
|
|
||||||
|
|
||||||
tracer := &Tracer{
|
tracer := &Tracer{
|
||||||
vm: duktape.New(),
|
vm: duktape.New(),
|
||||||
|
|
@ -328,6 +325,7 @@ func New(code string) (*Tracer, error) {
|
||||||
costValue: new(uint),
|
costValue: new(uint),
|
||||||
depthValue: new(uint),
|
depthValue: new(uint),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up builtins for this environment
|
// Set up builtins for this environment
|
||||||
tracer.vm.PushGlobalGoFunction("toHex", func(ctx *duktape.Context) int {
|
tracer.vm.PushGlobalGoFunction("toHex", func(ctx *duktape.Context) int {
|
||||||
ctx.PushString(hexutil.Encode(popSlice(ctx)))
|
ctx.PushString(hexutil.Encode(popSlice(ctx)))
|
||||||
|
|
@ -460,7 +458,6 @@ func New(code string) (*Tracer, error) {
|
||||||
|
|
||||||
tracer.dbWrapper.pushObject(tracer.vm)
|
tracer.dbWrapper.pushObject(tracer.vm)
|
||||||
tracer.vm.PutPropString(tracer.stateObject, "db")
|
tracer.vm.PutPropString(tracer.stateObject, "db")
|
||||||
|
|
||||||
return tracer, nil
|
return tracer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -500,11 +497,6 @@ func wrapError(context string, err error) error {
|
||||||
|
|
||||||
// CaptureStart implements the Tracer interface to initialize the tracing operation.
|
// CaptureStart implements the Tracer interface to initialize the tracing operation.
|
||||||
func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error {
|
func (jst *Tracer) CaptureStart(from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) error {
|
||||||
//fmt.Println("\n\n\t\t type: ", reflect.TypeOf(input))
|
|
||||||
fmt.Println("\t\t [TRACER TO]:", to.String())
|
|
||||||
fmt.Println("\t\t [TRACER FROM]:", from.String())
|
|
||||||
fmt.Println("\t\t [TRACER VALUE]:", value.String())
|
|
||||||
fmt.Println("\t\t [TRACER INPUT STRING]:", string(input[:len(input)]), "\n\n")
|
|
||||||
jst.ctx["type"] = "CALL"
|
jst.ctx["type"] = "CALL"
|
||||||
if create {
|
if create {
|
||||||
jst.ctx["type"] = "CREATE"
|
jst.ctx["type"] = "CREATE"
|
||||||
|
|
@ -573,9 +565,6 @@ func (jst *Tracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost
|
||||||
|
|
||||||
// CaptureEnd is called after the call finishes to finalize the tracing.
|
// CaptureEnd is called after the call finishes to finalize the tracing.
|
||||||
func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error {
|
func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error {
|
||||||
//fmt.Println("\n\n\t\t", reflect.TypeOf(output))
|
|
||||||
//fmt.Println("\t\t [TRACER OUTPUT]:", output[:len(output)])
|
|
||||||
//fmt.Println("\t\t [TRACER OUTPUT STRING]:", string(output[:len(output)]), "\n\n")
|
|
||||||
jst.ctx["output"] = output
|
jst.ctx["output"] = output
|
||||||
jst.ctx["gasUsed"] = gasUsed
|
jst.ctx["gasUsed"] = gasUsed
|
||||||
jst.ctx["time"] = t.String()
|
jst.ctx["time"] = t.String()
|
||||||
|
|
@ -586,6 +575,13 @@ func (jst *Tracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, er
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Internals struct {
|
||||||
|
From string
|
||||||
|
To string
|
||||||
|
Value string
|
||||||
|
Calls []*Internals
|
||||||
|
}
|
||||||
|
|
||||||
// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
|
// GetResult calls the Javascript 'result' function and returns its value, or any accumulated error
|
||||||
func (jst *Tracer) GetResult() (json.RawMessage, error) {
|
func (jst *Tracer) GetResult() (json.RawMessage, error) {
|
||||||
// Transform the context into a JavaScript object and inject into the state
|
// Transform the context into a JavaScript object and inject into the state
|
||||||
|
|
@ -626,5 +622,33 @@ func (jst *Tracer) GetResult() (json.RawMessage, error) {
|
||||||
jst.vm.DestroyHeap()
|
jst.vm.DestroyHeap()
|
||||||
jst.vm.Destroy()
|
jst.vm.Destroy()
|
||||||
|
|
||||||
|
//var dat map[string]interface{}
|
||||||
|
var dat Internals
|
||||||
|
|
||||||
|
if err := json.Unmarshal(result, &dat); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//fmt.Println("[FULL DATA]", string(result))
|
||||||
|
//fmt.Println("\n +++++++++++++++++++")
|
||||||
|
//fmt.Println(dat["calls"])
|
||||||
|
//fmt.Println(dat["calls"]["gasUsed"])
|
||||||
|
//j, _ := json.Marshal(result)
|
||||||
|
//internals := string(j)
|
||||||
|
//fmt.Println("[RESULT]", dat)
|
||||||
|
//fmt.Println("[RESULT]", dat.To)
|
||||||
|
//fmt.Println("[Internal Call]", len(dat.Calls))
|
||||||
|
|
||||||
|
for key, val := range dat.Calls {
|
||||||
|
fmt.Println(key)
|
||||||
|
fmt.Println("[INTERNAL TO]", val.To)
|
||||||
|
fmt.Println("[INTERNAL From]", val.From)
|
||||||
|
fmt.Println("[INTERNAL Calls length]", len(val.Calls))
|
||||||
|
for newKey, newVal := range val.Calls {
|
||||||
|
fmt.Println(newKey)
|
||||||
|
fmt.Println("[INSIDE INTERNAL TO]", newVal.To)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result, jst.err
|
return result, jst.err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,12 @@ package main
|
||||||
|
|
||||||
///@NOTE Shyft handler functions when endpoints are hit
|
///@NOTE Shyft handler functions when endpoints are hit
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/shyftdb"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
@ -19,13 +18,13 @@ import (
|
||||||
func GetTransaction(w http.ResponseWriter, r *http.Request) {
|
func GetTransaction(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
txHash := vars["txHash"]
|
txHash := vars["txHash"]
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
sqldb, err := core.DBConnection()
|
||||||
getTxResponse := shyftdb.GetTransaction(blockExplorerDb, txHash)
|
getTxResponse := core.SGetTransaction(sqldb, txHash)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -40,13 +39,15 @@ func GetTransaction(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// GetAllTransactions gets txs
|
// GetAllTransactions gets txs
|
||||||
func GetAllTransactions(w http.ResponseWriter, r *http.Request) {
|
func GetAllTransactions(w http.ResponseWriter, r *http.Request) {
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
|
||||||
txs := shyftdb.GetAllTransactions(blockExplorerDb)
|
sqldb, err := core.DBConnection()
|
||||||
|
|
||||||
|
txs := core.SGetAllTransactions(sqldb)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -64,13 +65,15 @@ func GetAllTransactions(w http.ResponseWriter, r *http.Request) {
|
||||||
func GetAllTransactionsFromBlock(w http.ResponseWriter, r *http.Request) {
|
func GetAllTransactionsFromBlock(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
blockNumber := vars["blockNumber"]
|
blockNumber := vars["blockNumber"]
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
|
||||||
txsFromBlock := shyftdb.GetAllTransactionsFromBlock(blockExplorerDb, blockNumber)
|
sqldb, err := core.DBConnection()
|
||||||
|
|
||||||
|
txsFromBlock := core.SGetAllTransactionsFromBlock(sqldb, blockNumber)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -86,13 +89,15 @@ func GetAllTransactionsFromBlock(w http.ResponseWriter, r *http.Request) {
|
||||||
func GetAllBlocksMinedByAddress(w http.ResponseWriter, r *http.Request) {
|
func GetAllBlocksMinedByAddress(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
coinbase := vars["coinbase"]
|
coinbase := vars["coinbase"]
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
|
||||||
blocksMined := shyftdb.GetAllBlocksMinedByAddress(blockExplorerDb, coinbase)
|
sqldb, err := core.DBConnection()
|
||||||
|
|
||||||
|
blocksMined := core.SGetAllBlocksMinedByAddress(sqldb, coinbase)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -109,13 +114,15 @@ func GetAllBlocksMinedByAddress(w http.ResponseWriter, r *http.Request) {
|
||||||
func GetAccount(w http.ResponseWriter, r *http.Request) {
|
func GetAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
address := vars["address"]
|
address := vars["address"]
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
|
||||||
getAccountBalance := shyftdb.GetAccount(blockExplorerDb, address)
|
sqldb, err := core.DBConnection()
|
||||||
|
|
||||||
|
getAccountBalance := core.SGetAccount(sqldb, address)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -132,13 +139,15 @@ func GetAccount(w http.ResponseWriter, r *http.Request) {
|
||||||
func GetAccountTxs(w http.ResponseWriter, r *http.Request) {
|
func GetAccountTxs(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
address := vars["address"]
|
address := vars["address"]
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
|
||||||
getAccountTxs := shyftdb.GetAccountTxs(blockExplorerDb, address)
|
sqldb, err := core.DBConnection()
|
||||||
|
|
||||||
|
getAccountTxs := core.SGetAccountTxs(sqldb, address)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -153,12 +162,15 @@ func GetAccountTxs(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// GetAllAccounts gets balances
|
// GetAllAccounts gets balances
|
||||||
func GetAllAccounts(w http.ResponseWriter, r *http.Request) {
|
func GetAllAccounts(w http.ResponseWriter, r *http.Request) {
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
allAccounts := shyftdb.GetAllAccounts(blockExplorerDb)
|
|
||||||
|
sqldb, err := core.DBConnection()
|
||||||
|
|
||||||
|
allAccounts := core.SGetAllAccounts(sqldb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
|
@ -173,13 +185,13 @@ func GetAllAccounts(w http.ResponseWriter, r *http.Request) {
|
||||||
func GetBlock(w http.ResponseWriter, r *http.Request) {
|
func GetBlock(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
blockNumber := vars["blockNumber"]
|
blockNumber := vars["blockNumber"]
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
|
sqldb, err := core.DBConnection()
|
||||||
getBlockResponse := shyftdb.GetBlock(blockExplorerDb, blockNumber)
|
getBlockResponse := core.SGetBlock(sqldb, blockNumber)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -194,12 +206,13 @@ func GetBlock(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// GetAllBlocks response
|
// GetAllBlocks response
|
||||||
func GetAllBlocks(w http.ResponseWriter, r *http.Request) {
|
func GetAllBlocks(w http.ResponseWriter, r *http.Request) {
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
block3 := shyftdb.GetAllBlocks(blockExplorerDb)
|
sqldb, err := core.DBConnection()
|
||||||
|
block3 := core.SGetAllBlocks(sqldb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
|
@ -210,12 +223,14 @@ func GetAllBlocks(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRecentBlock(w http.ResponseWriter, r *http.Request) {
|
func GetRecentBlock(w http.ResponseWriter, r *http.Request) {
|
||||||
connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
//connStr := "user=postgres dbname=shyftdb sslmode=disable"
|
||||||
blockExplorerDb, err := sql.Open("postgres", connStr)
|
//blockExplorerDb, err := sql.Open("postgres", connStr)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
return
|
// return
|
||||||
}
|
//}
|
||||||
mostRecentBlock := shyftdb.GetRecentBlock(blockExplorerDb)
|
sqldb, err := core.DBConnection()
|
||||||
|
|
||||||
|
mostRecentBlock := core.SGetRecentBlock(sqldb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue