Support multiple newnodes

pull/519/head
Rongjian Lan 6 years ago
parent 413ae2fd1e
commit 194a7617c6
  1. 3
      cmd/harmony.go
  2. 4
      node/staking.go
  3. 6
      test/deploy_newnode.sh

@ -106,6 +106,7 @@ func main() {
// isNewNode indicates this node is a new node
isNewNode := flag.Bool("is_newnode", false, "true means this node is a new node")
accountIndex := flag.Int("account_index", 0, "the index of the staking account to use")
// isLeader indicates this node is a beacon chain leader node during the bootstrap process
isLeader := flag.Bool("is_leader", false, "true means this node is a beacon chain leader node")
@ -143,7 +144,7 @@ func main() {
var clientPeer *p2p.Peer
var role string
stakingPriKey := node.LoadStakingKeyFromFile(*stakingKeyFile)
stakingPriKey := node.LoadStakingKeyFromFile(*stakingKeyFile, *accountIndex)
nodePriKey, _, err := utils.LoadKeyFromFile(*keyFile)
if err != nil {

@ -105,9 +105,9 @@ func decodeFuncSign(data []byte) string {
// a new random private key
// Currently for deploy_newnode.sh, we hard-coded the first fake account as staking account and
// it is minted in genesis block. See genesis_node.go
func LoadStakingKeyFromFile(keyfile string) *ecdsa.PrivateKey {
func LoadStakingKeyFromFile(keyfile string, accountIndex int) *ecdsa.PrivateKey {
// contract.FakeAccounts[0] gets minted tokens in genesis block of beacon chain.
key, err := crypto.HexToECDSA(contract.FakeAccounts[0].Private)
key, err := crypto.HexToECDSA(contract.StakingAccounts[accountIndex].Private)
if err != nil {
utils.GetLogInstance().Error("Unable to get staking key")
os.Exit(1)

@ -119,4 +119,8 @@ HMY_OPT=
HMY_OPT2=
HMY_OPT3=
($DRYRUN $ROOT/bin/harmony -ip 127.0.0.1 -port 9100 -log_folder $log_folder -is_newnode $DB -min_peers $MIN $HMY_OPT $HMY_OPT2 $HMY_OPT3 -key /tmp/127.0.0.1-9100.key 2>&1 | tee -a $LOG_FILE ) &
for i in {0..4}
do
echo "launching new node $i ..."
($DRYRUN $ROOT/bin/harmony -ip 127.0.0.1 -port 910$i -log_folder $log_folder -is_newnode $DB -account_index $i -min_peers $MIN $HMY_OPT $HMY_OPT2 $HMY_OPT3 -key /tmp/127.0.0.1-910$i.key 2>&1 | tee -a $LOG_FILE ) &
done

Loading…
Cancel
Save