예제 #1
0
func gen_account() {
	privAccount := account.GenPrivAccount()
	privAccountJSONBytes := binary.JSONBytes(privAccount)
	fmt.Printf(`Generated a new account!

%v

`,
		string(privAccountJSONBytes),
	)
}
예제 #2
0
파일: test.go 프로젝트: jaekwon/GuppyCamp
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
}