[wallet] use random port to avoid .dht file conflict

Signed-off-by: Leo Chen <leo@harmony.one>
pull/1511/head
Leo Chen 5 years ago
parent d2b3e8c340
commit 54339667ed
  1. 9
      cmd/client/wallet/main.go

@ -290,8 +290,9 @@ func createWalletNode() *node.Node {
// dummy host for wallet // dummy host for wallet
// TODO: potentially, too many dummy IP may flush out good IP address from our bootnode DHT // TODO: potentially, too many dummy IP may flush out good IP address from our bootnode DHT
// we need to understand the impact to bootnode DHT with this dummy host ip added // we need to understand the impact to bootnode DHT with this dummy host ip added
self := p2p.Peer{IP: "127.0.0.1", Port: "6999"} port := fmt.Sprintf("%d", 16999+rand.Intn(1000))
priKey, _, _ := utils.GenKeyP2P("127.0.0.1", "6999") self := p2p.Peer{IP: "127.0.0.1", Port: port}
priKey, _, _ := utils.GenKeyP2P("127.0.0.1", port)
host, err := p2pimpl.NewHost(&self, priKey) host, err := p2pimpl.NewHost(&self, priKey)
if err != nil { if err != nil {
panic(err) panic(err)
@ -688,8 +689,6 @@ func processTransferCommand() {
return return
} }
walletNode := createWalletNode()
shardIDToAccountState := FetchBalance(senderAddress) shardIDToAccountState := FetchBalance(senderAddress)
state := shardIDToAccountState[shardID] state := shardIDToAccountState[shardID]
@ -705,6 +704,8 @@ func processTransferCommand() {
return return
} }
walletNode := createWalletNode()
amountBigInt := big.NewInt(int64(amount * denominations.Nano)) amountBigInt := big.NewInt(int64(amount * denominations.Nano))
amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.Nano)) amountBigInt = amountBigInt.Mul(amountBigInt, big.NewInt(denominations.Nano))
gas, err := core.IntrinsicGas(inputData, false, true) gas, err := core.IntrinsicGas(inputData, false, true)

Loading…
Cancel
Save