Skip to content

Commit

Permalink
add rpc getaccountbyid
Browse files Browse the repository at this point in the history
  • Loading branch information
findbug2019 committed Mar 14, 2019
1 parent 61f0a15 commit 3419d37
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
4 changes: 4 additions & 0 deletions accountmanager/accountmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ func TestNewAccountManager(t *testing.T) {
}
}

func TestAccountManager_InitAccountCounter(t *testing.T) {
//TODO
}

func TestAccountManager_CreateAccount(t *testing.T) {
type fields struct {
sdb *state.StateDB
Expand Down
11 changes: 0 additions & 11 deletions blockchain/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ func SetupGenesisBlock(db fdb.Database, genesis *Genesis) (*params.ChainConfig,
// Get the existing chain configuration.
newcfg := genesis.configOrDefault(stored)

//init account and asset manager
// if !am.SetAcctMangerName(newcfg.SysName) {
// return newcfg, newdpos, stored, fmt.Errorf("genesis set account manager fail")
// }
if !am.SetSysName(newcfg.SysName) {
return newcfg, newdpos, stored, fmt.Errorf("genesis set account sys name fail")
}
// if !asset.SetAssetMangerName(newcfg.SysName) {
// return newcfg, newdpos, stored, fmt.Errorf("genesis set asset manager fail")
// }

height := rawdb.ReadHeaderNumber(db, rawdb.ReadHeadHeaderHash(db))
if height == nil {
return newcfg, newdpos, stored, fmt.Errorf("missing block number for head header hash")
Expand Down
6 changes: 3 additions & 3 deletions blockchain/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/fractalplatform/fractal/utils/fdb"
)

var defaultgenesisBlockHash = common.HexToHash("0xa139f1d16692026cd921e437e45506f2dec998f8ea57a5075e878afd4b428cc3")
var defaultgenesisBlockHash = common.HexToHash("3b9d8a76a7ea8bc82f07978c58318d346d581553efb78e9980299fd2603916a0")

func TestDefaultGenesisBlock(t *testing.T) {
block := DefaultGenesis().ToBlock(nil)
Expand All @@ -41,7 +41,7 @@ func TestDefaultGenesisBlock(t *testing.T) {

func TestSetupGenesis(t *testing.T) {
var (
customghash = common.HexToHash("0xf0ef187e3f23ac20aba4df4e4a6d6327f2eb56a0724c1a690be32d0af5ecb501")
customghash = common.HexToHash("0x1519f4b0ee03a8250b4c077705f3c88289bef6d32428d812e00eae624e59c75b")
customg = Genesis{
Config: &params.ChainConfig{ChainID: big.NewInt(3), SysName: "systemio", SysToken: "fractalfoundation"},
Dpos: dpos.DefaultConfig,
Expand All @@ -50,7 +50,7 @@ func TestSetupGenesis(t *testing.T) {
AllocAssets: DefaultGenesisAssets(),
}
oldcustomg = customg
oldcustomghash = common.HexToHash("0x461543306818df6d262089961cb45becf06a551dd36f61ab4cee78af8fb47f64")
oldcustomghash = common.HexToHash("0x954dba22b0197e16402283f3372ed57b7e2a2645888fe82833caf45b0069f0ff")

dposConfig = &dpos.Config{
MaxURLLen: 512,
Expand Down
12 changes: 12 additions & 0 deletions internal/api/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ func (aapi *AccountAPI) AccountIsExist(ctx context.Context, acctName common.Name
return acct.AccountIsExist(acctName)
}

//GetAccountByID
func (aapi *AccountAPI) GetAccountByID(ctx context.Context, accountID uint64) (*accountmanager.Account, error) {
am, err := aapi.b.GetAccountManager()
if err != nil {
return nil, err
}
if am == nil {
return nil, ErrGetAccounManagerErr
}
return am.GetAccountById(accountID)
}

//GetAccountByName
func (aapi *AccountAPI) GetAccountByName(ctx context.Context, accountName common.Name) (*accountmanager.Account, error) {
am, err := aapi.b.GetAccountManager()
Expand Down

0 comments on commit 3419d37

Please sign in to comment.