Merge branch 'shyft/greg' into shyftBlockExp

This commit is contained in:
Dustin Brickwood 2018-04-16 17:20:25 -04:00
commit 8fb0603227
7 changed files with 63 additions and 32 deletions

View file

@ -146,7 +146,6 @@ Use "ethereum dump 0" to dump the genesis block.`,
// initGenesis will initialise the given JSON format genesis file and writes it as // initGenesis will initialise the given JSON format genesis file and writes it as
// the zero'd block (i.e. genesis) or will fail hard if it can't succeed. // the zero'd block (i.e. genesis) or will fail hard if it can't succeed.
func initGenesis(ctx *cli.Context) error { func initGenesis(ctx *cli.Context) error {
fmt.Println("GENESIS+++++++++++++++++++++++")
// Make sure we have a valid genesis JSON // Make sure we have a valid genesis JSON
genesisPath := ctx.Args().First() genesisPath := ctx.Args().First()
if len(genesisPath) == 0 { if len(genesisPath) == 0 {

View file

@ -152,7 +152,6 @@ func enableWhisper(ctx *cli.Context) bool {
} }
func makeFullNode(ctx *cli.Context) *node.Node { func makeFullNode(ctx *cli.Context) *node.Node {
fmt.Println("+++++++++++++++++cmd/geth/config.GO+++++++++++++++++++++++++MakeFullNode()")
stack, cfg := makeConfigNode(ctx) stack, cfg := makeConfigNode(ctx)
utils.RegisterEthService(stack, &cfg.Eth) utils.RegisterEthService(stack, &cfg.Eth)

View file

@ -214,7 +214,6 @@ func main() {
// It creates a default node based on the command line arguments and runs it in // It creates a default node based on the command line arguments and runs it in
// blocking mode, waiting for it to be shut down. // blocking mode, waiting for it to be shut down.
func geth(ctx *cli.Context) error { func geth(ctx *cli.Context) error {
fmt.Println("+++++++++++++++++cmd/main/geth.GO+++++++++++++++++++++++++Geth()")
node := makeFullNode(ctx) node := makeFullNode(ctx)
startNode(ctx, node) startNode(ctx, node)
node.Wait() node.Wait()

View file

@ -1124,7 +1124,6 @@ func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) {
// RegisterEthService adds an Ethereum client to the stack. // RegisterEthService adds an Ethereum client to the stack.
func RegisterEthService(stack *node.Node, cfg *eth.Config) { func RegisterEthService(stack *node.Node, cfg *eth.Config) {
fmt.Println("+++++++++++++++++cmd/utils/Flags.GO+++++++++++++++++++++++++RegisterEthService()")
var err error var err error
if cfg.SyncMode == downloader.LightSync { if cfg.SyncMode == downloader.LightSync {
err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
@ -1216,7 +1215,6 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
// MakeChain creates a chain manager from set command line flags. // MakeChain creates a chain manager from set command line flags.
func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) { func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) {
fmt.Println("+++++++++++++++++cmd/flags.GO+++++++++++++++++++++++++MakeChain()")
var err error var err error
chainDb = MakeChainDatabase(ctx, stack) chainDb = MakeChainDatabase(ctx, stack)

View file

@ -141,7 +141,6 @@ type BlockChain struct {
// available in the database. It initialises the default Ethereum Validator and // available in the database. It initialises the default Ethereum Validator and
// Processor. // Processor.
func NewBlockChain(db ethdb.Database, blockExplorerDb *leveldb.DB, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) { func NewBlockChain(db ethdb.Database, blockExplorerDb *leveldb.DB, cacheConfig *CacheConfig, chainConfig *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) {
fmt.Printf("+++++++++++++++++core/blockchain.GO+++++++++++++++++++++++++NewBlockChain()")
if cacheConfig == nil { if cacheConfig == nil {
cacheConfig = &CacheConfig{ cacheConfig = &CacheConfig{
TrieNodeLimit: 256 * 1024 * 1024, TrieNodeLimit: 256 * 1024 * 1024,

View file

@ -104,7 +104,6 @@ func (s *Ethereum) AddLesServer(ls LesServer) {
// initialisation of the common Ethereum object) // initialisation of the common Ethereum object)
func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
// @NOTE:shyft Where we instantiate BlockExplorerDB // @NOTE:shyft Where we instantiate BlockExplorerDB
fmt.Println("+++++++++++++++++eth/backend.GO+++++++++++++++++++++++++New()")
if config.SyncMode == downloader.LightSync { if config.SyncMode == downloader.LightSync {
return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum") return nil, errors.New("can't run eth.Ethereum in light sync mode, use les.LightEthereum")
} }
@ -210,7 +209,6 @@ func makeExtraData(extra []byte) []byte {
// CreateDB creates the chain database. // CreateDB creates the chain database.
func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) { func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Database, error) {
fmt.Println("+++++++++++++++++eth/backend.GO+++++++++++++++++++++++++CreateDB()")
db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles) db, err := ctx.OpenDatabase(name, config.DatabaseCache, config.DatabaseHandles)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -31,6 +31,18 @@ type ShyftTxEntry struct {
Data []byte Data []byte
} }
type ShyftTxEntryPretty struct {
TxHash string
To string
From string
BlockHash string
Amount *big.Int
GasPrice *big.Int
Gas uint64
Nonce uint64
Data []byte
}
func WriteBlock(db *leveldb.DB, block *types.Block) error { func WriteBlock(db *leveldb.DB, block *types.Block) error {
leng := block.Transactions().Len() leng := block.Transactions().Len()
var tx_strs = make([]string, leng) var tx_strs = make([]string, leng)
@ -80,8 +92,6 @@ func WriteTransactions(db *leveldb.DB, tx *types.Transaction, blockHash common.H
if err := db.Put(key, encodedData.Bytes(), nil); err != nil { if err := db.Put(key, encodedData.Bytes(), nil); err != nil {
log.Crit("Failed to store TX", "err", err) log.Crit("Failed to store TX", "err", err)
} }
GetTransaction(db, tx)
GetAllTransactions(db)
return tx.Hash().String() return tx.Hash().String()
} }
@ -119,7 +129,8 @@ func GetBlock(db *leveldb.DB, block *types.Block) []byte {
return data return data
} }
func GetAllTransactions(db *leveldb.DB) { func GetAllTransactions(db *leveldb.DB) []ShyftTxEntryPretty {
var txs []ShyftTxEntryPretty
iter := db.NewIterator(util.BytesPrefix([]byte("tx-")), nil) iter := db.NewIterator(util.BytesPrefix([]byte("tx-")), nil)
for iter.Next() { for iter.Next() {
var txData ShyftTxEntry var txData ShyftTxEntry
@ -127,21 +138,36 @@ func GetAllTransactions(db *leveldb.DB) {
if err := d.Decode(&txData); err != nil { if err := d.Decode(&txData); err != nil {
log.Crit("Failed to decode tx:", "err", err) log.Crit("Failed to decode tx:", "err", err)
} }
fmt.Println("DECODED TX") prettyFormat := ShyftTxEntryPretty{
fmt.Println("Tx Hash: ", txData.TxHash.Hex()) TxHash: txData.TxHash.Hex(),
fmt.Println("From: ", txData.From.Hex()) From: txData.From.Hex(),
fmt.Println("To: ", txData.To.Hex()) To: txData.To.Hex(),
fmt.Println("BlockHash: ", txData.BlockHash.Hex()) BlockHash: txData.BlockHash.Hex(),
fmt.Println("Amount: ", txData.Amount) Amount: txData.Amount,
fmt.Println("Gas: ", txData.Gas) Gas: txData.Gas,
fmt.Println("GasPrice: ", txData.GasPrice) GasPrice: txData.GasPrice,
fmt.Println("Nonce: ", txData.Nonce) Nonce: txData.Nonce,
fmt.Println("Data: ", txData.Data) Data: txData.Data,
}
txs = append(txs, prettyFormat)
// Uncomment to view "pretty" version of data
//fmt.Println("DECODED TX")
//fmt.Println("Tx Hash: ", txData.TxHash.Hex())
//fmt.Println("From: ", txData.From.Hex())
//fmt.Println("To: ", txData.To.Hex())
//fmt.Println("BlockHash: ", txData.BlockHash.Hex())
//fmt.Println("Amount: ", txData.Amount)
//fmt.Println("Gas: ", txData.Gas)
//fmt.Println("GasPrice: ", txData.GasPrice)
//fmt.Println("Nonce: ", txData.Nonce)
//fmt.Println("Data: ", txData.Data)
} }
iter.Release() iter.Release()
return txs
} }
func GetTransaction (db *leveldb.DB, tx *types.Transaction) { func GetTransaction (db *leveldb.DB, tx *types.Transaction) ShyftTxEntryPretty {
var prettyFormat ShyftTxEntryPretty
key := append([]byte("tx-")[:], tx.Hash().Bytes()[:]...) key := append([]byte("tx-")[:], tx.Hash().Bytes()[:]...)
data, err := db.Get(key, nil) data, err := db.Get(key, nil)
if err != nil { if err != nil {
@ -153,15 +179,28 @@ func GetTransaction (db *leveldb.DB, tx *types.Transaction) {
if err := d.Decode(&txData); err != nil { if err := d.Decode(&txData); err != nil {
log.Crit("Failed to decode tx:", "err", err) log.Crit("Failed to decode tx:", "err", err)
} }
fmt.Println("DECODED TX") prettyFormat = ShyftTxEntryPretty{
fmt.Println("Tx Hash: ", txData.TxHash.Hex()) TxHash: txData.TxHash.Hex(),
fmt.Println("From: ", txData.From.Hex()) From: txData.From.Hex(),
fmt.Println("To: ", txData.To.Hex()) To: txData.To.Hex(),
fmt.Println("BlockHash: ", txData.BlockHash.Hex()) BlockHash: txData.BlockHash.Hex(),
fmt.Println("Amount: ", txData.Amount) Amount: txData.Amount,
fmt.Println("Gas: ", txData.Gas) Gas: txData.Gas,
fmt.Println("GasPrice: ", txData.GasPrice) GasPrice: txData.GasPrice,
fmt.Println("Nonce: ", txData.Nonce) Nonce: txData.Nonce,
fmt.Println("Data: ", txData.Data) Data: txData.Data,
}
// Uncomment to view "pretty" version of data
//fmt.Println("DECODED TX")
//fmt.Println("Tx Hash: ", txData.TxHash.Hex())
//fmt.Println("From: ", txData.From.Hex())
//fmt.Println("To: ", txData.To.Hex())
//fmt.Println("BlockHash: ", txData.BlockHash.Hex())
//fmt.Println("Amount: ", txData.Amount)
//fmt.Println("Gas: ", txData.Gas)
//fmt.Println("GasPrice: ", txData.GasPrice)
//fmt.Println("Nonce: ", txData.Nonce)
//fmt.Println("Data: ", txData.Data)
} }
return prettyFormat
} }