Acc/X/Receive -> Acc/X/Call

This commit is contained in:
Jae Kwon
2015-07-23 23:57:28 -07:00
parent 6b1a846201
commit feeab6579b
5 changed files with 31 additions and 31 deletions
+2 -2
View File
@@ -151,14 +151,14 @@ func TestSendCall(t *testing.T) {
}
}
// subscribes to an AccReceive, runs the vm, returns the exception
// subscribes to an AccCall, runs the vm, returns the exception
func runVMWaitEvents(t *testing.T, ourVm *VM, caller, callee *Account, subscribeAddr, contractCode []byte, gas int64) string {
// we need to catch the event from the CALL to check for exceptions
evsw := events.NewEventSwitch()
evsw.Start()
ch := make(chan interface{})
fmt.Printf("subscribe to %x\n", subscribeAddr)
evsw.AddListenerForEvent("test", types.EventStringAccReceive(subscribeAddr), func(msg interface{}) {
evsw.AddListenerForEvent("test", types.EventStringAccCall(subscribeAddr), func(msg interface{}) {
ch <- msg
})
evc := events.NewEventCache(evsw)
+5 -5
View File
@@ -95,10 +95,10 @@ func HasPermission(appState AppState, acc *Account, perm ptypes.PermFlag) bool {
return v
}
func (vm *VM) fireEvent(exception *string, output *[]byte, caller, callee *Account, input []byte, value int64, gas *int64) {
func (vm *VM) fireCallEvent(exception *string, output *[]byte, caller, callee *Account, input []byte, value int64, gas *int64) {
// fire the post call event (including exception if applicable)
if vm.evc != nil {
vm.evc.FireEvent(types.EventStringAccReceive(callee.Address.Postfix(20)), types.EventMsgCall{
vm.evc.FireEvent(types.EventStringAccCall(callee.Address.Postfix(20)), types.EventMsgCall{
&types.CallData{caller.Address.Postfix(20), callee.Address.Postfix(20), input, value, *gas},
vm.origin.Postfix(20),
vm.txid,
@@ -116,7 +116,7 @@ func (vm *VM) Call(caller, callee *Account, code, input []byte, value int64, gas
exception := new(string)
// fire the post call event (including exception if applicable)
defer vm.fireEvent(exception, &output, caller, callee, input, value, gas)
defer vm.fireCallEvent(exception, &output, caller, callee, input, value, gas)
if err = transfer(caller, callee, value); err != nil {
*exception = err.Error()
@@ -754,12 +754,12 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value int64, gas
// Native contract
ret, err = nativeContract(vm.appState, callee, args, &gasLimit)
// for now we fire the Receive event. maybe later we'll fire more particulars
// for now we fire the Call event. maybe later we'll fire more particulars
var exception string
if err != nil {
exception = err.Error()
}
vm.fireEvent(&exception, &ret, callee, &Account{Address: addr}, args, value, gas)
vm.fireCallEvent(&exception, &ret, callee, &Account{Address: addr}, args, value, gas)
} else {
// EVM contract
if ok = useGas(gas, GasGetAccount); !ok {