mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-09 21:32:14 +00:00
added DumpStorage RPC command
This commit is contained in:
parent
d2d1214e20
commit
6f0199aadf
@ -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(addr []byte) (*ResponseGetAccount, error) {
|
||||||
|
|
||||||
func GetAccount(address []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
|
||||||
|
}
|
||||||
|
@ -19,6 +19,16 @@ type ResponseListAccounts struct {
|
|||||||
Accounts []*account.Account
|
Accounts []*account.Account
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StorageItem struct {
|
||||||
|
Key []byte
|
||||||
|
Value []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResponseDumpStorage struct {
|
||||||
|
StorageRoot []byte
|
||||||
|
StorageItems []StorageItem
|
||||||
|
}
|
||||||
|
|
||||||
type ResponseBlockchainInfo struct {
|
type ResponseBlockchainInfo struct {
|
||||||
LastHeight uint
|
LastHeight uint
|
||||||
BlockMetas []*types.BlockMeta
|
BlockMetas []*types.BlockMeta
|
||||||
|
@ -23,6 +23,7 @@ var funcMap = map[string]*FuncWrapper{
|
|||||||
"get_block": funcWrap(core.GetBlock, []string{"height"}),
|
"get_block": funcWrap(core.GetBlock, []string{"height"}),
|
||||||
"get_account": funcWrap(core.GetAccount, []string{"address"}),
|
"get_account": funcWrap(core.GetAccount, []string{"address"}),
|
||||||
"list_validators": funcWrap(core.ListValidators, []string{}),
|
"list_validators": funcWrap(core.ListValidators, []string{}),
|
||||||
|
"dump_storage": funcWrap(core.DumpStorage, []string{"address"}),
|
||||||
"broadcast_tx": funcWrap(core.BroadcastTx, []string{"tx"}),
|
"broadcast_tx": funcWrap(core.BroadcastTx, []string{"tx"}),
|
||||||
"list_accounts": funcWrap(core.ListAccounts, []string{}),
|
"list_accounts": funcWrap(core.ListAccounts, []string{}),
|
||||||
"unsafe/gen_priv_account": funcWrap(core.GenPrivAccount, []string{}),
|
"unsafe/gen_priv_account": funcWrap(core.GenPrivAccount, []string{}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user