need to resolve dereference issue in node.go

This commit is contained in:
Dustin Brickwood 2018-07-04 20:31:29 -04:00
parent de32947dcf
commit bf5b379025
8 changed files with 63 additions and 59 deletions

View file

@ -1002,7 +1002,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.
} }
// NOTE:SHYFT - Write block data for block explorer // NOTE:SHYFT - Write block data for block explorer
fmt.Printf("\n\t[BLOCKCHAIN.GO bc.chainConfig] %+v", bc.chainConfig) //fmt.Printf("\n\t[BLOCKCHAIN.GO bc.chainConfig] %+v", bc.chainConfig)
if err := SWriteBlock(block, receipts); err != nil { if err := SWriteBlock(block, receipts); err != nil {
return NonStatTy, err return NonStatTy, err
} }
@ -1026,7 +1026,6 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
// only reason this method exists as a separate one is to make locking cleaner // only reason this method exists as a separate one is to make locking cleaner
// with deferred statements. // with deferred statements.
func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*types.Log, error) { func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*types.Log, error) {
fmt.Println("++++++++++ insertChain +++++++++")
_, file, no, ok := runtime.Caller(1) _, file, no, ok := runtime.Caller(1)
if ok { if ok {
fmt.Printf("called from %s#%d\n", file, no) fmt.Printf("called from %s#%d\n", file, no)

View file

@ -4,16 +4,19 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"time" "time"
"strconv" "strconv"
"database/sql" "database/sql"
"log" "log"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/ethereum/go-ethereum/common"
"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"
"github.com/ethereum/go-ethereum/node"
"reflect"
) )
var IShyftTracer shyfttracerinterface.IShyftTracer var IShyftTracer shyfttracerinterface.IShyftTracer
@ -171,8 +174,20 @@ func SwriteTransactions(sqldb *sql.DB, tx *types.Transaction, blockHash common.H
Nonce: tx.Nonce(), Nonce: tx.Nonce(),
Data: tx.Data(), Data: tx.Data(),
} }
hash := txData.TxHash
fmt.Println(reflect.TypeOf(hash))
txHash := txData.TxHash.Hex() txHash := txData.TxHash.Hex()
IShyftTracer.MyTraceTransaction(txHash) //.chaindb_global //IShyftTracer.MyTraceTransaction(txHash)
//
var stack *node.Node
fmt.Println(reflect.TypeOf(stack))
prayer, err := IShyftTracer.GetTracerToRun(hash, stack)
fmt.Println("THIS IS A PRAYER", prayer)
fmt.Println(err)
from := txData.From.Hex() from := txData.From.Hex()
blockHasher := txData.BlockHash blockHasher := txData.BlockHash
amount := txData.Amount.String() amount := txData.Amount.String()

View file

@ -38,6 +38,7 @@ import (
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
) )
const ( const (
@ -529,6 +530,26 @@ func (api *PrivateDebugAPI) computeStateDB(block *types.Block, reexec uint64) (*
return statedb, nil return statedb, nil
} }
//func GetTracerToRun(hash common.Hash) (interface{}, error) {
// config2 := params.ShyftNetworkChainConfig
// var cfg *Config
// fmt.Println(reflect.TypeOf(cfg))
// var ctx context.Context
// var config *TraceConfig
// var fullNode *Ethereum
// var stack *node.Node
// fmt.Println(reflect.TypeOf(stack))
// err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
// fullNode, err := New(ctx, cfg)
// return fullNode, err
// })
// fmt.Println(err)
// privateAPI := NewPrivateDebugAPI(config2, fullNode)
// return privateAPI.TraceTransaction(ctx, hash, config)
//}
// 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) {

View file

@ -109,7 +109,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
shyft_tracer := new(ShyftTracer) shyft_tracer := new(ShyftTracer)
core.SetIShyftTracer(shyft_tracer) core.SetIShyftTracer(shyft_tracer)
fmt.Println("++++++++++")
_, file, no, ok := runtime.Caller(1) _, file, no, ok := runtime.Caller(1)
if ok { if ok {
fmt.Printf("called from %s#%d\n", file, no) fmt.Printf("called from %s#%d\n", file, no)

View file

@ -3,59 +3,29 @@ package eth
import ( import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"fmt" "fmt"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
"context"
) )
//const (
// // defaultTraceReexec is the number of blocks the tracer is willing to go back
// // and reexecute to produce missing historical state necessary to run a specific
// // trace.
// defaultTraceReexec = uint64(128)
//)
//var api *eth.PrivateDebugAPI
var EthereumObject interface{} var EthereumObject interface{}
type ShyftTracer struct {} type ShyftTracer struct {}
func (st ShyftTracer) MyTraceTransaction(hash string) (interface{}) { func (st ShyftTracer) GetTracerToRun(hash common.Hash, stack *node.Node) (interface{}, error) {
//fmt.Println("THE stringed hash is in MYTRACETRANSACTION") config2 := params.ShyftNetworkChainConfig
//fmt.Println(hash) var cfg *Config
//fmt.Println(ethObjectInterface.GetEthObject()) var ctx context.Context
common_hash := common.HexToHash(hash) var config *TraceConfig
var fullNode *Ethereum
err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
//fmt.Println("the chain db is in MyTraceTransaction") fullNode, err := New(ctx, cfg)
//fmt.Println(Chaindb_global) return fullNode, err
if Chaindb_global == nil { })
return nil
}
tx, blockHash, _, index := core.GetTransaction(Chaindb_global, common_hash)
if tx == nil {
fmt.Println("TRANSACTION NOT FOUND IN MyTraceTransaction +++++++++")
}
reexec := defaultTraceReexec
//if config != nil && config.Reexec != nil {
// reexec = *config.Reexec
//}
msg, vmctx, statedb, err := DebugApi.computeTxEnv(blockHash, int(index), reexec)
fmt.Println("stuff and nonsense")
fmt.Println(msg)
fmt.Println(vmctx)
fmt.Println(statedb)
fmt.Println(err) fmt.Println(err)
privateAPI := NewPrivateDebugAPI(config2, fullNode)
//fmt.Println("the tx is ") return privateAPI.TraceTransaction(ctx, hash, config)
//fmt.Println(tx)
//fmt.Println(blockHash)
//fmt.Println(index)
//DebugApi.traceTx(ctx, msg, vmctx, statedb, config)
return 42
} }
func setEthObject(ethobj interface{}){ func setEthObject(ethobj interface{}){

View file

@ -309,7 +309,6 @@ func (self *worker) wait() {
for _, log := range work.state.Logs() { for _, log := range work.state.Logs() {
log.BlockHash = block.Hash() log.BlockHash = block.Hash()
} }
fmt.Printf("\n\t[WORKER.GO self.eth] %+v\n", self.eth)
// NOTE:SHYFT Added eth to writeBlockWithState // NOTE:SHYFT Added eth to writeBlockWithState
stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state) stat, err := self.chain.WriteBlockWithState(block, work.receipts, work.state)
if err != nil { if err != nil {

View file

@ -231,10 +231,6 @@ func (h *virtualHostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
if ipAddr := net.ParseIP(host); ipAddr != nil { if ipAddr := net.ParseIP(host); ipAddr != nil {
// It's an IP address, we can serve that // It's an IP address, we can serve that
fmt.Println("THE write is ")
fmt.Println(w)
fmt.Println("The read is ")
fmt.Println(r)
h.next.ServeHTTP(w, r) h.next.ServeHTTP(w, r)
return return

View file

@ -1,5 +1,10 @@
package shyfttracerinterface package shyfttracerinterface
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/node"
)
type IShyftTracer interface { type IShyftTracer interface {
MyTraceTransaction(hash string) (interface{}) GetTracerToRun(hash common.Hash, stack *node.Node) (interface{}, error)
} }