Skip to content

Commit

Permalink
Merge pull request ethereum#4 from CortexFoundation/ucwong
Browse files Browse the repository at this point in the history
pay for the model if exist
  • Loading branch information
ucwong authored May 24, 2018
2 parents 53c14ec + 7d011b5 commit 90fd2a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
contract.UseGas(contract.Gas)
}
}

if evm.interpreter.IsModelMeta(ret) {
//only if model is exist from ipfs, swarm or libtorrent ext, load model to memory
//todo if ret is model meta, pay some fee to model owner depends on set in meta data
// if exist
//evm.Transfer(evm.StateDB, caller.Address(), model.Owner,model.Fee)
}
return ret, contract.Gas, err
}

Expand Down
8 changes: 4 additions & 4 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack
return nil
}

func isModelMeta(code []byte) bool {
func IsModelMeta(code []byte) bool {
for i := 0; i < 8; i++ {
if code[i] != 0 {
return false
Expand All @@ -106,7 +106,7 @@ func isModelMeta(code []byte) bool {
return true
}

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

if isModelMeta(contract.Code) {
if IsModelMeta(contract.Code) {
return contract.Code, nil
}

if isInputMeta(contract.Code) {
if IsInputMeta(contract.Code) {
return contract.Code, nil
}

Expand Down

0 comments on commit 90fd2a2

Please sign in to comment.