From 156348b4590d34996cdae24996f58e822831808b Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 15 Apr 2018 15:41:16 -0400 Subject: [PATCH] succesfully found the contract address " --- cmd/utils/flags.go | 1 - core/blockchain.go | 4 +--- core/database_util.go | 14 ++++++++++---- core/types/transaction.go | 2 ++ miner/unconfirmed.go | 1 - node/node.go | 1 + simulations/sendTransactions.js | 4 ++-- 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index daac8f851c..bc43a3d705 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -56,7 +56,6 @@ import ( "github.com/ethereum/go-ethereum/p2p/netutil" "github.com/ethereum/go-ethereum/params" whisper "github.com/ethereum/go-ethereum/whisper/whisperv5" - "gopkg.in/urfave/cli.v1" ) var ( diff --git a/core/blockchain.go b/core/blockchain.go index 8c3ec4d29d..caed887cde 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -137,7 +137,6 @@ type BlockChain struct { // available in the database. It initialises the default Ethereum Validator and // Processor. func NewBlockChain(db ethdb.Database, blockExplorerDb ethdb.Database, 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, @@ -877,7 +876,6 @@ func (bc *BlockChain) WriteBlockWithoutState(block *types.Block, td *big.Int) (e // WriteBlockWithState writes the block and all associated state to the database. func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.Receipt, state *state.StateDB) (status WriteStatus, err error) { - fmt.Println("+++++++++++++++++++Blockchain.go+++++++++++++++++writeBlockWithState()") bc.wg.Add(1) defer bc.wg.Done() @@ -903,7 +901,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types. if err := WriteBlock(batch, block); err != nil { return NonStatTy, err } - + // @NOTE:SHYFT - Write block data for block explorer explorerBatch := bc.blockExplorerDb.NewBatch() if err := shyftdb.WriteBlock(explorerBatch, block); err != nil { return NonStatTy, err diff --git a/core/database_util.go b/core/database_util.go index 618313b066..a2ab22ad9e 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -21,8 +21,8 @@ import ( "encoding/binary" "encoding/json" "errors" - "fmt" "math/big" + "fmt" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -447,10 +447,14 @@ func WriteTd(db ethdb.Putter, hash common.Hash, number uint64, td *big.Int) erro // WriteBlock serializes a block into the database, header and body separately. func WriteBlock(db ethdb.Putter, block *types.Block) error { - fmt.Println("+++++++++++++++++++++++++++") - fmt.Println(block.Transactions()) - fmt.Println("+++++++++++++++++++++++++++") // Store the body first to retain database consistency + fmt.Println("\t\t ~~~~~BLOCK~~~~~") + if block.Transactions().Len() > 0 { + for _, tx := range block.Transactions() { + fmt.Println(tx.To().Hex()) + fmt.Println(block.Transactions()[0].To().Hex()) + } + } if err := WriteBody(db, block.Hash(), block.NumberU64(), block.Body()); err != nil { return err } @@ -466,6 +470,7 @@ func WriteBlock(db ethdb.Putter, block *types.Block) error { // as a single receipt slice. This is used during chain reorganisations for // rescheduling dropped transactions. func WriteBlockReceipts(db ethdb.Putter, hash common.Hash, number uint64, receipts types.Receipts) error { + // Convert the receipts into their storage form and serialize them storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) for i, receipt := range receipts { @@ -477,6 +482,7 @@ func WriteBlockReceipts(db ethdb.Putter, hash common.Hash, number uint64, receip } // Store the flattened receipt slice key := append(append(blockReceiptsPrefix, encodeBlockNumber(number)...), hash.Bytes()...) + if err := db.Put(key, bytes); err != nil { log.Crit("Failed to store block receipts", "err", err) } diff --git a/core/types/transaction.go b/core/types/transaction.go index 5660582baf..8d1ea4fa46 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -94,6 +94,8 @@ func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit if len(data) > 0 { data = common.CopyBytes(data) } + fmt.Println("DASas") + fmt.Println(to) d := txdata{ AccountNonce: nonce, Recipient: to, diff --git a/miner/unconfirmed.go b/miner/unconfirmed.go index 7a4fc7cc5a..d7d0fb0286 100644 --- a/miner/unconfirmed.go +++ b/miner/unconfirmed.go @@ -72,7 +72,6 @@ func (set *unconfirmedBlocks) Insert(index uint64, hash common.Hash) { // Set as the initial ring or append to the end set.lock.Lock() defer set.lock.Unlock() - if set.blocks == nil { set.blocks = item } else { diff --git a/node/node.go b/node/node.go index b02aecfad1..6e03cd1606 100644 --- a/node/node.go +++ b/node/node.go @@ -642,6 +642,7 @@ func (n *Node) EventMux() *event.TypeMux { // previous can be found) from within the node's instance directory. If the node is // ephemeral, a memory database is returned. func (n *Node) OpenDatabase(name string, cache, handles int) (ethdb.Database, error) { + fmt.Println("DSAhhysagdhkajsndjgasuygdvkhasbdjhs") if n.config.DataDir == "" { return ethdb.NewMemDatabase() } diff --git a/simulations/sendTransactions.js b/simulations/sendTransactions.js index d12950ec6b..09d39b6b85 100644 --- a/simulations/sendTransactions.js +++ b/simulations/sendTransactions.js @@ -2,8 +2,8 @@ var firstAccount = web3.eth.accounts[0] var secondAccount = web3.eth.accounts[1] var thirdAccount = web3.eth.accounts[2] -for (var i = 0; i < 50; i++) { - console.log('\t\t' +i+ ' - iterations') +for (var i = 0; i < 3; i++) { + console.log('\t\t' + (i + 1) + ' - Transactions') web3.eth.sendTransaction({ from: web3.eth.accounts[0], to: web3.eth.accounts[1],