()
| 62 | } |
| 63 | |
| 64 | func (this *NativeService) Invoke() ([]byte, error) { |
| 65 | contract := this.InvokeParam |
| 66 | services, ok := Contracts[contract.Address] |
| 67 | if !ok { |
| 68 | return BYTE_FALSE, fmt.Errorf("Native contract address %x haven't been registered.", contract.Address) |
| 69 | } |
| 70 | services(this) |
| 71 | service, ok := this.ServiceMap[contract.Method] |
| 72 | if !ok { |
| 73 | return BYTE_FALSE, fmt.Errorf("Native contract %x doesn't support this function %s.", |
| 74 | contract.Address, contract.Method) |
| 75 | } |
| 76 | args := this.Input |
| 77 | this.Input = contract.Args |
| 78 | this.ContextRef.PushContext(&context.Context{ContractAddress: contract.Address}) |
| 79 | notifications := this.Notifications |
| 80 | this.Notifications = []*event.NotifyEventInfo{} |
| 81 | result, err := service(this) |
| 82 | if err != nil { |
| 83 | return result, errors.NewDetailErr(err, errors.ErrNoCode, "[Invoke] Native serivce function execute error!") |
| 84 | } |
| 85 | this.ContextRef.PopContext() |
| 86 | this.ContextRef.PushNotifications(this.Notifications) |
| 87 | this.Notifications = notifications |
| 88 | this.Input = args |
| 89 | return result, nil |
| 90 | } |
| 91 | |
| 92 | func (this *NativeService) NativeCall(address common.Address, method string, args []byte) (interface{}, error) { |
| 93 | c := states.ContractInvokeParam{ |
no test coverage detected