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
d5bbc931
Commit
d5bbc931
authored
May 14, 2021
by
Alexader
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(*): rollback ibtp index when ibtp failed on bitxhub
parent
0d6dfd49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
9 deletions
+58
-9
client.go
client.go
+50
-0
go.mod
go.mod
+8
-9
go.sum
go.sum
+0
-0
No files found.
client.go
View file @
d5bbc931
...
...
@@ -455,6 +455,56 @@ func (c *Client) CommitCallback(ibtp *pb.IBTP) error {
return
nil
}
// @ibtp is the original ibtp merged from this appchain
func
(
c
*
Client
)
RollbackIBTP
(
ibtp
*
pb
.
IBTP
,
isSrcChain
bool
)
(
*
pb
.
RollbackIBTPResponse
,
error
)
{
ret
:=
&
pb
.
RollbackIBTPResponse
{}
pd
:=
&
pb
.
Payload
{}
if
err
:=
pd
.
Unmarshal
(
ibtp
.
Payload
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"ibtp payload unmarshal: %w"
,
err
)
}
content
:=
&
pb
.
Content
{}
if
err
:=
content
.
Unmarshal
(
pd
.
Content
);
err
!=
nil
{
return
ret
,
fmt
.
Errorf
(
"ibtp content unmarshal: %w"
,
err
)
}
// only support rollback for interchainCharge
if
content
.
Func
!=
"interchainCharge"
{
return
nil
,
nil
}
callFunc
:=
CallFunc
{
Func
:
content
.
Rollback
,
Args
:
content
.
ArgsRb
,
}
bizData
,
err
:=
json
.
Marshal
(
callFunc
)
if
err
!=
nil
{
return
ret
,
err
}
// pb.IBTP_RESPONSE indicates it is to update callback counter
_
,
resp
,
err
:=
c
.
InvokeInterchain
(
ibtp
.
To
,
ibtp
.
Index
,
content
.
SrcContractId
,
pb
.
IBTP_RESPONSE
,
bizData
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"invoke interchain for ibtp %s to call %s: %w"
,
ibtp
.
ID
(),
content
.
Rollback
,
err
)
}
ret
.
Status
=
resp
.
OK
ret
.
Message
=
resp
.
Message
return
ret
,
nil
}
func
(
c
*
Client
)
IncreaseInMeta
(
original
*
pb
.
IBTP
)
(
*
pb
.
IBTP
,
error
)
{
ibtp
,
err
:=
c
.
generateCallback
(
original
,
nil
,
nil
,
false
)
if
err
!=
nil
{
return
nil
,
err
}
_
,
_
,
err
=
c
.
InvokeIndexUpdate
(
original
.
From
,
original
.
Index
,
original
.
Category
())
if
err
!=
nil
{
logger
.
Error
(
"update in meta"
,
"ibtp_id"
,
original
.
ID
(),
"error"
,
err
.
Error
())
}
return
ibtp
,
nil
}
func
(
c
*
Client
)
GetReceipt
(
ibtp
*
pb
.
IBTP
)
(
*
pb
.
IBTP
,
error
)
{
result
,
err
:=
c
.
GetInMessage
(
ibtp
.
From
,
ibtp
.
Index
)
if
err
!=
nil
{
...
...
go.mod
View file @
d5bbc931
...
...
@@ -6,25 +6,22 @@ require (
github.com/OneOfOne/xxhash v1.2.5 // indirect
github.com/Rican7/retry v0.1.0
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/meshplus/bitxid v0.0.0-20210331074321-62187b1145f5
github.com/cloudflare/cfssl v0.0.0-20190409034051-768cd563887f
github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa // indirect
github.com/ethereum/go-ethereum v1.9.18 // indirect
github.com/go-logfmt/logfmt v0.4.0 // indirect
github.com/golang/protobuf v1.4.
0
github.com/golang/protobuf v1.4.
3
github.com/google/certificate-transparency-go v1.1.0 // indirect
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd
github.com/hashicorp/go-plugin v1.3.0
github.com/hyperledger/fabric v2.0.1+incompatible
github.com/hyperledger/fabric-chaincode-go v0.0.0-20200511190512-bcfeb58dd83a
github.com/hyperledger/fabric-lib-go v1.0.0 // indirect
github.com/hyperledger/fabric-protos-go v0.0.0-20200330074707-cfe579e86986
github.com/hyperledger/fabric-sdk-go v1.0.0-alpha5
github.com/meshplus/bitxhub v1.0.0-rc2 // indirect
github.com/meshplus/bitxhub-kit v1.1.2-0.20201203072410-8a0383a6870d
github.com/meshplus/bitxhub-model v1.1.2-0.20210312014622-c3ad532b64ad
github.com/meshplus/pier v1.5.1-0.20210312103925-148435c71325
github.com/sirupsen/logrus v1.6.0
github.com/spf13/viper v1.6.1
github.com/meshplus/bitxhub-model v1.2.1-0.20210524073042-f243c2fee25b
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a
github.com/meshplus/pier v1.7.1-0.20210524093640-1337e0a53318
github.com/spf13/viper v1.7.0
sigs.k8s.io/yaml v1.2.0 // indirect
)
...
...
@@ -32,4 +29,6 @@ replace (
github.com/go-kit/kit => github.com/go-kit/kit v0.8.0
github.com/golang/protobuf => github.com/golang/protobuf v1.3.2
github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.3
google.golang.org/genproto => google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884
google.golang.org/protobuf => google.golang.org/protobuf v1.21.0
)
go.sum
View file @
d5bbc931
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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