新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!

Commit 0e1710a0 authored by gh lu's avatar gh lu

fix: add GetStateFromKeyWithExists method and log

--bug=1004998
parent 12c3d53e
...@@ -398,6 +398,22 @@ func (mr *MockSDKInterfaceMockRecorder) GetStateFromKeyByte(key interface{}) *go ...@@ -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) 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. // GetStateWithExists mocks base method.
func (m *MockSDKInterface) GetStateWithExists(key, field string) (string, bool, error) { func (m *MockSDKInterface) GetStateWithExists(key, field string) (string, bool, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
......
...@@ -206,6 +206,10 @@ func (s *SDK) GetStateFromKey(key string) (string, error) { ...@@ -206,6 +206,10 @@ func (s *SDK) GetStateFromKey(key string) (string, error) {
return s.GetState(key, "") 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) { func (s *SDK) GetStateFromKeyByte(key string) ([]byte, error) {
return s.GetStateByte(key, "") return s.GetStateByte(key, "")
} }
......
...@@ -34,12 +34,13 @@ type SDKInterface interface { ...@@ -34,12 +34,13 @@ type SDKInterface interface {
// @param field: 获取的参数名 // @param field: 获取的参数名
// @return1: 获取结果,格式为string // @return1: 获取结果,格式为string
// @return2: 获取错误信息 // @return2: 获取错误信息
// Deprecated
GetState(key, field string) (string, error) GetState(key, field string) (string, error)
// GetStateWithExists get [key, field] from chain and db // GetStateWithExists get [key, field] from chain and db
// @param key: 获取的参数名 // @param key: 获取的参数名
// @param field: 获取的参数名 // @param field: 获取的参数名
// @return1: 获取结果,格式为string // @return1: 获取结果,格式为string
// @return2: 是否存在,bool // @return2: 是否存在,bool, 字符串长度为0不代表不存在
// @return3: 获取错误信息 // @return3: 获取错误信息
GetStateWithExists(key, field string) (string, bool, error) GetStateWithExists(key, field string) (string, bool, error)
// GetBatchState get [BatchKeys] from chain and db // GetBatchState get [BatchKeys] from chain and db
...@@ -50,17 +51,24 @@ type SDKInterface interface { ...@@ -50,17 +51,24 @@ type SDKInterface interface {
// GetStateByte get [key, field] from chain and db // GetStateByte get [key, field] from chain and db
// @param key: 获取的参数名 // @param key: 获取的参数名
// @param field: 获取的参数名 // @param field: 获取的参数名
// @return1: 获取结果,格式为[]byte // @return1: 获取结果,格式为[]byte, nil表示不存在
// @return2: 获取错误信息 // @return2: 获取错误信息
GetStateByte(key, field string) ([]byte, error) GetStateByte(key, field string) ([]byte, error)
// GetStateFromKey get [key] from chain and db // GetStateFromKey get [key] from chain and db
// @param key: 获取的参数名 // @param key: 获取的参数名
// @return1: 获取结果,格式为string // @return1: 获取结果,格式为string
// @return2: 获取错误信息 // @return2: 获取错误信息
// Deprecated
GetStateFromKey(key string) (string, error) 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 // GetStateFromKeyByte get [key] from chain and db
// @param key: 获取的参数名 // @param key: 获取的参数名
// @return1: 获取结果,格式为[]byte // @return1: 获取结果,格式为[]byte, nil表示不存在
// @return2: 获取错误信息 // @return2: 获取错误信息
GetStateFromKeyByte(key string) ([]byte, error) GetStateFromKeyByte(key string) ([]byte, error)
// PutState put [key, field, value] to chain // PutState put [key, field, value] to chain
...@@ -196,7 +204,7 @@ type SDKInterface interface { ...@@ -196,7 +204,7 @@ type SDKInterface interface {
// GetSenderAddr Get the address of the origin caller address, same with Origin() // GetSenderAddr Get the address of the origin caller address, same with Origin()
// @return1: origin caller address // @return1: origin caller address
// @return2: 获取错误信息 // @return2: 获取错误信息
//Deprecated // Deprecated
GetSenderAddr() (string, error) GetSenderAddr() (string, error)
// Sender Get the address of the sender address, if the contract is called by another contract, the result will be // 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 // the caller contract's address
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment