|
@ -1,24 +1,19 @@ |
|
|
package core |
|
|
package core |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
|
|
|
"fmt" |
|
|
"github.com/tendermint/tendermint2/account" |
|
|
"github.com/tendermint/tendermint2/account" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
func GenPrivAccount() (*ResponseGenPrivAccount, error) { |
|
|
func GenPrivAccount() (*ResponseGenPrivAccount, error) { |
|
|
return &ResponseGenPrivAccount{account.GenPrivAccount()}, nil |
|
|
return &ResponseGenPrivAccount{account.GenPrivAccount()}, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
func GetAccount(address []byte) (*ResponseGetAccount, error) { |
|
|
|
|
|
|
|
|
func GetAccount(addr []byte) (*ResponseGetAccount, error) { |
|
|
cache := mempoolReactor.Mempool.GetCache() |
|
|
cache := mempoolReactor.Mempool.GetCache() |
|
|
return &ResponseGetAccount{cache.GetAccount(address)}, nil |
|
|
|
|
|
|
|
|
return &ResponseGetAccount{cache.GetAccount(addr)}, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
func ListAccounts() (*ResponseListAccounts, error) { |
|
|
func ListAccounts() (*ResponseListAccounts, error) { |
|
|
var blockHeight uint |
|
|
var blockHeight uint |
|
|
var accounts []*account.Account |
|
|
var accounts []*account.Account |
|
@ -30,3 +25,20 @@ func ListAccounts() (*ResponseListAccounts, error) { |
|
|
}) |
|
|
}) |
|
|
return &ResponseListAccounts{blockHeight, accounts}, nil |
|
|
return &ResponseListAccounts{blockHeight, accounts}, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func DumpStorage(addr []byte) (*ResponseDumpStorage, error) { |
|
|
|
|
|
state := consensusState.GetState() |
|
|
|
|
|
account := state.GetAccount(addr) |
|
|
|
|
|
if account == nil { |
|
|
|
|
|
return nil, fmt.Errorf("Unknown address: %X", addr) |
|
|
|
|
|
} |
|
|
|
|
|
storageRoot := account.StorageRoot |
|
|
|
|
|
storage := state.LoadStorage(storageRoot) |
|
|
|
|
|
storageItems := []StorageItem{} |
|
|
|
|
|
storage.Iterate(func(key interface{}, value interface{}) bool { |
|
|
|
|
|
storageItems = append(storageItems, StorageItem{ |
|
|
|
|
|
key.([]byte), value.([]byte)}) |
|
|
|
|
|
return false |
|
|
|
|
|
}) |
|
|
|
|
|
return &ResponseDumpStorage{storageRoot, storageItems}, nil |
|
|
|
|
|
} |