permission/types pkg, Base and Roles

This commit is contained in:
Ethan Buchman
2015-05-20 00:40:02 -04:00
committed by Jae Kwon
parent 94f21ad012
commit 87ed1f5fda
9 changed files with 286 additions and 67 deletions

View File

@ -15,9 +15,9 @@ import (
)
type GenesisAccount struct {
Address []byte `json:"address"`
Amount uint64 `json:"amount"`
Permissions *ptypes.Permissions `json:"global_permissions"` // pointer so optional
Address []byte `json:"address"`
Amount uint64 `json:"amount"`
Permissions *ptypes.AccountPermissions `json:"global_permissions"` // pointer so optional
}
type GenesisValidator struct {
@ -28,7 +28,7 @@ type GenesisValidator struct {
type GenesisParams struct {
// Default permissions for newly created accounts
GlobalPermissions *ptypes.Permissions `json:"global_permissions"`
GlobalPermissions *ptypes.AccountPermissions `json:"global_permissions"`
// TODO: other params we may want to tweak?
}
@ -73,8 +73,7 @@ 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 := &perm_
perm := ptypes.NewDefaultAccountPermissions()
if genAcc.Permissions != nil {
perm = genAcc.Permissions
}
@ -90,10 +89,11 @@ 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 := &globalPerms_
globalPerms := ptypes.NewDefaultAccountPermissions()
if genDoc.Params != nil && genDoc.Params.GlobalPermissions != nil {
globalPerms = genDoc.Params.GlobalPermissions
// XXX: make sure the set bits are all true
globalPerms.Base.SetBit = ptypes.AllSet
}
permsAcc := &account.Account{
Address: ptypes.GlobalPermissionsAddress,