mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
Tx getters return values
This commit is contained in:
parent
45a2654ffd
commit
5f46c2d4a8
7 changed files with 63 additions and 32 deletions
|
|
@ -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
|
||||
// the zero'd block (i.e. genesis) or will fail hard if it can't succeed.
|
||||
func initGenesis(ctx *cli.Context) error {
|
||||
fmt.Println("GENESIS+++++++++++++++++++++++")
|
||||
// Make sure we have a valid genesis JSON
|
||||
genesisPath := ctx.Args().First()
|
||||
if len(genesisPath) == 0 {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ func enableWhisper(ctx *cli.Context) bool {
|
|||
}
|
||||
|
||||
func makeFullNode(ctx *cli.Context) *node.Node {
|
||||
fmt.Println("+++++++++++++++++cmd/geth/config.GO+++++++++++++++++++++++++MakeFullNode()")
|
||||
stack, cfg := makeConfigNode(ctx)
|
||||
|
||||
utils.RegisterEthService(stack, &cfg.Eth)
|
||||
|
|
|
|||
|
|
@ -214,7 +214,6 @@ func main() {
|
|||
// It creates a default node based on the command line arguments and runs it in
|
||||
// blocking mode, waiting for it to be shut down.
|
||||
func geth(ctx *cli.Context) error {
|
||||
fmt.Println("+++++++++++++++++cmd/main/geth.GO+++++++++++++++++++++++++Geth()")
|
||||
node := makeFullNode(ctx)
|
||||
startNode(ctx, node)
|
||||
node.Wait()
|
||||
|
|
|
|||
|
|
@ -1124,7 +1124,6 @@ func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) {
|
|||
|
||||
// RegisterEthService adds an Ethereum client to the stack.
|
||||
func RegisterEthService(stack *node.Node, cfg *eth.Config) {
|
||||
fmt.Println("+++++++++++++++++cmd/utils/Flags.GO+++++++++++++++++++++++++RegisterEthService()")
|
||||
var err error
|
||||
if cfg.SyncMode == downloader.LightSync {
|
||||
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.
|
||||
func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) {
|
||||
fmt.Println("+++++++++++++++++cmd/flags.GO+++++++++++++++++++++++++MakeChain()")
|
||||
var err error
|
||||
chainDb = MakeChainDatabase(ctx, stack)
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,6 @@ type BlockChain struct {
|
|||
// available in the database. It initialises the default Ethereum Validator and
|
||||
// Processor.
|
||||
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 {
|
||||
cacheConfig = &CacheConfig{
|
||||
TrieNodeLimit: 256 * 1024 * 1024,
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ func (s *Ethereum) AddLesServer(ls LesServer) {
|
|||
// initialisation of the common Ethereum object)
|
||||
func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||
// @NOTE:shyft Where we instantiate BlockExplorerDB
|
||||
fmt.Println("+++++++++++++++++eth/backend.GO+++++++++++++++++++++++++New()")
|
||||
if config.SyncMode == downloader.LightSync {
|
||||
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.
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -31,6 +31,18 @@ type ShyftTxEntry struct {
|
|||
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 {
|
||||
leng := block.Transactions().Len()
|
||||
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 {
|
||||
log.Crit("Failed to store TX", "err", err)
|
||||
}
|
||||
GetTransaction(db, tx)
|
||||
GetAllTransactions(db)
|
||||
return tx.Hash().String()
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +129,8 @@ func GetBlock(db *leveldb.DB, block *types.Block) []byte {
|
|||
return data
|
||||
}
|
||||
|
||||
func GetAllTransactions(db *leveldb.DB) {
|
||||
func GetAllTransactions(db *leveldb.DB) []ShyftTxEntryPretty {
|
||||
var txs []ShyftTxEntryPretty
|
||||
iter := db.NewIterator(util.BytesPrefix([]byte("tx-")), nil)
|
||||
for iter.Next() {
|
||||
var txData ShyftTxEntry
|
||||
|
|
@ -127,21 +138,36 @@ func GetAllTransactions(db *leveldb.DB) {
|
|||
if err := d.Decode(&txData); err != nil {
|
||||
log.Crit("Failed to decode tx:", "err", err)
|
||||
}
|
||||
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)
|
||||
prettyFormat := ShyftTxEntryPretty{
|
||||
TxHash: txData.TxHash.Hex(),
|
||||
From: txData.From.Hex(),
|
||||
To: txData.To.Hex(),
|
||||
BlockHash: txData.BlockHash.Hex(),
|
||||
Amount: txData.Amount,
|
||||
Gas: txData.Gas,
|
||||
GasPrice: txData.GasPrice,
|
||||
Nonce: txData.Nonce,
|
||||
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()
|
||||
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()[:]...)
|
||||
data, err := db.Get(key, nil)
|
||||
if err != nil {
|
||||
|
|
@ -153,15 +179,28 @@ func GetTransaction (db *leveldb.DB, tx *types.Transaction) {
|
|||
if err := d.Decode(&txData); err != nil {
|
||||
log.Crit("Failed to decode tx:", "err", err)
|
||||
}
|
||||
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)
|
||||
prettyFormat = ShyftTxEntryPretty{
|
||||
TxHash: txData.TxHash.Hex(),
|
||||
From: txData.From.Hex(),
|
||||
To: txData.To.Hex(),
|
||||
BlockHash: txData.BlockHash.Hex(),
|
||||
Amount: txData.Amount,
|
||||
Gas: txData.Gas,
|
||||
GasPrice: txData.GasPrice,
|
||||
Nonce: txData.Nonce,
|
||||
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
|
||||
}
|
||||
Loading…
Reference in a new issue