Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!
Open sidebar
白 鹿
contract-sdk-go
Commits
0e1710a0
Commit
0e1710a0
authored
Feb 07, 2023
by
gh lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add GetStateFromKeyWithExists method and log
--bug=1004998
parent
12c3d53e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
4 deletions
+32
-4
sdk/mock_sdk_interface.go
sdk/mock_sdk_interface.go
+16
-0
sdk/sdk.go
sdk/sdk.go
+4
-0
sdk/sdk_interface.go
sdk/sdk_interface.go
+12
-4
No files found.
sdk/mock_sdk_interface.go
View file @
0e1710a0
...
...
@@ -398,6 +398,22 @@ func (mr *MockSDKInterfaceMockRecorder) GetStateFromKeyByte(key interface{}) *go
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"GetStateFromKeyByte"
,
reflect
.
TypeOf
((
*
MockSDKInterface
)(
nil
)
.
GetStateFromKeyByte
),
key
)
}
// GetStateFromKeyWithExists mocks base method.
func
(
m
*
MockSDKInterface
)
GetStateFromKeyWithExists
(
key
string
)
(
string
,
bool
,
error
)
{
m
.
ctrl
.
T
.
Helper
()
ret
:=
m
.
ctrl
.
Call
(
m
,
"GetStateFromKeyWithExists"
,
key
)
ret0
,
_
:=
ret
[
0
]
.
(
string
)
ret1
,
_
:=
ret
[
1
]
.
(
bool
)
ret2
,
_
:=
ret
[
2
]
.
(
error
)
return
ret0
,
ret1
,
ret2
}
// GetStateFromKeyWithExists indicates an expected call of GetStateFromKeyWithExists.
func
(
mr
*
MockSDKInterfaceMockRecorder
)
GetStateFromKeyWithExists
(
key
interface
{})
*
gomock
.
Call
{
mr
.
mock
.
ctrl
.
T
.
Helper
()
return
mr
.
mock
.
ctrl
.
RecordCallWithMethodType
(
mr
.
mock
,
"GetStateFromKeyWithExists"
,
reflect
.
TypeOf
((
*
MockSDKInterface
)(
nil
)
.
GetStateFromKeyWithExists
),
key
)
}
// GetStateWithExists mocks base method.
func
(
m
*
MockSDKInterface
)
GetStateWithExists
(
key
,
field
string
)
(
string
,
bool
,
error
)
{
m
.
ctrl
.
T
.
Helper
()
...
...
sdk/sdk.go
View file @
0e1710a0
...
...
@@ -206,6 +206,10 @@ func (s *SDK) GetStateFromKey(key string) (string, error) {
return
s
.
GetState
(
key
,
""
)
}
func
(
s
*
SDK
)
GetStateFromKeyWithExists
(
key
string
)
(
string
,
bool
,
error
)
{
return
s
.
GetStateWithExists
(
key
,
""
)
}
func
(
s
*
SDK
)
GetStateFromKeyByte
(
key
string
)
([]
byte
,
error
)
{
return
s
.
GetStateByte
(
key
,
""
)
}
...
...
sdk/sdk_interface.go
View file @
0e1710a0
...
...
@@ -34,12 +34,13 @@ type SDKInterface interface {
// @param field: 获取的参数名
// @return1: 获取结果,格式为string
// @return2: 获取错误信息
// Deprecated
GetState
(
key
,
field
string
)
(
string
,
error
)
// GetStateWithExists get [key, field] from chain and db
// @param key: 获取的参数名
// @param field: 获取的参数名
// @return1: 获取结果,格式为string
// @return2: 是否存在,bool
// @return2: 是否存在,bool
, 字符串长度为0不代表不存在
// @return3: 获取错误信息
GetStateWithExists
(
key
,
field
string
)
(
string
,
bool
,
error
)
// GetBatchState get [BatchKeys] from chain and db
...
...
@@ -50,17 +51,24 @@ type SDKInterface interface {
// GetStateByte get [key, field] from chain and db
// @param key: 获取的参数名
// @param field: 获取的参数名
// @return1: 获取结果,格式为[]byte
// @return1: 获取结果,格式为[]byte
, nil表示不存在
// @return2: 获取错误信息
GetStateByte
(
key
,
field
string
)
([]
byte
,
error
)
// GetStateFromKey get [key] from chain and db
// @param key: 获取的参数名
// @return1: 获取结果,格式为string
// @return2: 获取错误信息
// Deprecated
GetStateFromKey
(
key
string
)
(
string
,
error
)
// GetStateFromKeyWithExists get [key] from chain and db
// @param key: 获取的参数名
// @return1: 获取结果,格式为string
// @return2: 是否存在,bool, 字符串长度为0不代表不存在
// @return3: 获取错误信息
GetStateFromKeyWithExists
(
key
string
)
(
string
,
bool
,
error
)
// GetStateFromKeyByte get [key] from chain and db
// @param key: 获取的参数名
// @return1: 获取结果,格式为[]byte
// @return1: 获取结果,格式为[]byte
, nil表示不存在
// @return2: 获取错误信息
GetStateFromKeyByte
(
key
string
)
([]
byte
,
error
)
// PutState put [key, field, value] to chain
...
...
@@ -196,7 +204,7 @@ type SDKInterface interface {
// GetSenderAddr Get the address of the origin caller address, same with Origin()
// @return1: origin caller address
// @return2: 获取错误信息
//Deprecated
//
Deprecated
GetSenderAddr
()
(
string
,
error
)
// Sender Get the address of the sender address, if the contract is called by another contract, the result will be
// the caller contract's address
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment