Пример #1
0
func gen_account() {
	privAccount := account.GenPrivAccount()
	privAccountJSONBytes := binary.JSONBytes(privAccount)
	fmt.Printf(`Generated a new account!

%v

`,
		string(privAccountJSONBytes),
	)
}
Пример #2
0
func RandAccount(randBalance bool, minBalance uint64) (*account.Account, *account.PrivAccount) {
	privAccount := account.GenPrivAccount()
	acc := &account.Account{
		Address:  privAccount.PubKey.Address(),
		PubKey:   privAccount.PubKey,
		Sequence: RandUint(),
		Balance:  minBalance,
	}
	if randBalance {
		acc.Balance += uint64(RandUint32())
	}
	return acc, privAccount
}
Пример #3
0
func RandAccount(randBalance bool, minBalance int64) (*acm.Account, *acm.PrivAccount) {
	privAccount := acm.GenPrivAccount()
	perms := ptypes.DefaultAccountPermissions
	acc := &acm.Account{
		Address:     privAccount.PubKey.Address(),
		PubKey:      privAccount.PubKey,
		Sequence:    RandInt(),
		Balance:     minBalance,
		Permissions: perms,
	}
	if randBalance {
		acc.Balance += int64(RandUint32())
	}
	return acc, privAccount
}
Пример #4
0
func BenchmarkValidatorSetCopy(b *testing.B) {
	b.StopTimer()
	vset := NewValidatorSet([]*Validator{})
	for i := 0; i < 1000; i++ {
		privAccount := account.GenPrivAccount()
		val := &Validator{
			Address: privAccount.Address,
			PubKey:  privAccount.PubKey.(account.PubKeyEd25519),
		}
		if !vset.Add(val) {
			panic("Failed to add validator")
		}
	}
	b.StartTimer()

	for i := 0; i < b.N; i++ {
		vset.Copy()
	}
}
Пример #5
0
func GenPrivAccount() (*ctypes.ResultGenPrivAccount, error) {
	return &ctypes.ResultGenPrivAccount{acm.GenPrivAccount()}, nil
}