expect []byte instead of common.Address in ethapi tracer

This commit is contained in:
Viktor 2017-11-13 20:29:02 +03:00
parent c2f756bf17
commit 9bebb9adef

View file

@ -130,33 +130,28 @@ type dbWrapper struct {
} }
// getBalance retrieves an account's balance // getBalance retrieves an account's balance
func (dw *dbWrapper) getBalance(addr common.Address) *big.Int { func (dw *dbWrapper) getBalance(addr []byte) *big.Int {
return dw.db.GetBalance(addr)
}
// getBalance retrieves an account's balance
func (dw *dbWrapper) getBalanceFromJs(addr []byte) *big.Int {
return dw.db.GetBalance(common.BytesToAddress(addr)) return dw.db.GetBalance(common.BytesToAddress(addr))
} }
// getNonce retrieves an account's nonce // getNonce retrieves an account's nonce
func (dw *dbWrapper) getNonce(addr common.Address) uint64 { func (dw *dbWrapper) getNonce(addr []byte) uint64 {
return dw.db.GetNonce(addr) return dw.db.GetNonce(common.BytesToAddress(addr))
} }
// getCode retrieves an account's code // getCode retrieves an account's code
func (dw *dbWrapper) getCode(addr common.Address) []byte { func (dw *dbWrapper) getCode(addr []byte) []byte {
return dw.db.GetCode(addr) return dw.db.GetCode(common.BytesToAddress(addr))
} }
// getState retrieves an account's state data for the given hash // getState retrieves an account's state data for the given hash
func (dw *dbWrapper) getState(addr common.Address, hash common.Hash) common.Hash { func (dw *dbWrapper) getState(addr []byte, hash common.Hash) common.Hash {
return dw.db.GetState(addr, hash) return dw.db.GetState(common.BytesToAddress(addr), hash)
} }
// exists returns true iff the account exists // exists returns true iff the account exists
func (dw *dbWrapper) exists(addr common.Address) bool { func (dw *dbWrapper) exists(addr []byte) bool {
return dw.db.Exist(addr) return dw.db.Exist(common.BytesToAddress(addr))
} }
// toValue returns an otto.Value for the dbWrapper // toValue returns an otto.Value for the dbWrapper
@ -164,7 +159,6 @@ func (dw *dbWrapper) toValue(vm *otto.Otto) otto.Value {
value, _ := vm.ToValue(dw) value, _ := vm.ToValue(dw)
obj := value.Object() obj := value.Object()
obj.Set("getBalance", dw.getBalance) obj.Set("getBalance", dw.getBalance)
obj.Set("getBalanceFromJs", dw.getBalanceFromJs)
obj.Set("getNonce", dw.getNonce) obj.Set("getNonce", dw.getNonce)
obj.Set("getCode", dw.getCode) obj.Set("getCode", dw.getCode)
obj.Set("getState", dw.getState) obj.Set("getState", dw.getState)