From 1924a3437795629f943362f7e34814ca2b565c97 Mon Sep 17 00:00:00 2001 From: ak Date: Mon, 10 Dec 2018 17:12:20 -0800 Subject: [PATCH] cleaning up --- node/node.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/node/node.go b/node/node.go index 4acf35a9e..ee7ad8278 100644 --- a/node/node.go +++ b/node/node.go @@ -230,13 +230,14 @@ func DeserializeNode(d []byte) *NetworkNode { func (node *Node) AddSmartContractsToPendingTransactions() { // Add a contract deployment transactionv + priKey := node.TestBankKeys[0] + txs := make([]*types.Transaction, 0) var nonce uint64 nonce = 0 - txs := make([]*types.Transaction, 1) contractData := "0x608060405234801561001057600080fd5b506040516020806104c08339810180604052602081101561003057600080fd5b505160008054600160a060020a0319163317808255600160a060020a031681526001602081905260409091205560ff811661006c600282610073565b50506100bd565b8154818355818111156100975760008381526020902061009791810190830161009c565b505050565b6100ba91905b808211156100b657600081556001016100a2565b5090565b90565b6103f4806100cc6000396000f3fe60806040526004361061005b577c010000000000000000000000000000000000000000000000000000000060003504635c19a95c8114610060578063609ff1bd146100955780639e7b8d61146100c0578063b3f98adc146100f3575b600080fd5b34801561006c57600080fd5b506100936004803603602081101561008357600080fd5b5035600160a060020a0316610120565b005b3480156100a157600080fd5b506100aa610280565b6040805160ff9092168252519081900360200190f35b3480156100cc57600080fd5b50610093600480360360208110156100e357600080fd5b5035600160a060020a03166102eb565b3480156100ff57600080fd5b506100936004803603602081101561011657600080fd5b503560ff16610348565b3360009081526001602081905260409091209081015460ff1615610144575061027d565b5b600160a060020a0382811660009081526001602081905260409091200154620100009004161580159061019c5750600160a060020a0382811660009081526001602081905260409091200154620100009004163314155b156101ce57600160a060020a039182166000908152600160208190526040909120015462010000900490911690610145565b600160a060020a0382163314156101e5575061027d565b6001818101805460ff1916821775ffffffffffffffffffffffffffffffffffffffff0000191662010000600160a060020a0386169081029190911790915560009081526020829052604090209081015460ff16156102725781546001820154600280549091610100900460ff1690811061025b57fe5b60009182526020909120018054909101905561027a565b815481540181555b50505b50565b600080805b60025460ff821610156102e6578160028260ff168154811015156102a557fe5b906000526020600020016000015411156102de576002805460ff83169081106102ca57fe5b906000526020600020016000015491508092505b600101610285565b505090565b600054600160a060020a0316331415806103215750600160a060020a0381166000908152600160208190526040909120015460ff165b1561032b5761027d565b600160a060020a0316600090815260016020819052604090912055565b3360009081526001602081905260409091209081015460ff1680610371575060025460ff831610155b1561037c575061027d565b6001818101805460ff191690911761ff00191661010060ff8516908102919091179091558154600280549192909181106103b257fe5b600091825260209091200180549091019055505056fea165627a7a72305820164189ef302b4648e01e22456b0a725191604cb63ee472f230ef6a2d17d702f900290000000000000000000000000000000000000000000000000000000000000002" dataEnc := common.FromHex(contractData) - //Unsigned transaction to avoid the case of transaction address. - mycontracttx := types.NewContractCreation(nonce, 0, big.NewInt(1000000), params.TxGasContractCreation*10, nil, dataEnc) + // Unsigned transaction to avoid the case of transaction address. + mycontracttx, _ := types.SignTx(types.NewContractCreation(nonce, 0, big.NewInt(1000000), params.TxGasContractCreation*10, nil, dataEnc), types.HomesteadSigner{}, priKey) txs = append(txs, mycontracttx) node.pendingTransactionsAccount = txs } @@ -282,7 +283,7 @@ func New(host host.Host, consensus *bft.Consensus, db *hdb.LDBDatabase) *Node { for i := 0; i < 100; i++ { testBankKey, _ := ecdsa.GenerateKey(crypto.S256(), reader) testBankAddress := crypto.PubkeyToAddress(testBankKey.PublicKey) - testBankFunds := big.NewInt(10000000000) + testBankFunds := big.NewInt(8000000000000000000) genesisAloc[testBankAddress] = core.GenesisAccount{Balance: testBankFunds} node.TestBankKeys = append(node.TestBankKeys, testBankKey) } @@ -298,11 +299,9 @@ func New(host host.Host, consensus *bft.Consensus, db *hdb.LDBDatabase) *Node { _ = gspec.MustCommit(database) chain, _ := core.NewBlockChain(database, nil, gspec.Config, node.Consensus, vm.Config{}, nil) - node.Chain = chain //This one is not used --- RJ. node.TxPool = core.NewTxPool(core.DefaultTxPoolConfig, params.TestChainConfig, chain) - node.BlockChannelAccount = make(chan *types.Block) node.Worker = worker.New(params.TestChainConfig, chain, node.Consensus, pki.GetAddressFromPublicKey(node.SelfPeer.PubKey)) //Initialize the pending transactions with smart contract transactions