responding to comments

pull/422/head
ak 6 years ago
parent 3e4a8ca33b
commit 6e7902a5ef
  1. 5
      node/contract.go
  2. 6
      node/node.go

@ -36,7 +36,8 @@ func (node *Node) AddStakingContractToPendingTransactions() {
dataEnc := common.FromHex(StakingContractBinary)
// Unsigned transaction to avoid the case of transaction address.
mycontracttx, _ := types.SignTx(types.NewContractCreation(uint64(0), node.Consensus.ShardID, contractFunds, params.TxGasContractCreation*10, nil, dataEnc), types.HomesteadSigner{}, priKey)
node.StakingContractAddress = crypto.CreateAddress(contractAddress, uint64(0))
//node.StakingContractAddress = crypto.CreateAddress(contractAddress, uint64(0))
node.StakingContractAddress = node.getDeployedStakingContract(mycontracttx, contractAddress)
node.addPendingTransactions(types.Transactions{mycontracttx})
}
@ -50,8 +51,6 @@ func (node *Node) CreateStakingWithdrawTransaction(stake string) (*types.Transac
log.Error("Failed to get chain state", "Error", err)
}
nonce := state.GetNonce(crypto.PubkeyToAddress(DepositContractPriKey.PublicKey))
//callingFunction := "0x2e1a7d4d"
//Following: https://github.com/miguelmota/ethereum-development-with-go-book/blob/master/code/transfer_tokens.go
withdrawFnSignature := []byte("withdraw(uint)")
hash := sha3.NewLegacyKeccak256()

@ -160,7 +160,7 @@ type Node struct {
serviceManager *service_manager.Manager
//Staked Accounts and Contract
CurrentStakes map[common.Address]int64
CurrentStakes map[common.Address]int64 //This will save the latest information about staked nodes.
StakingContractAddress common.Address
WithdrawStakeFunc []byte
@ -259,7 +259,7 @@ func New(host p2p.Host, consensus *bft.Consensus, db ethdb.Database) *Node {
node.Worker = worker.New(params.TestChainConfig, chain, node.Consensus, pki.GetAddressFromPublicKey(node.SelfPeer.PubKey), node.Consensus.ShardID)
node.AddFaucetContractToPendingTransactions()
if node.Role == BeaconLeader {
node.AddStakingContractToPendingTransactions()
node.AddStakingContractToPendingTransactions() //This will save the latest information about staked nodes in current staked
node.DepositToFakeAccounts()
}
if node.Role == BeaconLeader || node.Role == BeaconValidator {
@ -289,7 +289,7 @@ func New(host p2p.Host, consensus *bft.Consensus, db ethdb.Database) *Node {
//(Refer: https://solidity.readthedocs.io/en/v0.5.3/introduction-to-smart-contracts.html#index-8)
// Then we can (re)create the deployed address. Trivially, this is 0 for us.
// The deployed contract address can also be obtained via the receipt of the contract creating transaction.
func (node *Node) getDeployedStakingContract(mycontracttx types.Transaction, contractAddress common.Address) common.Address {
func (node *Node) getDeployedStakingContract(mycontracttx *types.Transaction, contractAddress common.Address) common.Address {
//Ideally we send the transaction to
//Correct Way 1:

Loading…
Cancel
Save