mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-13 13:21:20 +00:00
Some renames and small fixes.
This commit is contained in:
@ -242,7 +242,7 @@ func (bcR *BlockchainReactor) BroadcastStatus() error {
|
||||
}
|
||||
|
||||
// implements events.Eventable
|
||||
func (bcR *BlockchainReactor) AddEventSwitch(evsw *events.EventSwitch) {
|
||||
func (bcR *BlockchainReactor) SetEventSwitch(evsw *events.EventSwitch) {
|
||||
bcR.evsw = evsw
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ func (conR *ConsensusReactor) ResetToState(state *sm.State) {
|
||||
}
|
||||
|
||||
// implements events.Eventable
|
||||
func (conR *ConsensusReactor) AddEventSwitch(evsw *events.EventSwitch) {
|
||||
func (conR *ConsensusReactor) SetEventSwitch(evsw *events.EventSwitch) {
|
||||
conR.evsw = evsw
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ func NewNode() *Node {
|
||||
|
||||
// add the event switch to all services
|
||||
// they should all satisfy events.Eventable
|
||||
AddEventSwitch(eventSwitch, pexReactor, bcReactor, mempoolReactor, consensusReactor)
|
||||
SetEventSwitch(eventSwitch, pexReactor, bcReactor, mempoolReactor, consensusReactor)
|
||||
|
||||
return &Node{
|
||||
sw: sw,
|
||||
@ -116,9 +116,9 @@ func (n *Node) Stop() {
|
||||
}
|
||||
|
||||
// Add the event switch to reactors, mempool, etc.
|
||||
func AddEventSwitch(evsw *events.EventSwitch, eventables ...events.Eventable) {
|
||||
func SetEventSwitch(evsw *events.EventSwitch, eventables ...events.Eventable) {
|
||||
for _, e := range eventables {
|
||||
e.AddEventSwitch(evsw)
|
||||
e.SetEventSwitch(evsw)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
// reactors and other modules should export
|
||||
// this interface to become eventable
|
||||
type Eventable interface {
|
||||
AddEventSwitch(*EventSwitch)
|
||||
SetEventSwitch(*EventSwitch)
|
||||
}
|
||||
|
||||
type EventSwitch struct {
|
||||
|
@ -114,7 +114,7 @@ func (memR *MempoolReactor) BroadcastTx(tx types.Tx) error {
|
||||
}
|
||||
|
||||
// implements events.Eventable
|
||||
func (memR *MempoolReactor) AddEventSwitch(evsw *events.EventSwitch) {
|
||||
func (memR *MempoolReactor) SetEventSwitch(evsw *events.EventSwitch) {
|
||||
memR.evsw = evsw
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ func (pexR *PEXReactor) ensurePeers() {
|
||||
}
|
||||
|
||||
// implements events.Eventable
|
||||
func (pexR *PEXReactor) AddEventSwitch(evsw *events.EventSwitch) {
|
||||
func (pexR *PEXReactor) SetEventSwitch(evsw *events.EventSwitch) {
|
||||
pexR.evsw = evsw
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ type Client interface {
|
||||
GenPrivAccount() (*core.ResponseGenPrivAccount, error)
|
||||
GetAccount(address []byte) (*core.ResponseGetAccount, error)
|
||||
GetBlock(height uint) (*core.ResponseGetBlock, error)
|
||||
GetStorage(address []byte, storage []byte) (*core.ResponseGetStorage, error)
|
||||
GetStorage(address []byte, key []byte) (*core.ResponseGetStorage, error)
|
||||
ListAccounts() (*core.ResponseListAccounts, error)
|
||||
ListValidators() (*core.ResponseListValidators, error)
|
||||
NetInfo() (*core.ResponseNetInfo, error)
|
||||
@ -269,8 +269,8 @@ func (c *ClientHTTP) GetBlock(height uint) (*core.ResponseGetBlock, error) {
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) GetStorage(address []byte, storage []byte) (*core.ResponseGetStorage, error) {
|
||||
values, err := argsToURLValues([]string{"address", "storage"}, address, storage)
|
||||
func (c *ClientHTTP) GetStorage(address []byte, key []byte) (*core.ResponseGetStorage, error) {
|
||||
values, err := argsToURLValues([]string{"address", "key"}, address, key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -390,7 +390,7 @@ func (c *ClientHTTP) NetInfo() (*core.ResponseNetInfo, error) {
|
||||
}
|
||||
|
||||
func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*core.ResponseSignTx, error) {
|
||||
values, err := argsToURLValues([]string{"tx", "privAccounts"}, tx, privAccounts)
|
||||
values, err := argsToURLValues([]string{"tx", "priv_accounts"}, tx, privAccounts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -665,11 +665,11 @@ func (c *ClientJSON) GetBlock(height uint) (*core.ResponseGetBlock, error) {
|
||||
return response.Result, nil
|
||||
}
|
||||
|
||||
func (c *ClientJSON) GetStorage(address []byte, storage []byte) (*core.ResponseGetStorage, error) {
|
||||
func (c *ClientJSON) GetStorage(address []byte, key []byte) (*core.ResponseGetStorage, error) {
|
||||
request := RPCRequest{
|
||||
JSONRPC: "2.0",
|
||||
Method: reverseFuncMap["GetStorage"],
|
||||
Params: []interface{}{address, storage},
|
||||
Params: []interface{}{address, key},
|
||||
Id: 0,
|
||||
}
|
||||
body, err := c.RequestResponse(request)
|
||||
|
@ -15,7 +15,7 @@ func GetAccount(address []byte) (*ResponseGetAccount, error) {
|
||||
return &ResponseGetAccount{cache.GetAccount(address)}, nil
|
||||
}
|
||||
|
||||
func GetStorage(address, storage []byte) (*ResponseGetStorage, error) {
|
||||
func GetStorage(address, key []byte) (*ResponseGetStorage, error) {
|
||||
state := consensusState.GetState()
|
||||
account := state.GetAccount(address)
|
||||
if account == nil {
|
||||
@ -24,11 +24,11 @@ func GetStorage(address, storage []byte) (*ResponseGetStorage, error) {
|
||||
storageRoot := account.StorageRoot
|
||||
storageTree := state.LoadStorage(storageRoot)
|
||||
|
||||
_, value := storageTree.Get(RightPadWord256(storage).Bytes())
|
||||
_, value := storageTree.Get(RightPadWord256(key).Bytes())
|
||||
if value == nil {
|
||||
return &ResponseGetStorage{storage, nil}, nil
|
||||
return &ResponseGetStorage{key, nil}, nil
|
||||
}
|
||||
return &ResponseGetStorage{storage, value.([]byte)}, nil
|
||||
return &ResponseGetStorage{key, value.([]byte)}, nil
|
||||
}
|
||||
|
||||
func ListAccounts() (*ResponseListAccounts, error) {
|
||||
@ -50,9 +50,9 @@ func DumpStorage(addr []byte) (*ResponseDumpStorage, error) {
|
||||
return nil, fmt.Errorf("Unknown address: %X", addr)
|
||||
}
|
||||
storageRoot := account.StorageRoot
|
||||
storage := state.LoadStorage(storageRoot)
|
||||
storageTree := state.LoadStorage(storageRoot)
|
||||
storageItems := []StorageItem{}
|
||||
storage.Iterate(func(key interface{}, value interface{}) bool {
|
||||
storageTree.Iterate(func(key interface{}, value interface{}) bool {
|
||||
storageItems = append(storageItems, StorageItem{
|
||||
key.([]byte), value.([]byte)})
|
||||
return false
|
||||
|
@ -24,7 +24,7 @@ var funcMap = map[string]*FuncWrapper{
|
||||
"blockchain": funcWrap(core.BlockchainInfo, []string{"min_height", "max_height"}),
|
||||
"get_block": funcWrap(core.GetBlock, []string{"height"}),
|
||||
"get_account": funcWrap(core.GetAccount, []string{"address"}),
|
||||
"get_storage": funcWrap(core.GetStorage, []string{"address", "storage"}),
|
||||
"get_storage": funcWrap(core.GetStorage, []string{"address", "key"}),
|
||||
"call": funcWrap(core.Call, []string{"address", "data"}),
|
||||
"call_code": funcWrap(core.CallCode, []string{"code", "data"}),
|
||||
"list_validators": funcWrap(core.ListValidators, []string{}),
|
||||
@ -32,7 +32,7 @@ var funcMap = map[string]*FuncWrapper{
|
||||
"broadcast_tx": funcWrap(core.BroadcastTx, []string{"tx"}),
|
||||
"list_accounts": funcWrap(core.ListAccounts, []string{}),
|
||||
"unsafe/gen_priv_account": funcWrap(core.GenPrivAccount, []string{}),
|
||||
"unsafe/sign_tx": funcWrap(core.SignTx, []string{"tx", "privAccounts"}),
|
||||
"unsafe/sign_tx": funcWrap(core.SignTx, []string{"tx", "priv_accounts"}),
|
||||
}
|
||||
|
||||
// maps camel-case function names to lower case rpc version
|
||||
|
@ -209,9 +209,9 @@ func dumpStorage(t *testing.T, addr []byte) core.ResponseDumpStorage {
|
||||
return *resp
|
||||
}
|
||||
|
||||
func getStorage(t *testing.T, typ string, addr, slot []byte) []byte {
|
||||
func getStorage(t *testing.T, typ string, addr, key []byte) []byte {
|
||||
client := clients[typ]
|
||||
resp, err := client.GetStorage(addr, slot)
|
||||
resp, err := client.GetStorage(addr, key)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ func (st *Stack) useGas(gasToUse uint64) {
|
||||
}
|
||||
|
||||
func (st *Stack) setErr(err error) {
|
||||
//if *st.err != nil {
|
||||
if *st.err == nil {
|
||||
*st.err = err
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
func (st *Stack) Push(d Word256) {
|
||||
|
2
vm/vm.go
2
vm/vm.go
@ -659,7 +659,7 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value uint64, ga
|
||||
case RETURN: // 0xF3
|
||||
offset, size := stack.Pop64(), stack.Pop64()
|
||||
ret, ok := subslice(memory, offset, size, false)
|
||||
if !ok || err != nil {
|
||||
if !ok {
|
||||
return nil, firstErr(err, ErrMemoryOutOfBounds)
|
||||
}
|
||||
dbg.Printf(" => [%v, %v] (%d) 0x%X\n", offset, size, len(ret), ret)
|
||||
|
Reference in New Issue
Block a user