Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
samliok committed Dec 19, 2023
1 parent eda4b66 commit 07801df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions x/programs/examples/imports/program/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func (i *Import) Register(link runtime.Link, meter runtime.Meter, imports runtim
return nil
}

// callProgramFn makes a call to an entry function of a program in the context of another program's address.
// callProgramFn makes a call to an entry function of a program in the context of another program's ID.
func (i *Import) callProgramFn(
caller *wasmtime.Caller,
_callerAddress int64,
programAddress int64,
_callerID int64,
programID int64,
maxUnits int64,
function int64,
args int64,
Expand All @@ -80,9 +80,9 @@ func (i *Import) callProgramFn(
return -1
}

programIDBytes, err := runtime.SmartPtr(programAddress).Bytes(memory)
programIDBytes, err := runtime.SmartPtr(programID).Bytes(memory)
if err != nil {
i.log.Error("failed to read address from memory",
i.log.Error("failed to read id from memory",
zap.Error(err),
)
return -1
Expand Down Expand Up @@ -161,12 +161,12 @@ func (i *Import) callProgramFn(

// getCallArgs returns the arguments to be passed to the program being invoked from [buffer].
func getCallArgs(ctx context.Context, memory runtime.Memory, buffer []byte, programIDBytes []byte) ([]runtime.SmartPtr, error) {
// first arg contains address of program to call
invokeProgramAddressPtr, err := runtime.WriteBytes(memory, programIDBytes)
// first arg contains id of program to call
invokeProgramIDPtr, err := runtime.WriteBytes(memory, programIDBytes)
if err != nil {
return nil, err
}
argPtr, err := runtime.NewSmartPtr(uint32(invokeProgramAddressPtr), len(programIDBytes))
argPtr, err := runtime.NewSmartPtr(uint32(invokeProgramIDPtr), len(programIDBytes))
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions x/programs/examples/imports/pstate/pstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (i *Import) Register(link runtime.Link, meter runtime.Meter, _ runtime.Supp
func (i *Import) putFn(caller *wasmtime.Caller, id int64, key int64, value int64) int32 {
memory := runtime.NewMemory(runtime.NewExportClient(caller))
// memory := runtime.NewMemory(client)
programidBytes, err := runtime.SmartPtr(id).Bytes(memory)
programIDBytes, err := runtime.SmartPtr(id).Bytes(memory)
if err != nil {
i.log.Error("failed to read program id from memory",
zap.Error(err),
Expand All @@ -86,7 +86,7 @@ func (i *Import) putFn(caller *wasmtime.Caller, id int64, key int64, value int64
return -1
}

k := storage.ProgramPrefixKey(programidBytes, keyBytes)
k := storage.ProgramPrefixKey(programIDBytes, keyBytes)
err = i.mu.Insert(context.Background(), k, valueBytes)
if err != nil {
i.log.Error("failed to insert into storage",
Expand All @@ -101,7 +101,7 @@ func (i *Import) putFn(caller *wasmtime.Caller, id int64, key int64, value int64
func (i *Import) getFn(caller *wasmtime.Caller, id int64, key int64) int64 {
client := runtime.NewExportClient(caller)
memory := runtime.NewMemory(client)
programidBytes, err := runtime.SmartPtr(id).Bytes(memory)
programIDBytes, err := runtime.SmartPtr(id).Bytes(memory)
if err != nil {
i.log.Error("failed to read program id from memory",
zap.Error(err),
Expand All @@ -116,7 +116,7 @@ func (i *Import) getFn(caller *wasmtime.Caller, id int64, key int64) int64 {
)
return -1
}
k := storage.ProgramPrefixKey(programidBytes, keyBytes)
k := storage.ProgramPrefixKey(programIDBytes, keyBytes)
val, err := i.mu.GetValue(context.Background(), k)
if err != nil {
if !errors.Is(err, database.ErrNotFound) {
Expand Down

0 comments on commit 07801df

Please sign in to comment.