Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
675bdfcd
Commit
675bdfcd
authored
Dec 14, 2021
by
harrylee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a bug for inner request index
parent
272cfa67
Pipeline
#8370
failed with stages
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
brokerdb.go
plugin/dapp/broker/executor/brokerdb.go
+18
-10
No files found.
plugin/dapp/broker/executor/brokerdb.go
View file @
675bdfcd
...
...
@@ -89,45 +89,53 @@ func (b *BrokerDB) audit(payload *brokertypes.Audit) (*types.Receipt, error) {
func
(
b
*
BrokerDB
)
updateIndex
(
payload
*
brokertypes
.
UpdateIndex
)
(
*
types
.
Receipt
,
error
)
{
//FIXME 权限检查
currentServiceID
,
err
:=
b
.
genFullServiceID
(
payload
.
DstServiceID
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"can't get current service ID!"
)
}
receipt
:=
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
}
if
payload
.
ReqType
==
brokertypes
.
Req_Inner
{
inServicePair
:=
genServicePair
(
payload
.
SrcServiceID
,
currentServiceID
)
meta
,
err
:=
getMeta
(
b
.
statedb
,
calInnerMetaKey
())
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"broker not init!"
)
}
idx
:=
meta
.
Meta
[
genServicePair
(
payload
.
SrcServiceID
,
payload
.
DstServiceID
)]
payload
.
DstServiceID
=
currentServiceID
idx
:=
meta
.
Meta
[
inServicePair
]
if
payload
.
SequenceNum
!=
idx
+
1
{
return
nil
,
fmt
.
Errorf
(
"
incorrect index, expect %d"
,
idx
+
1
)
return
nil
,
fmt
.
Errorf
(
"
Req_Inner incorrect index,key %s expect %d,but get %d"
,
inServicePair
,
idx
+
1
,
payload
.
SequenceNum
)
}
meta
.
Meta
[
genServicePair
(
payload
.
SrcServiceID
,
payload
.
DstServiceID
)
]
=
idx
+
1
meta
.
Meta
[
inServicePair
]
=
idx
+
1
kvset
:=
b
.
GetMetaKVSet
(
payload
.
ReqType
,
meta
)
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
inMsgKey
(
genServicePair
(
payload
.
SrcServiceID
,
payload
.
DstServiceID
)
,
idx
+
1
),
Value
:
types
.
Encode
(
payload
.
Response
)})
kvset
=
append
(
kvset
,
&
types
.
KeyValue
{
Key
:
inMsgKey
(
inServicePair
,
idx
+
1
),
Value
:
types
.
Encode
(
payload
.
Response
)})
receipt
.
KV
=
append
(
receipt
.
KV
,
kvset
...
)
}
else
if
payload
.
ReqType
==
brokertypes
.
Req_Callback
{
outServicePair
:=
genServicePair
(
currentServiceID
,
payload
.
GetSrcServiceID
())
meta
,
err
:=
getMeta
(
b
.
statedb
,
calCallBackMetaKey
())
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"broker not init!"
)
}
idx
:=
meta
.
Meta
[
genServicePair
(
payload
.
DstServiceID
,
payload
.
SrcServiceID
)
]
idx
:=
meta
.
Meta
[
outServicePair
]
if
payload
.
SequenceNum
!=
idx
+
1
{
return
nil
,
fmt
.
Errorf
(
"
incorrect index, expect %d"
,
idx
+
1
)
return
nil
,
fmt
.
Errorf
(
"
Req_Callback incorrect index,key %s expect %d,but get %d"
,
outServicePair
,
idx
+
1
,
payload
.
SequenceNum
)
}
meta
.
Meta
[
genServicePair
(
payload
.
DstServiceID
,
payload
.
SrcServiceID
)
]
=
idx
+
1
meta
.
Meta
[
outServicePair
]
=
idx
+
1
kvset
:=
b
.
GetMetaKVSet
(
payload
.
ReqType
,
meta
)
// 跨出交易不需要确认是否成功
receipt
.
KV
=
append
(
receipt
.
KV
,
kvset
...
)
}
else
if
payload
.
ReqType
==
brokertypes
.
Req_DstRollback
{
//todo
inServicePair
:=
genServicePair
(
payload
.
SrcServiceID
,
currentServiceID
)
meta
,
err
:=
getMeta
(
b
.
statedb
,
calDstRollBackMetaKey
())
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"broker not init!"
)
}
idx
:=
meta
.
Meta
[
genServicePair
(
payload
.
SrcServiceID
,
payload
.
DstServiceID
)
]
idx
:=
meta
.
Meta
[
inServicePair
]
if
payload
.
SequenceNum
<
idx
+
1
{
return
nil
,
fmt
.
Errorf
(
"
incorrect dstrollback index, expect %d"
,
idx
+
1
)
return
nil
,
fmt
.
Errorf
(
"
Req_DstRollback incorrect index,key %s expect %d,but get %d"
,
inServicePair
,
idx
+
1
,
payload
.
SequenceNum
)
}
meta
.
Meta
[
genServicePair
(
payload
.
SrcServiceID
,
payload
.
DstServiceID
)
]
=
payload
.
SequenceNum
meta
.
Meta
[
inServicePair
]
=
payload
.
SequenceNum
kvset
:=
b
.
GetMetaKVSet
(
payload
.
ReqType
,
meta
)
receipt
.
KV
=
append
(
receipt
.
KV
,
kvset
...
)
}
...
...
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