Skip to content

Commit 90fd2a2

Browse files
authored
Merge pull request ethereum#4 from CortexFoundation/ucwong
pay for the model if exist
2 parents 53c14ec + 7d011b5 commit 90fd2a2

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

core/vm/evm.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
192192
contract.UseGas(contract.Gas)
193193
}
194194
}
195+
196+
if evm.interpreter.IsModelMeta(ret) {
197+
//only if model is exist from ipfs, swarm or libtorrent ext, load model to memory
198+
//todo if ret is model meta, pay some fee to model owner depends on set in meta data
199+
// if exist
200+
//evm.Transfer(evm.StateDB, caller.Address(), model.Owner,model.Fee)
201+
}
195202
return ret, contract.Gas, err
196203
}
197204

core/vm/interpreter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack
9797
return nil
9898
}
9999

100-
func isModelMeta(code []byte) bool {
100+
func IsModelMeta(code []byte) bool {
101101
for i := 0; i < 8; i++ {
102102
if code[i] != 0 {
103103
return false
@@ -106,7 +106,7 @@ func isModelMeta(code []byte) bool {
106106
return true
107107
}
108108

109-
func isInputMeta(code []byte) bool {
109+
func IsInputMeta(code []byte) bool {
110110
for i := 0; i < 8; i++ {
111111
if code[i] != 1 {
112112
return false
@@ -135,11 +135,11 @@ func (in *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err er
135135
return nil, nil
136136
}
137137

138-
if isModelMeta(contract.Code) {
138+
if IsModelMeta(contract.Code) {
139139
return contract.Code, nil
140140
}
141141

142-
if isInputMeta(contract.Code) {
142+
if IsInputMeta(contract.Code) {
143143
return contract.Code, nil
144144
}
145145

0 commit comments

Comments
 (0)