Skip to content

Commit

Permalink
nvm:module.go fix compatibility require bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzi committed Jun 19, 2018
1 parent ee92698 commit 1dce757
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions core/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ const (
TestNetWsResetRecordDependencyHeight uint64 = 281800

// TestNetV8JSLibVersionControlHeight
TestNetV8JSLibVersionControlHeight uint64 = 424300
TestNetV8JSLibVersionControlHeight uint64 = 424400

//TestNetTransferFromContractFailureEventRecordableHeight
TestNetTransferFromContractFailureEventRecordableHeight uint64 = 424300
TestNetTransferFromContractFailureEventRecordableHeight uint64 = 424400

//TestNetNewNvmExeTimeoutConsumeGasHeight
TestNetNewNvmExeTimeoutConsumeGasHeight uint64 = 424300
TestNetNewNvmExeTimeoutConsumeGasHeight uint64 = 424400
)

// var for TestNet
Expand Down
8 changes: 6 additions & 2 deletions nf/nvm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ func AttachLibVersionDelegateFunc(handler unsafe.Pointer, require *C.char) *C.ch
logging.VLog().WithFields(logrus.Fields{
"libname": libname,
"height": e.ctx.block.Height(),
}).Error("e.context.contract.ContractMeta is nil.")
return nil
}).Debug("e.context.contract.ContractMeta is nil.")
return attachDefaultVersionLib(libname)
}
cv := e.ctx.contract.ContractMeta().Version

Expand Down Expand Up @@ -179,6 +179,10 @@ func AttachLibVersionDelegateFunc(handler unsafe.Pointer, require *C.char) *C.ch
return C.CString(JSLibRootName + ver + libname[JSLibRootNameLen-1:])
}

return attachDefaultVersionLib(libname)
}

func attachDefaultVersionLib(libname string) *C.char {
// block created before core.V8JSLibVersionControlHeight, default lib version: 1.0.0
if !strings.HasPrefix(libname, JSLibRootName) {
if strings.HasPrefix(libname, "/") {
Expand Down

0 comments on commit 1dce757

Please sign in to comment.