Skip to content

Commit

Permalink
fix mislead api name (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanZiWen authored and laizy committed Nov 22, 2018
1 parent 71daa24 commit 197c079
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions core/store/ledgerstore/ledger_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,10 +835,10 @@ func (this *LedgerStoreImp) PreExecuteContract(tx *types.Transaction) (*sstate.P
stf := &sstate.PreExecResult{State: event.CONTRACT_STATE_FAIL, Gas: neovm.MIN_TRANSACTION_GAS, Result: nil}

config := &smartcontract.Config{
Time: uint32(time.Now().Unix()),
Height: height + 1,
Tx: tx,
RandomHash: this.GetBlockHash(height),
Time: uint32(time.Now().Unix()),
Height: height + 1,
Tx: tx,
BlockHash: this.GetBlockHash(height),
}

overlay := this.stateStore.NewOverlayDB()
Expand Down
16 changes: 8 additions & 8 deletions core/store/ledgerstore/tx_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ func (self *StateStore) HandleDeployTransaction(store store.LedgerStore, overlay
if tx.GasPrice != 0 {
// init smart contract configuration info
config := &smartcontract.Config{
Time: block.Header.Timestamp,
Height: block.Header.Height,
Tx: tx,
RandomHash: block.Hash(),
Time: block.Header.Timestamp,
Height: block.Header.Height,
Tx: tx,
BlockHash: block.Hash(),
}
createGasPrice, ok := neovm.GAS_TABLE.Load(neovm.CONTRACT_CREATE_NAME)
if !ok {
Expand Down Expand Up @@ -128,10 +128,10 @@ func (self *StateStore) HandleInvokeTransaction(store store.LedgerStore, overlay

// init smart contract configuration info
config := &smartcontract.Config{
Time: block.Header.Timestamp,
Height: block.Header.Height,
Tx: tx,
RandomHash: block.Hash(),
Time: block.Header.Timestamp,
Height: block.Header.Height,
Tx: tx,
BlockHash: block.Hash(),
}

var (
Expand Down
2 changes: 1 addition & 1 deletion smartcontract/service/native/native_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type NativeService struct {
Tx *types.Transaction
Height uint32
Time uint32
RandomHash common.Uint256
BlockHash common.Uint256
ContextRef context.ContextRef
}

Expand Down
20 changes: 10 additions & 10 deletions smartcontract/service/neovm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ var (

STORAGECONTEXT_ASREADONLY_NAME = "System.StorageContext.AsReadOnly"

RUNTIME_GETTIME_NAME = "System.Runtime.GetTime"
RUNTIME_CHECKWITNESS_NAME = "System.Runtime.CheckWitness"
RUNTIME_NOTIFY_NAME = "System.Runtime.Notify"
RUNTIME_LOG_NAME = "System.Runtime.Log"
RUNTIME_GETTRIGGER_NAME = "System.Runtime.GetTrigger"
RUNTIME_SERIALIZE_NAME = "System.Runtime.Serialize"
RUNTIME_DESERIALIZE_NAME = "System.Runtime.Deserialize"
RUNTIME_BASE58TOADDRESS_NAME = "Ontology.Runtime.Base58ToAddress"
RUNTIME_ADDRESSTOBASE58_NAME = "Ontology.Runtime.AddressToBase58"
RUNTIME_GETRANDOMHASH_NAME = "Ontology.Runtime.GetRandomHash"
RUNTIME_GETTIME_NAME = "System.Runtime.GetTime"
RUNTIME_CHECKWITNESS_NAME = "System.Runtime.CheckWitness"
RUNTIME_NOTIFY_NAME = "System.Runtime.Notify"
RUNTIME_LOG_NAME = "System.Runtime.Log"
RUNTIME_GETTRIGGER_NAME = "System.Runtime.GetTrigger"
RUNTIME_SERIALIZE_NAME = "System.Runtime.Serialize"
RUNTIME_DESERIALIZE_NAME = "System.Runtime.Deserialize"
RUNTIME_BASE58TOADDRESS_NAME = "Ontology.Runtime.Base58ToAddress"
RUNTIME_ADDRESSTOBASE58_NAME = "Ontology.Runtime.AddressToBase58"
RUNTIME_GETCURRENTBLOCKHASH_NAME = "Ontology.Runtime.GetCurrentBlockHash"

NATIVE_INVOKE_NAME = "Ontology.Native.Invoke"

Expand Down
8 changes: 4 additions & 4 deletions smartcontract/service/neovm/neovm_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ var (
GETCALLINGSCRIPTHASH_NAME: {Execute: GetCallingAddress},
GETENTRYSCRIPTHASH_NAME: {Execute: GetEntryAddress},

RUNTIME_BASE58TOADDRESS_NAME: {Execute: RuntimeBase58ToAddress},
RUNTIME_ADDRESSTOBASE58_NAME: {Execute: RuntimeAddressToBase58},
RUNTIME_GETRANDOMHASH_NAME: {Execute: RuntimeGetRandomHash},
RUNTIME_BASE58TOADDRESS_NAME: {Execute: RuntimeBase58ToAddress},
RUNTIME_ADDRESSTOBASE58_NAME: {Execute: RuntimeAddressToBase58},
RUNTIME_GETCURRENTBLOCKHASH_NAME: {Execute: RuntimeGetCurrentBlockHash},
}
)

Expand Down Expand Up @@ -125,7 +125,7 @@ type NeoVmService struct {
Tx *types.Transaction
Time uint32
Height uint32
RandomHash scommon.Uint256
BlockHash scommon.Uint256
Engine *vm.ExecutionEngine
PreExec bool
}
Expand Down
4 changes: 2 additions & 2 deletions smartcontract/service/neovm/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ func RuntimeAddressToBase58(service *NeoVmService, engine *vm.ExecutionEngine) e
return nil
}

func RuntimeGetRandomHash(service *NeoVmService, engine *vm.ExecutionEngine) error {
vm.PushData(engine, service.RandomHash.ToArray())
func RuntimeGetCurrentBlockHash(service *NeoVmService, engine *vm.ExecutionEngine) error {
vm.PushData(engine, service.BlockHash.ToArray())
return nil
}

Expand Down
12 changes: 6 additions & 6 deletions smartcontract/smart_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ type SmartContract struct {

// Config describe smart contract need parameters configuration
type Config struct {
Time uint32 // current block timestamp
Height uint32 // current block height
RandomHash common.Uint256 // current block hash
Tx *ctypes.Transaction // current transaction
Time uint32 // current block timestamp
Height uint32 // current block height
BlockHash common.Uint256 // current block hash
Tx *ctypes.Transaction // current transaction
}

// PushContext push current context to smart contract
Expand Down Expand Up @@ -134,7 +134,7 @@ func (this *SmartContract) NewExecuteEngine(code []byte) (context.Engine, error)
Tx: this.Config.Tx,
Time: this.Config.Time,
Height: this.Config.Height,
RandomHash: this.Config.RandomHash,
BlockHash: this.Config.BlockHash,
Engine: vm.NewExecutionEngine(),
PreExec: this.PreExec,
}
Expand All @@ -151,7 +151,7 @@ func (this *SmartContract) NewNativeService() (*native.NativeService, error) {
Tx: this.Config.Tx,
Time: this.Config.Time,
Height: this.Config.Height,
RandomHash: this.Config.RandomHash,
BlockHash: this.Config.BlockHash,
ServiceMap: make(map[string]native.Handler),
}
return service, nil
Expand Down

0 comments on commit 197c079

Please sign in to comment.