Пример #1
0
// Generates a new validator with private key.
func GenPrivValidator() *PrivValidator {
	privKeyBytes := new([64]byte)
	copy(privKeyBytes[:32], CRandBytes(32))
	pubKeyBytes := ed25519.MakePublicKey(privKeyBytes)
	pubKey := acm.PubKeyEd25519(*pubKeyBytes)
	privKey := acm.PrivKeyEd25519(*privKeyBytes)
	return &PrivValidator{
		Address:    pubKey.Address(),
		PubKey:     pubKey,
		PrivKey:    privKey,
		LastHeight: 0,
		LastRound:  0,
		LastStep:   stepNone,
		filePath:   "",
	}
}
Пример #2
0
// initialize config and create new node
func init() {
	// Save new priv_validator file.
	priv := &state.PrivValidator{
		Address: decodeHex(userAddr),
		PubKey:  account.PubKeyEd25519(decodeHex(userPub)),
		PrivKey: account.PrivKeyEd25519(decodeHex(userPriv)),
	}
	priv.SetFile(config.GetString("priv_validator_file"))
	priv.Save()

	consensus.RoundDuration0 = 3 * time.Second
	consensus.RoundDurationDelta = 1 * time.Second

	// start a node
	ready := make(chan struct{})
	go newNode(ready)
	<-ready
}
Пример #3
0
// initialize config and create new node
func init() {
	chainID = config.GetString("chain_id")

	// Save new priv_validator file.
	priv := &types.PrivValidator{
		Address: user[0].Address,
		PubKey:  acm.PubKeyEd25519(user[0].PubKey.(acm.PubKeyEd25519)),
		PrivKey: acm.PrivKeyEd25519(user[0].PrivKey.(acm.PrivKeyEd25519)),
	}
	priv.SetFile(config.GetString("priv_validator_file"))
	priv.Save()

	// TODO: change consensus/state.go timeouts to be shorter

	// start a node
	ready := make(chan struct{})
	go newNode(ready)
	<-ready
}