Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar-client-fabric
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
sidecar-client-fabric
Commits
14604298
Commit
14604298
authored
Aug 12, 2021
by
zhourong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(*): handle dest rollback
parent
7bce9c1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
contracts.zip
example/contracts.zip
+0
-0
transfer.go
example/contracts/src/transfer/transfer.go
+8
-2
No files found.
example/contracts.zip
View file @
14604298
No preview for this file type
example/contracts/src/transfer/transfer.go
View file @
14604298
...
...
@@ -118,7 +118,7 @@ func (t *Transfer) transfer(stub shim.ChaincodeStubInterface, args []string) pb.
return
shim
.
Error
(
err
.
Error
())
}
args
:=
strings
.
Join
([]
string
{
sender
,
receiver
,
amountArg
},
","
)
args
:=
strings
.
Join
([]
string
{
sender
,
receiver
,
amountArg
,
"true"
},
","
)
argsRb
:=
strings
.
Join
([]
string
{
sender
,
amountArg
},
","
)
b
:=
util
.
ToChaincodeArgs
(
emitInterchainEventFunc
,
dstServiceID
,
"interchainCharge,,interchainRollback"
,
args
,
""
,
argsRb
)
response
:=
stub
.
InvokeChaincode
(
brokerContractName
,
b
,
channelID
)
...
...
@@ -173,6 +173,7 @@ func (t *Transfer) interchainCharge(stub shim.ChaincodeStubInterface, args []str
sender
:=
args
[
0
]
receiver
:=
args
[
1
]
amountArg
:=
args
[
2
]
isRollback
:=
args
[
3
]
// check for sender info
if
sender
==
""
{
...
...
@@ -189,7 +190,12 @@ func (t *Transfer) interchainCharge(stub shim.ChaincodeStubInterface, args []str
return
shim
.
Error
(
fmt
.
Errorf
(
"get balancee from %s %w"
,
receiver
,
err
)
.
Error
())
}
balance
+=
amount
// TODO: deal with rollback failure (balance not enough)
if
isRollback
==
"true"
{
balance
-=
amount
}
else
{
balance
+=
amount
}
err
=
stub
.
PutState
(
receiver
,
[]
byte
(
strconv
.
FormatUint
(
balance
,
10
)))
if
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
...
...
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