move perms to vm.Account

This commit is contained in:
Ethan Buchman
2015-05-16 00:48:04 -04:00
committed by Jae Kwon
parent c6c0701b69
commit 94f21ad012
10 changed files with 55 additions and 304 deletions

View File

@ -10,15 +10,14 @@ import (
. "github.com/tendermint/tendermint/common"
dbm "github.com/tendermint/tendermint/db"
"github.com/tendermint/tendermint/merkle"
ptypes "github.com/tendermint/tendermint/permission/types"
"github.com/tendermint/tendermint/types"
)
type GenesisAccount struct {
Address []byte `json:"address"`
Amount int64 `json:"amount"`
Address []byte `json:"address"`
Amount uint64 `json:"amount"`
Permissions *account.Permissions `json:"global_permissions"` // pointer so optional
Address []byte `json:"address"`
Amount uint64 `json:"amount"`
Permissions *ptypes.Permissions `json:"global_permissions"` // pointer so optional
}
type GenesisValidator struct {
@ -29,7 +28,7 @@ type GenesisValidator struct {
type GenesisParams struct {
// Default permissions for newly created accounts
GlobalPermissions *account.Permissions `json:"global_permissions"`
GlobalPermissions *ptypes.Permissions `json:"global_permissions"`
// TODO: other params we may want to tweak?
}
@ -74,9 +73,10 @@ func MakeGenesisState(db dbm.DB, genDoc *GenesisDoc) *State {
// Make accounts state tree
accounts := merkle.NewIAVLTree(binary.BasicCodec, account.AccountCodec, defaultAccountsCacheCapacity, db)
for _, genAcc := range genDoc.Accounts {
perm := account.DefaultPermissions
perm_ := account.DefaultPermissions
perm := &perm_
if genAcc.Permissions != nil {
perm = *(genAcc.Permissions)
perm = genAcc.Permissions
}
acc := &account.Account{
Address: genAcc.Address,
@ -90,12 +90,13 @@ func MakeGenesisState(db dbm.DB, genDoc *GenesisDoc) *State {
// global permissions are saved as the 0 address
// so they are included in the accounts tree
globalPerms := account.DefaultPermissions
globalPerms_ := account.DefaultPermissions
globalPerms := &globalPerms_
if genDoc.Params != nil && genDoc.Params.GlobalPermissions != nil {
globalPerms = *(genDoc.Params.GlobalPermissions)
globalPerms = genDoc.Params.GlobalPermissions
}
permsAcc := &account.Account{
Address: account.GlobalPermissionsAddress,
Address: ptypes.GlobalPermissionsAddress,
PubKey: nil,
Sequence: 0,
Balance: 1337,