Skip to content

Commit

Permalink
rename the functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yun-yeo committed Oct 6, 2021
1 parent a3198f1 commit 60311bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions x/wasm/keeper/legacy_querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ func queryContractStore(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacy
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
}

wasmVM, err := k.getWasmVM(sdk.WrapSDKContext(ctx))
wasmVM, err := k.acquireWasmVM(sdk.WrapSDKContext(ctx))
if err != nil {
return nil, sdkerrors.Wrap(types.ErrContractQueryFailed, err.Error())
}

// recover from out-of-gas panic
defer func() {
k.putWasmVM(wasmVM)
k.releaseWasmVM(wasmVM)

if r := recover(); r != nil {
switch rType := r.(type) {
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/keeper/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

var n = 0

func (k Keeper) getWasmVM(ctx context.Context) (types.WasmerEngine, error) {
func (k Keeper) acquireWasmVM(ctx context.Context) (types.WasmerEngine, error) {
err := k.wasmReadVMSemaphore.Acquire(ctx, 1)
if err != nil {
return nil, err
Expand All @@ -22,7 +22,7 @@ func (k Keeper) getWasmVM(ctx context.Context) (types.WasmerEngine, error) {
return wasmVM, nil
}

func (k Keeper) putWasmVM(wasmVM types.WasmerEngine) {
func (k Keeper) releaseWasmVM(wasmVM types.WasmerEngine) {
k.wasmReadVMMutex.Lock()
k.wasmReadVMPool = append(k.wasmReadVMPool, wasmVM)
k.wasmReadVMMutex.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ func (q querier) ContractStore(c context.Context, req *types.QueryContractStoreR
return nil, status.Error(codes.InvalidArgument, err.Error())
}

wasmVM, err := q.getWasmVM(c)
wasmVM, err := q.acquireWasmVM(c)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}

// recover from out-of-gas panic
defer func() {
q.putWasmVM(wasmVM)
q.releaseWasmVM(wasmVM)

if r := recover(); r != nil {
switch rType := r.(type) {
Expand Down

0 comments on commit 60311bb

Please sign in to comment.