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
d359a25a
Unverified
Commit
d359a25a
authored
Aug 23, 2021
by
Sandy Zhou
Committed by
GitHub
Aug 23, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #37 from meshplus/feat/handle-ibtp-2.0
Feat/handle ibtp 2.0
parents
4e3c0b70
bb0db4ee
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
615 additions
and
293 deletions
+615
-293
build.yml
.github/workflows/build.yml
+24
-24
.gitignore
.gitignore
+3
-3
client.go
client.go
+203
-90
config.go
config.go
+32
-17
fabric.toml
config/fabric.toml
+13
-2
event.go
event.go
+25
-30
contracts.zip
example/contracts.zip
+0
-0
broker.go
example/contracts/src/broker/broker.go
+141
-60
go.mod
example/contracts/src/broker/go.mod
+23
-0
helper.go
example/contracts/src/broker/helper.go
+1
-22
meta.go
example/contracts/src/broker/meta.go
+22
-8
data_swapper.go
example/contracts/src/data_swapper/data_swapper.go
+2
-2
go.mod
example/contracts/src/data_swapper/go.mod
+23
-0
go.mod
example/contracts/src/transfer/go.mod
+23
-0
transfer.go
example/contracts/src/transfer/transfer.go
+11
-6
go.mod
go.mod
+5
-9
go.sum
go.sum
+47
-0
receipt.go
receipt.go
+17
-20
No files found.
.github/workflows/build.yml
View file @
d359a25a
...
...
@@ -26,30 +26,30 @@ jobs:
uses
:
creekorful/goreportcard-action@v1.0
test
:
name
:
Run unittest
runs-on
:
ubuntu-latest
steps
:
-
name
:
Set up Go
uses
:
actions/setup-go@v1
with
:
go-version
:
1.13
-
name
:
Check out code
uses
:
actions/checkout@v1
-
name
:
Run Unit tests.
run
:
|
git clone https://github.com/meshplus/pier.git ../pier
export PATH=$PATH:$(go env GOPATH)/bin
make prepare
make test-coverage
# - name: Upload Coverage report to CodeCov
# uses: codecov/codecov-action@v1.0.0
# with:
# token: ${{secrets.CODECOV_TOKEN}}
#file: ./coverage.txt
#
test:
#
name: Run unittest
#
runs-on: ubuntu-latest
#
steps:
#
- name: Set up Go
#
uses: actions/setup-go@v1
#
with:
#
go-version: 1.13
#
#
- name: Check out code
#
uses: actions/checkout@v1
#
#
- name: Run Unit tests.
#
run: |
#
git clone https://github.com/meshplus/pier.git ../pier
#
export PATH=$PATH:$(go env GOPATH)/bin
#
make prepare
#
make test-coverage
#
#
# - name: Upload Coverage report to CodeCov
#
# uses: codecov/codecov-action@v1.0.0
#
# with:
#
# token: ${{secrets.CODECOV_TOKEN}}
#
#file: ./coverage.txt
build
:
name
:
Build project
...
...
.gitignore
View file @
d359a25a
...
...
@@ -8,6 +8,6 @@ bin
cover.out
cover.html
coverage.txt
/
example/contracts/src/broker/vendor/
/
example/contracts/src/data_swapper/vendor/
/
example/contracts/src/transfer/vendor/
example/contracts/src/broker/vendor/
example/contracts/src/data_swapper/vendor/
example/contracts/src/transfer/vendor/
client.go
View file @
d359a25a
...
...
@@ -21,7 +21,6 @@ import (
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
"github.com/hyperledger/fabric/common/util"
"github.com/meshplus/bitxhub-model/pb"
"github.com/meshplus/bitxid"
"github.com/meshplus/pier/pkg/plugins"
)
...
...
@@ -36,9 +35,11 @@ var (
var
_
plugins
.
Client
=
(
*
Client
)(
nil
)
const
(
GetInnerMetaMethod
=
"getInnerMeta"
// get last index of each source chain executing tx
GetOutMetaMethod
=
"getOuterMeta"
// get last index of each receiving chain crosschain event
GetCallbackMetaMethod
=
"getCallbackMeta"
// get last index of each receiving chain callback tx
GetInnerMetaMethod
=
"getInnerMeta"
// get last index of each source chain executing tx
GetOutMetaMethod
=
"getOuterMeta"
// get last index of each receiving chain crosschain event
GetCallbackMetaMethod
=
"getCallbackMeta"
// get last index of each receiving chain callback tx
GetDstRollbackMeta
=
"getDstRollbackMeta"
// get last index of each receiving chain dst roll back tx
GetChainId
=
"getChainId"
GetInMessageMethod
=
"getInMessage"
GetOutMessageMethod
=
"getOutMessage"
PollingEventMethod
=
"pollingEvent"
...
...
@@ -56,14 +57,16 @@ type ContractMeta struct {
}
type
Client
struct
{
meta
*
ContractMeta
consumer
*
Consumer
eventC
chan
*
pb
.
IBTP
appchainID
string
name
string
outMeta
map
[
string
]
uint64
ticker
*
time
.
Ticker
done
chan
bool
meta
*
ContractMeta
consumer
*
Consumer
eventC
chan
*
pb
.
IBTP
appchainID
string
name
string
serviceMeta
map
[
string
]
*
pb
.
Interchain
ticker
*
time
.
Ticker
done
chan
bool
timeoutHeight
int64
config
*
Config
}
type
CallFunc
struct
{
...
...
@@ -73,11 +76,11 @@ type CallFunc struct {
func
(
c
*
Client
)
Initialize
(
configPath
,
appchainID
string
,
extra
[]
byte
)
error
{
eventC
:=
make
(
chan
*
pb
.
IBTP
)
fabricC
onfig
,
err
:=
UnmarshalConfig
(
configPath
)
c
onfig
,
err
:=
UnmarshalConfig
(
configPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"unmarshal config for plugin :%w"
,
err
)
}
fabricConfig
:=
config
.
Fabric
contractmeta
:=
&
ContractMeta
{
EventFilter
:
fabricConfig
.
EventFilter
,
Username
:
fabricConfig
.
Username
,
...
...
@@ -86,12 +89,12 @@ func (c *Client) Initialize(configPath, appchainID string, extra []byte) error {
ORG
:
fabricConfig
.
Org
,
}
m
:=
make
(
map
[
string
]
uint64
)
m
:=
make
(
map
[
string
]
*
pb
.
Interchain
)
if
err
:=
json
.
Unmarshal
(
extra
,
&
m
);
err
!=
nil
{
return
fmt
.
Errorf
(
"unmarshal extra for plugin :%w"
,
err
)
}
if
m
==
nil
{
m
=
make
(
map
[
string
]
uint64
)
m
=
make
(
map
[
string
]
*
pb
.
Interchain
)
}
mgh
,
err
:=
newFabricHandler
(
contractmeta
.
EventFilter
,
eventC
,
appchainID
)
...
...
@@ -110,10 +113,11 @@ func (c *Client) Initialize(configPath, appchainID string, extra []byte) error {
c
.
meta
=
contractmeta
c
.
appchainID
=
appchainID
c
.
name
=
fabricConfig
.
Name
c
.
out
Meta
=
m
c
.
service
Meta
=
m
c
.
ticker
=
time
.
NewTicker
(
2
*
time
.
Second
)
c
.
done
=
done
c
.
timeoutHeight
=
fabricConfig
.
TimeoutHeight
c
.
config
=
config
return
nil
}
...
...
@@ -128,44 +132,44 @@ func (c *Client) polling() {
for
{
select
{
case
<-
c
.
ticker
.
C
:
args
,
err
:=
json
.
Marshal
(
c
.
outMeta
)
if
err
!=
nil
{
logger
.
Error
(
"Marshal outMeta of plugin"
,
"error"
,
err
.
Error
())
continue
}
request
:=
channel
.
Request
{
ChaincodeID
:
c
.
meta
.
CCID
,
Fcn
:
PollingEventMethod
,
Args
:
[][]
byte
{
args
},
}
var
response
channel
.
Response
response
,
err
=
c
.
consumer
.
ChannelClient
.
Execute
(
request
)
if
err
!=
nil
{
logger
.
Error
(
"Polling events from contract"
,
"error"
,
err
.
Error
())
continue
}
if
response
.
Payload
==
nil
{
continue
}
proof
,
err
:=
c
.
getProof
(
response
)
outMeta
,
err
:=
c
.
GetOutMeta
()
if
err
!=
nil
{
continue
}
for
servicePair
,
index
:=
range
outMeta
{
srcChainServiceID
,
dstChainServiceID
,
err
:=
parseServicePair
(
servicePair
)
if
err
!=
nil
{
logger
.
Error
(
"Polling out invalid service pair"
,
"servicePair"
,
servicePair
,
"index"
,
index
,
"error"
,
err
.
Error
())
continue
}
meta
,
ok
:=
c
.
serviceMeta
[
srcChainServiceID
]
if
!
ok
{
meta
=
&
pb
.
Interchain
{
ID
:
srcChainServiceID
,
InterchainCounter
:
make
(
map
[
string
]
uint64
),
ReceiptCounter
:
make
(
map
[
string
]
uint64
),
SourceInterchainCounter
:
make
(
map
[
string
]
uint64
),
SourceReceiptCounter
:
make
(
map
[
string
]
uint64
),
}
c
.
serviceMeta
[
srcChainServiceID
]
=
meta
}
evs
:=
make
([]
*
Event
,
0
)
if
err
:=
json
.
Unmarshal
(
response
.
Payload
,
&
evs
);
err
!=
nil
{
logger
.
Error
(
"Unmarshal response payload"
,
"error"
,
err
.
Error
())
continue
}
for
_
,
ev
:=
range
evs
{
ev
.
Proof
=
proof
c
.
eventC
<-
ev
.
Convert2IBTP
(
c
.
appchainID
,
pb
.
IBTP_INTERCHAIN
)
if
c
.
outMeta
==
nil
{
c
.
outMeta
=
make
(
map
[
string
]
uint64
)
for
i
:=
meta
.
InterchainCounter
[
dstChainServiceID
]
+
1
;
i
<=
index
;
i
++
{
ibtp
,
err
:=
c
.
GetOutMessage
(
servicePair
,
i
)
if
err
!=
nil
{
logger
.
Error
(
"Polling out message"
,
"servicePair"
,
servicePair
,
"index"
,
i
,
"error"
,
err
.
Error
())
continue
}
c
.
eventC
<-
ibtp
meta
.
InterchainCounter
[
dstChainServiceID
]
++
}
c
.
outMeta
[
string
(
bitxid
.
DID
(
ev
.
DstContractDID
)
.
GetChainDID
())]
++
}
case
<-
c
.
done
:
logger
.
Info
(
"Stop long polling"
)
...
...
@@ -234,11 +238,12 @@ func (c *Client) GetIBTP() chan *pb.IBTP {
}
func
(
c
*
Client
)
SubmitIBTP
(
ibtp
*
pb
.
IBTP
)
(
*
pb
.
SubmitIBTPResponse
,
error
)
{
pd
:=
&
pb
.
Payload
{}
ret
:=
&
pb
.
SubmitIBTPResponse
{}
pd
:=
&
pb
.
Payload
{}
if
err
:=
pd
.
Unmarshal
(
ibtp
.
Payload
);
err
!=
nil
{
return
ret
,
fmt
.
Errorf
(
"ibtp payload unmarshal: %w"
,
err
)
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
)
...
...
@@ -248,20 +253,35 @@ func (c *Client) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
return
nil
,
fmt
.
Errorf
(
"invalid ibtp category"
)
}
logger
.
Info
(
"submit ibtp"
,
"id"
,
ibtp
.
ID
(),
"contract"
,
content
.
DstContractId
,
"func"
,
content
.
Func
)
for
i
,
arg
:=
range
content
.
Args
{
logger
.
Info
(
"arg"
,
strconv
.
Itoa
(
i
),
string
(
arg
))
var
(
err
error
serviceID
string
srcChainServiceID
string
)
if
ibtp
.
Category
()
==
pb
.
IBTP_REQUEST
{
srcChainServiceID
=
ibtp
.
From
_
,
_
,
serviceID
,
err
=
parseChainServiceID
(
ibtp
.
To
)
}
else
{
srcChainServiceID
=
ibtp
.
To
_
,
_
,
serviceID
,
err
=
parseChainServiceID
(
ibtp
.
From
)
}
if
ibtp
.
Category
()
==
pb
.
IBTP_RESPONSE
&&
content
.
Func
==
""
{
if
ibtp
.
Category
()
==
pb
.
IBTP_RESPONSE
&&
content
.
Func
==
""
||
ibtp
.
Type
==
pb
.
IBTP_ROLLBACK
{
logger
.
Info
(
"InvokeIndexUpdate"
,
"ibtp"
,
ibtp
.
ID
())
_
,
resp
,
err
:=
c
.
InvokeIndexUpdate
(
ibtp
.
From
,
ibtp
.
Index
,
ibtp
.
Category
())
_
,
resp
,
err
:=
c
.
InvokeIndexUpdate
(
srcChainServiceID
,
ibtp
.
Index
,
serviceID
,
ibtp
.
Category
())
if
err
!=
nil
{
return
nil
,
err
}
ret
.
Status
=
resp
.
OK
ret
.
Message
=
resp
.
Message
if
ibtp
.
Type
==
pb
.
IBTP_ROLLBACK
{
ret
.
Result
,
err
=
c
.
generateCallback
(
ibtp
,
nil
,
ret
.
Status
)
if
err
!=
nil
{
return
nil
,
err
}
}
return
ret
,
nil
}
...
...
@@ -276,13 +296,13 @@ func (c *Client) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
ret
.
Status
=
false
ret
.
Message
=
fmt
.
Sprintf
(
"marshal ibtp %s func %s and args: %s"
,
ibtp
.
ID
(),
callFunc
.
Func
,
err
.
Error
())
res
,
_
,
err
:=
c
.
InvokeIndexUpdate
(
ibtp
.
From
,
ibtp
.
Index
,
ibtp
.
Category
())
res
,
_
,
err
:=
c
.
InvokeIndexUpdate
(
srcChainServiceID
,
ibtp
.
Index
,
serviceID
,
ibtp
.
Category
())
if
err
!=
nil
{
return
nil
,
err
}
chResp
=
res
}
else
{
res
,
resp
,
err
:=
c
.
InvokeInterchain
(
ibtp
.
From
,
ibtp
.
Index
,
content
.
DstContractId
,
ibtp
.
Category
(
),
bizData
)
res
,
resp
,
err
:=
c
.
InvokeInterchain
(
srcChainServiceID
,
ibtp
.
Index
,
serviceID
,
uint64
(
ibtp
.
Category
()
),
bizData
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"invoke interchain for ibtp %s to call %s: %w"
,
ibtp
.
ID
(),
content
.
Func
,
err
)
}
...
...
@@ -305,20 +325,18 @@ func (c *Client) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
return
ret
,
err
}
ret
.
Result
,
err
=
c
.
generateCallback
(
ibtp
,
result
,
proof
,
ret
.
Status
)
ret
.
Result
,
err
=
c
.
generateCallback
(
ibtp
,
result
,
ret
.
Status
)
if
err
!=
nil
{
return
nil
,
err
}
ret
.
Result
.
Proof
=
proof
return
ret
,
nil
}
func
(
c
*
Client
)
InvokeInterchain
(
from
string
,
index
uint64
,
destAddr
string
,
category
pb
.
IBTP_Category
,
bizCallData
[]
byte
)
(
*
channel
.
Response
,
*
Response
,
error
)
{
req
:=
"true"
if
category
==
pb
.
IBTP_RESPONSE
{
req
=
"false"
}
args
:=
util
.
ToChaincodeArgs
(
from
,
strconv
.
FormatUint
(
index
,
10
),
destAddr
,
req
)
func
(
c
*
Client
)
InvokeInterchain
(
from
string
,
index
uint64
,
destAddr
string
,
reqType
uint64
,
bizCallData
[]
byte
)
(
*
channel
.
Response
,
*
Response
,
error
)
{
args
:=
util
.
ToChaincodeArgs
(
from
,
strconv
.
FormatUint
(
index
,
10
),
destAddr
,
strconv
.
FormatUint
(
reqType
,
10
))
args
=
append
(
args
,
bizCallData
)
request
:=
channel
.
Request
{
ChaincodeID
:
c
.
meta
.
CCID
,
...
...
@@ -358,8 +376,8 @@ func (c *Client) InvokeInterchain(from string, index uint64, destAddr string, ca
return
&
res
,
response
,
nil
}
func
(
c
*
Client
)
GetOutMessage
(
to
string
,
idx
uint64
)
(
*
pb
.
IBTP
,
error
)
{
args
:=
util
.
ToChaincodeArgs
(
to
,
strconv
.
FormatUint
(
idx
,
10
))
func
(
c
*
Client
)
GetOutMessage
(
servicePair
string
,
idx
uint64
)
(
*
pb
.
IBTP
,
error
)
{
args
:=
util
.
ToChaincodeArgs
(
servicePair
,
strconv
.
FormatUint
(
idx
,
10
))
request
:=
channel
.
Request
{
ChaincodeID
:
c
.
meta
.
CCID
,
Fcn
:
GetOutMessageMethod
,
...
...
@@ -379,11 +397,11 @@ func (c *Client) GetOutMessage(to string, idx uint64) (*pb.IBTP, error) {
return
c
.
unpackIBTP
(
&
response
,
pb
.
IBTP_INTERCHAIN
,
proof
)
}
func
(
c
*
Client
)
GetInMessage
(
from
string
,
index
uint64
)
([][]
byte
,
error
)
{
func
(
c
*
Client
)
GetInMessage
(
servicePair
string
,
index
uint64
)
([][]
byte
,
error
)
{
request
:=
channel
.
Request
{
ChaincodeID
:
c
.
meta
.
CCID
,
Fcn
:
GetInMessageMethod
,
Args
:
util
.
ToChaincodeArgs
(
from
,
strconv
.
FormatUint
(
index
,
10
)),
Args
:
util
.
ToChaincodeArgs
(
servicePair
,
strconv
.
FormatUint
(
index
,
10
)),
}
var
response
channel
.
Response
...
...
@@ -457,7 +475,7 @@ func (c *Client) CommitCallback(ibtp *pb.IBTP) error {
// @ibtp is the original ibtp merged from this appchain
func
(
c
*
Client
)
RollbackIBTP
(
ibtp
*
pb
.
IBTP
,
isSrcChain
bool
)
(
*
pb
.
RollbackIBTPResponse
,
error
)
{
ret
:=
&
pb
.
RollbackIBTPResponse
{}
ret
:=
&
pb
.
RollbackIBTPResponse
{
Status
:
true
}
pd
:=
&
pb
.
Payload
{}
if
err
:=
pd
.
Unmarshal
(
ibtp
.
Payload
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"ibtp payload unmarshal: %w"
,
err
)
...
...
@@ -467,22 +485,47 @@ func (c *Client) RollbackIBTP(ibtp *pb.IBTP, isSrcChain bool) (*pb.RollbackIBTPR
return
ret
,
fmt
.
Errorf
(
"ibtp content unmarshal: %w"
,
err
)
}
// only support rollback for interchainCharge
if
content
.
Func
!=
"interchainCharge"
{
if
content
.
Rollback
==
""
{
logger
.
Info
(
"rollback function is empty, ignore it"
,
"func"
,
content
.
Func
,
"callback"
,
content
.
Callback
,
"rollback"
,
content
.
Rollback
)
return
nil
,
nil
}
var
(
bizData
[]
byte
err
error
serviceID
string
srcChainServiceID
string
rollbackFunc
string
rollbackArgs
[][]
byte
reqType
uint64
)
if
isSrcChain
{
rollbackFunc
=
content
.
Rollback
rollbackArgs
=
content
.
ArgsRb
srcChainServiceID
=
ibtp
.
To
_
,
_
,
serviceID
,
err
=
parseChainServiceID
(
ibtp
.
From
)
reqType
=
1
}
else
{
rollbackFunc
=
content
.
Func
rollbackArgs
=
content
.
Args
rollbackArgs
[
len
(
rollbackArgs
)
-
1
]
=
[]
byte
(
"true"
)
srcChainServiceID
=
ibtp
.
From
_
,
_
,
serviceID
,
err
=
parseChainServiceID
(
ibtp
.
To
)
reqType
=
2
}
callFunc
:=
CallFunc
{
Func
:
content
.
Rollback
,
Args
:
content
.
ArgsRb
,
Func
:
rollbackFunc
,
Args
:
rollbackArgs
,
}
bizData
,
err
:
=
json
.
Marshal
(
callFunc
)
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
)
_
,
resp
,
err
:=
c
.
InvokeInterchain
(
srcChainServiceID
,
ibtp
.
Index
,
serviceID
,
reqType
,
bizData
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"invoke interchain for ibtp %s to call %s: %w"
,
ibtp
.
ID
(),
content
.
Rollback
,
err
)
}
...
...
@@ -494,11 +537,15 @@ func (c *Client) RollbackIBTP(ibtp *pb.IBTP, isSrcChain bool) (*pb.RollbackIBTPR
}
func
(
c
*
Client
)
IncreaseInMeta
(
original
*
pb
.
IBTP
)
(
*
pb
.
IBTP
,
error
)
{
ibtp
,
err
:=
c
.
generateCallback
(
original
,
nil
,
nil
,
false
)
ibtp
,
err
:=
c
.
generateCallback
(
original
,
nil
,
false
)
if
err
!=
nil
{
return
nil
,
err
}
_
,
_
,
err
=
c
.
InvokeIndexUpdate
(
original
.
From
,
original
.
Index
,
original
.
Category
())
_
,
_
,
serviceID
,
err
:=
parseChainServiceID
(
ibtp
.
To
)
if
err
!=
nil
{
return
nil
,
err
}
_
,
_
,
err
=
c
.
InvokeIndexUpdate
(
original
.
From
,
original
.
Index
,
serviceID
,
original
.
Category
())
if
err
!=
nil
{
logger
.
Error
(
"update in meta"
,
"ibtp_id"
,
original
.
ID
(),
"error"
,
err
.
Error
())
}
...
...
@@ -506,7 +553,7 @@ func (c *Client) IncreaseInMeta(original *pb.IBTP) (*pb.IBTP, error) {
}
func
(
c
*
Client
)
GetReceipt
(
ibtp
*
pb
.
IBTP
)
(
*
pb
.
IBTP
,
error
)
{
result
,
err
:=
c
.
GetInMessage
(
ibtp
.
From
,
ibtp
.
Index
)
result
,
err
:=
c
.
GetInMessage
(
ibtp
.
ServicePair
()
,
ibtp
.
Index
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -515,15 +562,12 @@ func (c *Client) GetReceipt(ibtp *pb.IBTP) (*pb.IBTP, error) {
if
err
!=
nil
{
return
nil
,
err
}
return
c
.
generateCallback
(
ibtp
,
result
[
1
:
],
nil
,
status
)
return
c
.
generateCallback
(
ibtp
,
result
[
1
:
],
status
)
}
func
(
c
Client
)
InvokeIndexUpdate
(
from
string
,
index
uint64
,
category
pb
.
IBTP_Category
)
(
*
channel
.
Response
,
*
Response
,
error
)
{
req
:=
"true"
if
category
==
pb
.
IBTP_RESPONSE
{
req
=
"false"
}
args
:=
util
.
ToChaincodeArgs
(
from
,
strconv
.
FormatUint
(
index
,
10
),
req
)
func
(
c
*
Client
)
InvokeIndexUpdate
(
from
string
,
index
uint64
,
serviceId
string
,
category
pb
.
IBTP_Category
)
(
*
channel
.
Response
,
*
Response
,
error
)
{
reqType
:=
strconv
.
FormatUint
(
uint64
(
category
),
10
)
args
:=
util
.
ToChaincodeArgs
(
from
,
strconv
.
FormatUint
(
index
,
10
),
serviceId
,
reqType
)
request
:=
channel
.
Request
{
ChaincodeID
:
c
.
meta
.
CCID
,
Fcn
:
InvokeIndexUpdateMethod
,
...
...
@@ -543,13 +587,60 @@ func (c Client) InvokeIndexUpdate(from string, index uint64, category pb.IBTP_Ca
return
&
res
,
response
,
nil
}
func
(
c
*
Client
)
GetSrcRollbackMeta
()
(
map
[
string
]
uint64
,
error
)
{
panic
(
"implement me"
)
}
func
(
c
*
Client
)
GetDstRollbackMeta
()
(
map
[
string
]
uint64
,
error
)
{
request
:=
channel
.
Request
{
ChaincodeID
:
c
.
meta
.
CCID
,
Fcn
:
GetDstRollbackMeta
,
}
var
response
channel
.
Response
response
,
err
:=
c
.
consumer
.
ChannelClient
.
Execute
(
request
)
if
err
!=
nil
{
return
nil
,
err
}
return
c
.
unpackMap
(
response
)
}
func
(
c
*
Client
)
GetServices
()
[]
string
{
var
services
[]
string
for
_
,
service
:=
range
c
.
config
.
Services
{
services
=
append
(
services
,
service
.
ID
)
}
return
services
}
func
(
c
*
Client
)
GetChainID
()
(
string
,
string
)
{
request
:=
channel
.
Request
{
ChaincodeID
:
c
.
meta
.
CCID
,
Fcn
:
GetChainId
,
}
response
,
err
:=
c
.
consumer
.
ChannelClient
.
Execute
(
request
)
if
err
!=
nil
||
response
.
Payload
==
nil
{
return
""
,
""
}
chainIds
:=
strings
.
Split
(
string
(
response
.
Payload
),
"-"
)
if
len
(
chainIds
)
!=
2
{
return
""
,
""
}
return
chainIds
[
0
],
chainIds
[
1
]
}
func
(
c
*
Client
)
unpackIBTP
(
response
*
channel
.
Response
,
ibtpType
pb
.
IBTP_Type
,
proof
[]
byte
)
(
*
pb
.
IBTP
,
error
)
{
ret
:=
&
Event
{}
if
err
:=
json
.
Unmarshal
(
response
.
Payload
,
ret
);
err
!=
nil
{
return
nil
,
err
}
ret
.
Proof
=
proof
return
ret
.
Convert2IBTP
(
c
.
appchainID
,
ibtpType
),
nil
ibtp
:=
ret
.
Convert2IBTP
(
c
.
timeoutHeight
,
ibtpType
)
ibtp
.
Proof
=
proof
return
ibtp
,
nil
}
func
(
c
*
Client
)
unpackMap
(
response
channel
.
Response
)
(
map
[
string
]
uint64
,
error
)
{
...
...
@@ -602,3 +693,25 @@ func main() {
logger
.
Info
(
"Plugin server down"
)
}
func
parseChainServiceID
(
id
string
)
(
string
,
string
,
string
,
error
)
{
splits
:=
strings
.
Split
(
id
,
":"
)
if
len
(
splits
)
!=
3
{
return
""
,
""
,
""
,
fmt
.
Errorf
(
"invalid chain service ID: %s"
,
id
)
}
return
splits
[
0
],
splits
[
1
],
splits
[
2
],
nil
}
func
parseServicePair
(
servicePair
string
)
(
string
,
string
,
error
)
{
splits
:=
strings
.
Split
(
servicePair
,
"-"
)
if
len
(
splits
)
!=
2
{
return
""
,
""
,
fmt
.
Errorf
(
"invalid service pair: %s"
,
servicePair
)
}
return
splits
[
0
],
splits
[
1
],
nil
}
func
genServicePair
(
from
,
to
string
)
string
{
return
fmt
.
Sprintf
(
"%s-%s"
,
from
,
to
)
}
config.go
View file @
d359a25a
...
...
@@ -11,29 +11,44 @@ const (
ConfigName
=
"fabric.toml"
)
type
Config
struct
{
Fabric
Fabric
`toml:"fabric" json:"fabric"`
Services
[]
Service
`mapstructure:"services" json:"services"`
}
type
Fabric
struct
{
Addr
string
`toml:"addr" json:"addr"`
Name
string
`toml:"name" json:"name"`
EventFilter
string
`mapstructure:"event_filter" toml:"event_filter" json:"event_filter"`
Username
string
`toml:"username" json:"username"`
CCID
string
`toml:"ccid" json:"ccid"`
ChannelId
string
`mapstructure:"channel_id" toml:"channel_id" json:"channel_id"`
Org
string
`toml:"org" json:"org"`
Addr
string
`toml:"addr" json:"addr"`
Name
string
`toml:"name" json:"name"`
EventFilter
string
`mapstructure:"event_filter" toml:"event_filter" json:"event_filter"`
Username
string
`toml:"username" json:"username"`
CCID
string
`toml:"ccid" json:"ccid"`
ChannelId
string
`mapstructure:"channel_id" toml:"channel_id" json:"channel_id"`
Org
string
`toml:"org" json:"org"`
TimeoutHeight
int64
`mapstructure:"timeout_height" json:"timeout_height"`
ChainID
string
`mapstructure:"chain_id" json:"chain_id"`
}
type
Service
struct
{
ID
string
`toml:"id" json:"id"`
Name
string
`toml:"name" json:"name"`
Type
string
`toml:"type" json:"type"`
}
func
DefaultConfig
()
*
Fabric
{
return
&
Fabric
{
Addr
:
"40.125.164.122:10053"
,
Name
:
"fabric"
,
EventFilter
:
"CrosschainEventName"
,
Username
:
"Admin"
,
CCID
:
"Broker-001"
,
ChannelId
:
"mychannel"
,
Org
:
"org2"
,
func
DefaultConfig
()
*
Config
{
return
&
Config
{
Fabric
:
Fabric
{
Addr
:
"40.125.164.122:10053"
,
Name
:
"fabric"
,
EventFilter
:
"CrosschainEventName"
,
Username
:
"Admin"
,
CCID
:
"Broker-001"
,
ChannelId
:
"mychannel"
,
Org
:
"org2"
,
},
Services
:
nil
,
}
}
func
UnmarshalConfig
(
configPath
string
)
(
*
Fabric
,
error
)
{
func
UnmarshalConfig
(
configPath
string
)
(
*
Config
,
error
)
{
viper
.
SetConfigFile
(
filepath
.
Join
(
configPath
,
ConfigName
))
viper
.
SetConfigType
(
"toml"
)
viper
.
AutomaticEnv
()
...
...
config/fabric.toml
View file @
d359a25a
[fabric]
addr
=
"host.docker.internal:7053"
event_filter
=
"interchain-event-name"
username
=
"Admin"
ccid
=
"broker"
channel_id
=
"mychannel"
org
=
"org2"
\ No newline at end of file
org
=
"org2"
timeout_height
=
10
chain_id
=
"3"
[[services]]
id
=
"mychannel&transfer"
name
=
"transfer"
[[services]]
id
=
"mychannel&data_swapper"
name
=
"data_swapper"
\ No newline at end of file
event.go
View file @
d359a25a
package
main
import
(
"fmt"
"strings"
"time"
"github.com/cloudflare/cfssl/log"
"github.com/meshplus/bitxhub-model/pb"
"github.com/meshplus/bitxid"
)
type
Event
struct
{
Index
uint64
`json:"index"`
DstContractDID
string
`json:"dst_contract_did"`
SrcContractID
string
`json:"src_contract_id"`
Func
string
`json:"func"`
Args
string
`json:"args"`
Callback
string
`json:"callback"`
Argscb
string
`json:"argscb"`
Rollback
string
`json:"rollback"`
Argsrb
string
`json:"argsrb"`
Proof
[]
byte
`json:"proof"`
Extra
[]
byte
`json:"extra"`
Index
uint64
`json:"index"`
DstFullID
string
`json:"dst_full_id"`
SrcFullID
string
`json:"src_full_id"`
Func
string
`json:"func"`
Args
string
`json:"args"`
Argscb
string
`json:"argscb"`
Argsrb
string
`json:"argsrb"`
}
func
(
ev
*
Event
)
Convert2IBTP
(
srcMethod
string
,
ibtpType
pb
.
IBTP_Type
)
*
pb
.
IBTP
{
func
(
ev
*
Event
)
Convert2IBTP
(
timeoutHeight
int64
,
ibtpType
pb
.
IBTP_Type
)
*
pb
.
IBTP
{
pd
,
err
:=
ev
.
encryptPayload
()
if
err
!=
nil
{
log
.
Fatalf
(
"Get ibtp payload :%s"
,
err
)
}
return
&
pb
.
IBTP
{
From
:
srcMethod
,
To
:
string
(
bitxid
.
DID
(
ev
.
DstContractDID
)
.
GetChainDID
()),
Index
:
ev
.
Index
,
Type
:
ibtpType
,
Timestamp
:
time
.
Now
()
.
UnixNano
(),
Proof
:
ev
.
Proof
,
Payload
:
pd
,
Extra
:
ev
.
Extra
,
From
:
ev
.
SrcFullID
,
To
:
ev
.
DstFullID
,
Index
:
ev
.
Index
,
Type
:
ibtpType
,
TimeoutHeight
:
timeoutHeight
,
Payload
:
pd
,
}
}
...
...
@@ -51,15 +44,17 @@ func handleArgs(args string) [][]byte {
}
func
(
ev
*
Event
)
encryptPayload
()
([]
byte
,
error
)
{
funcSplit
:=
strings
.
Split
(
ev
.
Func
,
","
)
if
len
(
funcSplit
)
!=
3
{
return
nil
,
fmt
.
Errorf
(
"ibtp func not is (func, callback,rollback)"
)
}
content
:=
&
pb
.
Content
{
SrcContractId
:
ev
.
SrcContractID
,
DstContractId
:
bitxid
.
DID
(
ev
.
DstContractDID
)
.
GetAddress
(),
Func
:
ev
.
Func
,
Args
:
handleArgs
(
ev
.
Args
),
Callback
:
ev
.
Callback
,
ArgsCb
:
handleArgs
(
ev
.
Argscb
),
Rollback
:
ev
.
Rollback
,
ArgsRb
:
handleArgs
(
ev
.
Argsrb
),
Func
:
funcSplit
[
0
],
Args
:
handleArgs
(
ev
.
Args
),
Callback
:
funcSplit
[
1
],
ArgsCb
:
handleArgs
(
ev
.
Argscb
),
Rollback
:
funcSplit
[
2
],
ArgsRb
:
handleArgs
(
ev
.
Argsrb
),
}
data
,
err
:=
content
.
Marshal
()
if
err
!=
nil
{
...
...
example/contracts.zip
View file @
d359a25a
No preview for this file type
example/contracts/src/broker/broker.go
View file @
d359a25a
...
...
@@ -16,25 +16,26 @@ const (
innerMeta
=
"inner-meta"
outterMeta
=
"outter-meta"
callbackMeta
=
"callback-meta"
dstRollbackMeta
=
"dst-rollback-meta"
whiteList
=
"white-list"
adminList
=
"admin-list"
passed
=
"1"
rejected
=
"2"
delimiter
=
"&"
bxhID
=
"bxh-id"
appchainID
=
"appchain-id"
)
type
Broker
struct
{}
type
Event
struct
{
Index
uint64
`json:"index"`
DstContractDID
string
`json:"dst_contract_did"`
SrcContractID
string
`json:"src_contract_id"`
Func
string
`json:"func"`
Args
string
`json:"args"`
Callback
string
`json:"callback"`
Argscb
string
`json:"argscb"`
Rollback
string
`json:"rollback"`
Argsrb
string
`json:"argsrb"`
Index
uint64
`json:"index"`
DstFullID
string
`json:"dst_full_id"`
SrcFullID
string
`json:"src_full_id"`
Func
string
`json:"func"`
Args
string
`json:"args"`
Argscb
string
`json:"argscb"`
Argsrb
string
`json:"argsrb"`
}
type
CallFunc
struct
{
...
...
@@ -59,8 +60,10 @@ func (broker *Broker) Init(stub shim.ChaincodeStubInterface) pb.Response {
if
err
!=
nil
{
return
shim
.
Error
(
fmt
.
Sprintf
(
"Initialize admin list fail %s"
,
err
.
Error
()))
}
args
:=
make
([]
string
,
2
)
return
broker
.
initialize
(
stub
,
args
)
return
broker
.
initialize
(
stub
)
}
func
(
broker
*
Broker
)
Invoke
(
stub
shim
.
ChaincodeStubInterface
)
pb
.
Response
{
...
...
@@ -84,8 +87,12 @@ func (broker *Broker) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
return
broker
.
getInnerMeta
(
stub
)
case
"getOuterMeta"
:
return
broker
.
getOuterMeta
(
stub
)
case
"getDstRollbackMeta"
:
return
broker
.
getDstRollbackMeta
(
stub
)
case
"getCallbackMeta"
:
return
broker
.
getCallbackMeta
(
stub
)
case
"getChainId"
:
return
broker
.
getChainId
(
stub
)
case
"getInMessage"
:
return
broker
.
getInMessage
(
stub
,
args
)
case
"getOutMessage"
:
...
...
@@ -95,7 +102,7 @@ func (broker *Broker) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
case
"pollingEvent"
:
return
broker
.
pollingEvent
(
stub
,
args
)
case
"initialize"
:
return
broker
.
initialize
(
stub
)
return
broker
.
initialize
(
stub
,
args
)
case
"invokeInterchain"
:
return
broker
.
invokeInterchain
(
stub
,
args
)
case
"invokeIndexUpdate"
:
...
...
@@ -107,10 +114,26 @@ func (broker *Broker) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
}
}
func
(
broker
*
Broker
)
initialize
(
stub
shim
.
ChaincodeStubInterface
)
pb
.
Response
{
func
(
broker
*
Broker
)
initialize
(
stub
shim
.
ChaincodeStubInterface
,
args
[]
string
)
pb
.
Response
{
if
onlyAdmin
:=
broker
.
onlyAdmin
(
stub
);
!
onlyAdmin
{
return
shim
.
Error
(
"caller is not admin"
)
}
if
len
(
args
)
!=
2
{
return
shim
.
Error
(
"incorrect number of arguments, expecting 2"
)
}
if
err
:=
stub
.
PutState
(
bxhID
,
[]
byte
(
args
[
0
]));
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
}
if
err
:=
stub
.
PutState
(
appchainID
,
[]
byte
(
args
[
1
]));
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
}
inCounter
:=
make
(
map
[
string
]
uint64
)
outCounter
:=
make
(
map
[
string
]
uint64
)
callbackCounter
:=
make
(
map
[
string
]
uint64
)
dstRollbackCounter
:=
make
(
map
[
string
]
uint64
)
if
err
:=
broker
.
putMap
(
stub
,
innerMeta
,
inCounter
);
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
...
...
@@ -124,54 +147,50 @@ func (broker *Broker) initialize(stub shim.ChaincodeStubInterface) pb.Response {
return
shim
.
Error
(
err
.
Error
())
}
if
err
:=
broker
.
putMap
(
stub
,
dstRollbackMeta
,
dstRollbackCounter
);
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
}
return
shim
.
Success
(
nil
)
}
// EmitInterchainEvent
// string destContractDID,
// string func,
// string args,
// string callback;
// string argsCb;
// string rollback;
// string argsRb;
func
(
broker
*
Broker
)
EmitInterchainEvent
(
stub
shim
.
ChaincodeStubInterface
,
args
[]
string
)
pb
.
Response
{
if
len
(
args
)
!=
7
{
if
len
(
args
)
!=
5
{
return
shim
.
Error
(
"incorrect number of arguments, expecting 7"
)
}
d
estContractD
ID
:=
args
[
0
]
destChainMethod
:=
parseMethod
(
destContractDID
)
if
destChainMethod
==
""
{
return
ErrInvalidDID
(
destContractDID
)
d
stService
ID
:=
args
[
0
]
cid
,
err
:=
getChaincodeID
(
stub
)
if
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
()
)
}
outMeta
,
err
:=
broker
.
getMap
(
stub
,
outterMeta
)
curFullID
,
err
:=
broker
.
genFullServiceID
(
stub
,
cid
)
if
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
}
if
_
,
ok
:=
outMeta
[
destChainMethod
];
!
ok
{
outMeta
[
destChainMethod
]
=
0
}
outServicePair
:=
genServicePair
(
curFullID
,
dstServiceID
)
cid
,
err
:=
getChaincodeID
(
stub
)
outMeta
,
err
:=
broker
.
getMap
(
stub
,
outterMeta
)
if
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
}
if
_
,
ok
:=
outMeta
[
outServicePair
];
!
ok
{
outMeta
[
outServicePair
]
=
0
}
tx
:=
&
Event
{
Index
:
outMeta
[
destChainMethod
]
+
1
,
DstContractDID
:
destContractDID
,
SrcContractID
:
cid
,
Func
:
args
[
1
],
Args
:
args
[
2
],
Callback
:
args
[
3
],
Argscb
:
args
[
4
],
Rollback
:
args
[
5
],
Argsrb
:
args
[
6
],
Index
:
outMeta
[
outServicePair
]
+
1
,
DstFullID
:
dstServiceID
,
SrcFullID
:
curFullID
,
Func
:
args
[
1
],
Args
:
args
[
2
],
Argscb
:
args
[
3
],
Argsrb
:
args
[
4
],
}
outMeta
[
destChainMethod
]
++
outMeta
[
outServicePair
]
++
txValue
,
err
:=
json
.
Marshal
(
tx
)
if
err
!=
nil
{
...
...
@@ -179,7 +198,7 @@ func (broker *Broker) EmitInterchainEvent(stub shim.ChaincodeStubInterface, args
}
// persist out message
key
:=
broker
.
outMsgKey
(
destChainMethod
,
strconv
.
FormatUint
(
tx
.
Index
,
10
))
key
:=
broker
.
outMsgKey
(
outServicePair
,
strconv
.
FormatUint
(
tx
.
Index
,
10
))
if
err
:=
stub
.
PutState
(
key
,
txValue
);
err
!=
nil
{
return
shim
.
Error
(
fmt
.
Errorf
(
"persist event: %w"
,
err
)
.
Error
())
}
...
...
@@ -285,25 +304,48 @@ func (broker *Broker) pollingEvent(stub shim.ChaincodeStubInterface, args []stri
return
shim
.
Success
(
ret
)
}
func
(
broker
*
Broker
)
updateIndex
(
stub
shim
.
ChaincodeStubInterface
,
sourceChainMethod
,
sequenceNum
string
,
isReq
bool
)
error
{
if
isReq
{
if
err
:=
broker
.
checkIndex
(
stub
,
sourceChainMethod
,
sequenceNum
,
innerMeta
);
err
!=
nil
{
func
(
broker
*
Broker
)
updateIndex
(
stub
shim
.
ChaincodeStubInterface
,
srcChainServiceID
,
sequenceNum
string
,
dstAddr
string
,
reqType
uint64
)
error
{
curServiceID
,
err
:=
broker
.
genFullServiceID
(
stub
,
dstAddr
)
if
err
!=
nil
{
return
err
}
if
reqType
==
0
{
inServicePair
:=
genServicePair
(
srcChainServiceID
,
curServiceID
)
if
err
:=
broker
.
checkIndex
(
stub
,
inServicePair
,
sequenceNum
,
innerMeta
);
err
!=
nil
{
return
fmt
.
Errorf
(
"inner meta:%v"
,
err
)
}
if
err
:=
broker
.
markInCounter
(
stub
,
inServicePair
);
err
!=
nil
{
return
err
}
}
else
if
reqType
==
1
{
outServicePair
:=
genServicePair
(
curServiceID
,
srcChainServiceID
)
if
err
:=
broker
.
markInCounter
(
stub
,
sourceChainMethod
);
err
!=
nil
{
if
err
:=
broker
.
checkIndex
(
stub
,
outServicePair
,
sequenceNum
,
callbackMeta
);
err
!=
nil
{
return
fmt
.
Errorf
(
"callback:%v"
,
err
)
}
idx
,
err
:=
strconv
.
ParseUint
(
sequenceNum
,
10
,
64
)
if
err
!=
nil
{
return
err
}
}
else
{
if
err
:=
broker
.
checkIndex
(
stub
,
sourceChainMethod
,
sequenceNum
,
callbackMeta
);
err
!=
nil
{
if
err
:=
broker
.
markCallbackCounter
(
stub
,
outServicePair
,
idx
);
err
!=
nil
{
return
err
}
}
else
if
reqType
==
2
{
inServicePair
:=
genServicePair
(
srcChainServiceID
,
curServiceID
)
idx
,
err
:=
strconv
.
ParseUint
(
sequenceNum
,
10
,
64
)
if
err
!=
nil
{
return
err
}
if
err
:=
broker
.
markCallbackCounter
(
stub
,
sourceChainMethod
,
idx
);
err
!=
nil
{
meta
,
err
:=
broker
.
getMap
(
stub
,
dstRollbackMeta
)
if
err
!=
nil
{
return
err
}
if
idx
<
meta
[
inServicePair
]
+
1
{
return
fmt
.
Errorf
(
"incorrect dstRollback index, expect %d"
,
meta
[
inServicePair
]
+
1
)
}
if
err
:=
broker
.
markDstRollbackCounter
(
stub
,
inServicePair
,
idx
);
err
!=
nil
{
return
err
}
}
...
...
@@ -312,38 +354,71 @@ func (broker *Broker) updateIndex(stub shim.ChaincodeStubInterface, sourceChainM
}
func
(
broker
*
Broker
)
invokeIndexUpdate
(
stub
shim
.
ChaincodeStubInterface
,
args
[]
string
)
pb
.
Response
{
if
len
(
args
)
!=
3
{
return
errorResponse
(
"incorrect number of arguments, expecting
3
"
)
if
len
(
args
)
!=
4
{
return
errorResponse
(
"incorrect number of arguments, expecting
4
"
)
}
s
ourceChainMethod
:=
args
[
0
]
s
rcServiceID
:=
args
[
0
]
sequenceNum
:=
args
[
1
]
isReq
,
err
:=
strconv
.
ParseBool
(
args
[
2
])
dstAddr
:=
args
[
2
]
reqType
,
err
:=
strconv
.
ParseUint
(
args
[
3
],
10
,
64
)
if
err
!=
nil
{
return
errorResponse
(
fmt
.
Sprintf
(
"cannot parse %s to
bool
"
,
args
[
3
]))
return
errorResponse
(
fmt
.
Sprintf
(
"cannot parse %s to
uint64
"
,
args
[
3
]))
}
if
err
:=
broker
.
updateIndex
(
stub
,
s
ourceChainMethod
,
sequenceNum
,
isReq
);
err
!=
nil
{
if
err
:=
broker
.
updateIndex
(
stub
,
s
rcServiceID
,
sequenceNum
,
dstAddr
,
reqType
);
err
!=
nil
{
return
errorResponse
(
err
.
Error
())
}
return
successResponse
(
nil
)
}
func
(
broker
*
Broker
)
getChainId
(
stub
shim
.
ChaincodeStubInterface
)
pb
.
Response
{
bxhId
,
err
:=
stub
.
GetState
(
bxhID
)
if
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
}
appchainId
,
err
:=
stub
.
GetState
(
appchainID
)
if
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
}
return
successResponse
([]
byte
(
fmt
.
Sprintf
(
"%s-%s"
,
bxhId
,
appchainId
)))
}
func
(
broker
*
Broker
)
genFullServiceID
(
stub
shim
.
ChaincodeStubInterface
,
serviceId
string
)
(
string
,
error
)
{
bxhId
,
err
:=
stub
.
GetState
(
bxhID
)
if
err
!=
nil
{
return
""
,
err
}
appchainId
,
err
:=
stub
.
GetState
(
appchainID
)
if
err
!=
nil
{
return
""
,
err
}
return
fmt
.
Sprintf
(
"%s:%s:%s"
,
bxhId
,
appchainId
,
serviceId
),
nil
}
func
genServicePair
(
from
,
to
string
)
string
{
return
fmt
.
Sprintf
(
"%s-%s"
,
from
,
to
)
}
func
(
broker
*
Broker
)
invokeInterchain
(
stub
shim
.
ChaincodeStubInterface
,
args
[]
string
)
pb
.
Response
{
if
len
(
args
)
!=
5
{
return
errorResponse
(
"incorrect number of arguments, expecting 5"
)
}
srcChain
Method
:=
args
[
0
]
srcChain
ServiceID
:=
args
[
0
]
sequenceNum
:=
args
[
1
]
targetCID
:=
args
[
2
]
isReq
,
err
:=
strconv
.
ParseBool
(
args
[
3
]
)
reqType
,
err
:=
strconv
.
ParseUint
(
args
[
3
],
10
,
64
)
if
err
!=
nil
{
return
errorResponse
(
fmt
.
Sprintf
(
"cannot parse %s to
bool
"
,
args
[
3
]))
return
errorResponse
(
fmt
.
Sprintf
(
"cannot parse %s to
uint64
"
,
args
[
3
]))
}
if
err
:=
broker
.
updateIndex
(
stub
,
srcChain
Method
,
sequenceNum
,
isReq
);
err
!=
nil
{
if
err
:=
broker
.
updateIndex
(
stub
,
srcChain
ServiceID
,
sequenceNum
,
targetCID
,
reqType
);
err
!=
nil
{
return
errorResponse
(
err
.
Error
())
}
...
...
@@ -365,7 +440,13 @@ func (broker *Broker) invokeInterchain(stub shim.ChaincodeStubInterface, args []
return
errorResponse
(
fmt
.
Sprintf
(
"invoke chaincode '%s' function %s err: %s"
,
splitedCID
[
1
],
callFunc
.
Func
,
response
.
Message
))
}
inKey
:=
broker
.
inMsgKey
(
srcChainMethod
,
sequenceNum
)
curServiceID
,
err
:=
broker
.
genFullServiceID
(
stub
,
targetCID
)
if
err
!=
nil
{
return
errorResponse
(
err
.
Error
())
}
inServicePair
:=
genServicePair
(
srcChainServiceID
,
curServiceID
)
inKey
:=
broker
.
inMsgKey
(
inServicePair
,
sequenceNum
)
value
,
err
:=
json
.
Marshal
(
response
)
if
err
!=
nil
{
return
errorResponse
(
err
.
Error
())
...
...
example/contracts/src/broker/go.mod
0 → 100644
View file @
d359a25a
module github.com/meshplus/broker
go 1.13
require (
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
github.com/Shopify/sarama v1.29.1 // indirect
github.com/fsouza/go-dockerclient v1.7.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hyperledger/fabric v1.4.3
github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/onsi/gomega v1.14.0 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/spf13/viper v1.8.1 // indirect
github.com/sykesm/zap-logfmt v0.0.4 // indirect
go.uber.org/zap v1.18.1 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
google.golang.org/grpc v1.39.0 // indirect
)
replace github.com/golang/protobuf => github.com/golang/protobuf v1.3.2
example/contracts/src/broker/helper.go
View file @
d359a25a
...
...
@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"strconv"
"strings"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/chaincode/shim"
...
...
@@ -43,7 +42,7 @@ func errorResponse(msg string) pb.Response {
panic
(
err
)
}
return
shim
.
Success
(
data
)
return
shim
.
Error
(
string
(
data
)
)
}
// putMap for persisting meta state into ledger
...
...
@@ -201,23 +200,3 @@ func (broker *Broker) checkWhitelist(stub shim.ChaincodeStubInterface, function
return
broker
.
onlyWhitelist
(
stub
)
}
func
(
broker
*
Broker
)
validDID
(
did
string
)
bool
{
s
:=
strings
.
Split
(
did
,
":"
)
if
len
(
s
)
!=
4
||
s
[
0
]
!=
"did"
||
s
[
1
]
==
""
||
s
[
2
]
==
""
||
s
[
3
]
==
""
{
return
false
}
return
true
}
func
parseMethod
(
did
string
)
string
{
s
:=
strings
.
Split
(
did
,
":"
)
if
len
(
s
)
!=
4
||
s
[
0
]
!=
"did"
||
s
[
1
]
==
""
||
s
[
2
]
==
""
||
s
[
3
]
==
""
{
return
""
}
return
fmt
.
Sprintf
(
"%s:%s:%s:."
,
s
[
0
],
s
[
1
],
s
[
2
])
}
func
ErrInvalidDID
(
did
string
)
pb
.
Response
{
return
errorResponse
(
fmt
.
Sprintf
(
"Invalid did format for %s"
,
did
))
}
example/contracts/src/broker/meta.go
View file @
d359a25a
...
...
@@ -21,9 +21,6 @@ func (broker *Broker) getOutMessage(stub shim.ChaincodeStubInterface, args []str
}
destChainMethod
:=
args
[
0
]
sequenceNum
:=
args
[
1
]
if
!
broker
.
validDID
(
destChainMethod
)
{
return
ErrInvalidDID
(
destChainMethod
)
}
key
:=
broker
.
outMsgKey
(
destChainMethod
,
sequenceNum
)
v
,
err
:=
stub
.
GetState
(
key
)
if
err
!=
nil
{
...
...
@@ -45,12 +42,9 @@ func (broker *Broker) getInMessage(stub shim.ChaincodeStubInterface, args []stri
if
len
(
args
)
<
2
{
return
shim
.
Error
(
"incorrect number of arguments, expecting 2"
)
}
sourceChainMethod
:=
args
[
0
]
inServicePair
:=
args
[
0
]
sequenceNum
:=
args
[
1
]
if
!
broker
.
validDID
(
sourceChainMethod
)
{
return
ErrInvalidDID
(
sourceChainMethod
)
}
key
:=
broker
.
inMsgKey
(
sourceChainMethod
,
sequenceNum
)
key
:=
broker
.
inMsgKey
(
inServicePair
,
sequenceNum
)
v
,
err
:=
stub
.
GetState
(
key
)
if
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
...
...
@@ -66,6 +60,14 @@ func (broker *Broker) getCallbackMeta(stub shim.ChaincodeStubInterface) pb.Respo
return
shim
.
Success
(
v
)
}
func
(
broker
*
Broker
)
getDstRollbackMeta
(
stub
shim
.
ChaincodeStubInterface
)
pb
.
Response
{
v
,
err
:=
stub
.
GetState
(
dstRollbackMeta
)
if
err
!=
nil
{
return
shim
.
Error
(
err
.
Error
())
}
return
shim
.
Success
(
v
)
}
func
(
broker
*
Broker
)
markInCounter
(
stub
shim
.
ChaincodeStubInterface
,
from
string
)
error
{
inMeta
,
err
:=
broker
.
getMap
(
stub
,
innerMeta
)
if
err
!=
nil
{
...
...
@@ -86,3 +88,15 @@ func (broker *Broker) markCallbackCounter(stub shim.ChaincodeStubInterface, from
return
broker
.
putMap
(
stub
,
callbackMeta
,
meta
)
}
func
(
broker
*
Broker
)
markDstRollbackCounter
(
stub
shim
.
ChaincodeStubInterface
,
from
string
,
index
uint64
)
error
{
meta
,
err
:=
broker
.
getMap
(
stub
,
dstRollbackMeta
)
if
err
!=
nil
{
return
err
}
meta
[
from
]
=
index
return
broker
.
putMap
(
stub
,
dstRollbackMeta
,
meta
)
}
example/contracts/src/data_swapper/data_swapper.go
View file @
d359a25a
...
...
@@ -62,9 +62,9 @@ func (s *DataSwapper) get(stub shim.ChaincodeStubInterface, args []string) pb.Re
return
shim
.
Success
(
value
)
case
2
:
// args[0]: destination
appchain contract d
id
// args[0]: destination
service
id
// args[1]: key
b
:=
util
.
ToChaincodeArgs
(
emitInterchainEventFunc
,
args
[
0
],
"interchainGet
"
,
args
[
2
],
"interchainSet"
,
args
[
2
],
""
,
""
)
b
:=
util
.
ToChaincodeArgs
(
emitInterchainEventFunc
,
args
[
0
],
"interchainGet
,interchainSet,"
,
args
[
1
],
args
[
1
]
,
""
)
response
:=
stub
.
InvokeChaincode
(
brokerContractName
,
b
,
channelID
)
if
response
.
Status
!=
shim
.
OK
{
return
shim
.
Error
(
fmt
.
Errorf
(
"invoke broker chaincode %s error: %s"
,
brokerContractName
,
response
.
Message
)
.
Error
())
...
...
example/contracts/src/data_swapper/go.mod
0 → 100644
View file @
d359a25a
module github.com/meshplus/data_swapper
go 1.13
require (
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
github.com/Shopify/sarama v1.29.1 // indirect
github.com/fsouza/go-dockerclient v1.7.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hyperledger/fabric v1.4.3
github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/onsi/gomega v1.14.0 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/spf13/viper v1.8.1 // indirect
github.com/sykesm/zap-logfmt v0.0.4 // indirect
go.uber.org/zap v1.18.1 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
google.golang.org/grpc v1.39.0 // indirect
)
replace github.com/golang/protobuf => github.com/golang/protobuf v1.3.2
example/contracts/src/transfer/go.mod
0 → 100644
View file @
d359a25a
module github.com/meshplus/transfer
go 1.13
require (
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
github.com/Shopify/sarama v1.29.1 // indirect
github.com/fsouza/go-dockerclient v1.7.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hyperledger/fabric v1.4.3
github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/onsi/gomega v1.14.0 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/spf13/viper v1.8.1 // indirect
github.com/sykesm/zap-logfmt v0.0.4 // indirect
go.uber.org/zap v1.18.1 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
google.golang.org/grpc v1.39.0 // indirect
)
replace github.com/golang/protobuf => github.com/golang/protobuf v1.3.2
example/contracts/src/transfer/transfer.go
View file @
d359a25a
...
...
@@ -92,8 +92,7 @@ func (t *Transfer) transfer(stub shim.ChaincodeStubInterface, args []string) pb.
return
shim
.
Success
(
nil
)
case
4
:
// args[0]: destination appchain contract did
destContractDID
:=
args
[
0
]
dstServiceID
:=
args
[
0
]
sender
:=
args
[
1
]
receiver
:=
args
[
2
]
amountArg
:=
args
[
3
]
...
...
@@ -119,9 +118,9 @@ 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
,
"false"
},
","
)
argsRb
:=
strings
.
Join
([]
string
{
sender
,
amountArg
},
","
)
b
:=
util
.
ToChaincodeArgs
(
emitInterchainEventFunc
,
d
estContractDID
,
"interchainCharge"
,
args
,
""
,
""
,
"interchainRollback
"
,
argsRb
)
b
:=
util
.
ToChaincodeArgs
(
emitInterchainEventFunc
,
d
stServiceID
,
"interchainCharge,,interchainRollback"
,
args
,
"
"
,
argsRb
)
response
:=
stub
.
InvokeChaincode
(
brokerContractName
,
b
,
channelID
)
if
response
.
Status
!=
shim
.
OK
{
return
shim
.
Error
(
fmt
.
Errorf
(
"invoke broker chaincode %s"
,
response
.
Message
)
.
Error
())
...
...
@@ -167,13 +166,14 @@ func (t *Transfer) setBalance(stub shim.ChaincodeStubInterface, args []string) p
// charge user,amount
func
(
t
*
Transfer
)
interchainCharge
(
stub
shim
.
ChaincodeStubInterface
,
args
[]
string
)
pb
.
Response
{
if
len
(
args
)
!=
3
{
if
len
(
args
)
!=
4
{
return
shim
.
Error
(
"incorrect number of arguments, expect 3"
)
}
sender
:=
args
[
0
]
receiver
:=
args
[
1
]
amountArg
:=
args
[
2
]
isRollback
:=
args
[
3
]
// check for sender info
if
sender
==
""
{
...
...
@@ -190,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
())
...
...
go.mod
View file @
d359a25a
...
...
@@ -3,26 +3,23 @@ module github.com/meshplus/pier-client-fabric
go 1.13
require (
github.com/
OneOfOne/xxhash v1.2.5
// indirect
github.com/
Knetic/govaluate v3.0.0+incompatible
// indirect
github.com/Rican7/retry v0.1.0
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/cloudflare/cfssl v0.0.0-20190409034051-768cd563887f
github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa // indirect
github.com/go-logfmt/logfmt v0.4.0 // indirect
github.com/golang/protobuf v1.
4.3
github.com/golang/protobuf v1.
5.2
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-2020
0330074707-cfe579e86986
github.com/hyperledger/fabric-protos-go v0.0.0-2020
1028172056-a3136dde2354
github.com/hyperledger/fabric-sdk-go v1.0.0-alpha5
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/meshplus/bitxhub-model v1.2.1-0.20210805064451-03258148acad
github.com/meshplus/pier v1.11.1-0.20210809064238-de527e06d443
github.com/spf13/viper v1.7.0
sigs.k8s.io/yaml v1.2.0 // indirect
)
replace (
...
...
@@ -30,5 +27,4 @@ replace (
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 @
d359a25a
...
...
@@ -40,6 +40,7 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/Knetic/govaluate v1.5.0 h1:L4MyqdJSld9xr2eZcZHCWLfeIX2SBjqrwIKG1pcm/+4=
github.com/Knetic/govaluate v3.0.0+incompatible h1:7o6+MAPhYTCF0+fdvoz1xDedhRb4f6s9Tn1Tt7/WTEg=
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y=
...
...
@@ -61,6 +62,7 @@ github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrU
github.com/VictoriaMetrics/fastcache v1.5.3/go.mod h1:+jv9Ckb+za/P1ZRg/sulP5Ni1v49daAVERr0H3CuscE=
github.com/VictoriaMetrics/fastcache v1.5.7 h1:4y6y0G8PRzszQUYIQHHssv/jgPHAb5qQuuDNdCbyAgw=
github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
...
...
@@ -157,6 +159,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/common-nighthawk/go-figure v0.0.0-20190529165535-67e0ed34491a/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
github.com/consensys/bavard v0.1.8-0.20210105233146-c16790d2aa8b/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ=
github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ=
github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q=
github.com/consensys/goff v0.3.10/go.mod h1:xTldOBEHmFiYS0gPXd3NsaEqZWlnmeWcRLWgD3ba3xc=
github.com/consensys/gurvy v0.3.8/go.mod h1:sN75xnsiD593XnhbhvG2PkOy194pZBzqShWF/kwuW/g=
github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=
...
...
@@ -237,6 +241,7 @@ github.com/ethereum/go-ethereum v1.9.18/go.mod h1:JSSTypSMTkGZtAdAChH2wP5dZEvPGh
github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8plZ0M9VMk4/oM=
github.com/ethereum/go-ethereum v1.10.2 h1:qRDI7ztIBsAFH0ULVjU+twnRUYV2ApT0XJBdxxaSNzk=
github.com/ethereum/go-ethereum v1.10.2/go.mod h1:YmSRTZNqAvVUg3BIG8uhT/BOkFk9+R2iCbxw5zOlnWY=
github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg=
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU=
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw=
github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
...
...
@@ -380,6 +385,7 @@ github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3 h1:ur2rms48b3Ep1dxh7aUV2FZEQ8jEVO2F6ILKx8ofkAg=
github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 h1:23T5iq8rbUYlhpt5DB4XJkc6BU31uODLD1o1gKvZmD0=
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4=
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a h1:w8hkcTqaFpzKqonE9uMCefW1WDie15eSP/4MssdenaM=
...
...
@@ -523,6 +529,7 @@ github.com/hokaccha/go-prettyjson v0.0.0-20190818114111-108c894c2c0e/go.mod h1:p
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huin/goupnp v0.0.0-20161224104101-679507af18f3/go.mod h1:MZ2ZmwcBpvOoJ22IJsc7va19ZwoheaBk43rKg12SKag=
...
...
@@ -538,6 +545,7 @@ github.com/hyperledger/fabric v2.1.1+incompatible h1:cYYRv3vVg4kA6DmrixLxwn1nwBE
github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a h1:HgdNn3UYz8PdcZrLEk0IsSU4LRHp7yY2rgjIKcSiJaA=
github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE=
github.com/hyperledger/fabric-amcl v0.0.0-20200424173818-327c9e2cf77a/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE=
github.com/hyperledger/fabric-amcl v0.0.0-20210603140002-2670f91851c8/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE=
github.com/hyperledger/fabric-chaincode-go v0.0.0-20200511190512-bcfeb58dd83a h1:KoFw2HnRfW+EItMP0zvUUl1FGzDb/7O0ov7uXZffQok=
github.com/hyperledger/fabric-chaincode-go v0.0.0-20200511190512-bcfeb58dd83a/go.mod h1:N7H3sA7Tx4k/YzFq7U0EPdqJtqvM4Kild0JoCc7C0Dc=
github.com/hyperledger/fabric-lib-go v1.0.0 h1:UL1w7c9LvHZUSkIvHTDGklxFv2kTeva1QI2emOVc324=
...
...
@@ -547,6 +555,8 @@ github.com/hyperledger/fabric-protos-go v0.0.0-20191121202242-f5500d5e3e85/go.mo
github.com/hyperledger/fabric-protos-go v0.0.0-20200124220212-e9cfc186ba7b/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20200330074707-cfe579e86986 h1:g9tgYXQPZcxRryp2/rutvfSCiiJzHNoyX7JaoXeGkZ8=
github.com/hyperledger/fabric-protos-go v0.0.0-20200330074707-cfe579e86986/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-protos-go v0.0.0-20201028172056-a3136dde2354 h1:6vLLEpvDbSlmUJFjg1hB5YMBpI+WgKguztlONcAFBoY=
github.com/hyperledger/fabric-protos-go v0.0.0-20201028172056-a3136dde2354/go.mod h1:xVYTjK4DtZRBxZ2D9aE4y6AbLaPwue2o/criQyQbVD0=
github.com/hyperledger/fabric-sdk-go v1.0.0-alpha5 h1:gc6CVOAM6Br4HMfs3N6ZSK9bJdZo4zhiEbrYS8fqVwA=
github.com/hyperledger/fabric-sdk-go v1.0.0-alpha5/go.mod h1:kqYuM7jCDf1BbXWgbWaevpnlhDii5i4TkGXhfib2epU=
github.com/hyperledger/fabric-sdk-go v1.0.0-beta2 h1:FBYygns0Qga+mQ4PXycyTU5m4N9KAZM+Ttf7agiV7M8=
...
...
@@ -881,6 +891,7 @@ github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20201021153523-274a013bfd41/go.mod
github.com/meshplus/bitxhub-core v0.1.0-rc1.0.20210204062242-16739cd5ee9a/go.mod h1:MHf0waxqnW4Qwfpq66jqvJP+FritN5OTs/8wlQcNlJY=
github.com/meshplus/bitxhub-core v1.3.0/go.mod h1:2ksSKEiox4B06gSPT6h4+GcdWnh92/FDPUUImX/dI04=
github.com/meshplus/bitxhub-core v1.3.1-0.20210524071255-789fd9ab501c/go.mod h1:3jozBvAkL1+asOJPvhCouIZoedWnhr79LgDAdX9o95I=
github.com/meshplus/bitxhub-core v1.3.1-0.20210803021905-6eb15f02fc23/go.mod h1:yP/sWObKXNTovvopImIWNIy50vpdCdlrZkZM1RJoxts=
github.com/meshplus/bitxhub-kit v1.0.0-rc1 h1:gNi8IFU5CMHT3KE2I4ACj5alMW9h/4cV8xOxn7wSmtA=
github.com/meshplus/bitxhub-kit v1.0.0-rc1/go.mod h1:ra/AhOkPvpElI+wXrB9G6DjdcrdxFU3vMwA5MYKr9D0=
github.com/meshplus/bitxhub-kit v1.0.0-rc2/go.mod h1:1XDQRhdVkFDwQH3SgKKyy+cpUyfozNmCqrudDXlh2Oo=
...
...
@@ -905,6 +916,8 @@ github.com/meshplus/bitxhub-kit v1.2.0 h1:lG6vyRD14bPoQFNU8ygmgzMXAy4xDlEueJyM6v
github.com/meshplus/bitxhub-kit v1.2.0/go.mod h1:vGTKDkCAU7/IlirT6tlq6BMnCpY9UbfrrwGDy6foQIg=
github.com/meshplus/bitxhub-kit v1.2.1-0.20210524063043-9afae78ac098 h1:/E1isgGcUXQhTlKgVZ7GULTqw+0mj/WZ1a+Yd5N7Bmg=
github.com/meshplus/bitxhub-kit v1.2.1-0.20210524063043-9afae78ac098/go.mod h1:wrEdhHp1tktzdwcWb4bOxYsVc+KkcrYL18IYWYeumPQ=
github.com/meshplus/bitxhub-kit v1.2.1-0.20210616114532-4849447f09e1 h1:rLkrRvNOduKx+w3sGxNQIUCFf2Qu6d/mvTCGZjsfVZw=
github.com/meshplus/bitxhub-kit v1.2.1-0.20210616114532-4849447f09e1/go.mod h1:wrEdhHp1tktzdwcWb4bOxYsVc+KkcrYL18IYWYeumPQ=
github.com/meshplus/bitxhub-model v1.0.0-rc3/go.mod h1:ZCctQIYTlE3vJ8Lhkrgs9bWwNA+Dw4JzojOSIzLVU6E=
github.com/meshplus/bitxhub-model v1.0.0-rc4.0.20200429111056-62b55c3d4260 h1:C82XmTofR2/R/1rafiwjLkgTvzPN/0cOQHBbpxEXUyY=
github.com/meshplus/bitxhub-model v1.0.0-rc4.0.20200429111056-62b55c3d4260/go.mod h1:QK8aACbxtZEA3Hk1BOCirW0uxMWLsMrLDpWz9FweIKM=
...
...
@@ -930,6 +943,10 @@ github.com/meshplus/bitxhub-model v1.2.1-0.20210512070527-c3a68359d36c/go.mod h1
github.com/meshplus/bitxhub-model v1.2.1-0.20210524063354-5d48e2fee178/go.mod h1:vwJ+sHPUyA2JELmUUDBol+7zA+7GcqutxzqXjsN0QLA=
github.com/meshplus/bitxhub-model v1.2.1-0.20210524073042-f243c2fee25b h1:X3USIatxU/mMy4P7y9/x6ONDHm3CFEgfTyHo4KGAt2o=
github.com/meshplus/bitxhub-model v1.2.1-0.20210524073042-f243c2fee25b/go.mod h1:vwJ+sHPUyA2JELmUUDBol+7zA+7GcqutxzqXjsN0QLA=
github.com/meshplus/bitxhub-model v1.2.1-0.20210629020432-d98febd566c1/go.mod h1:IjgoQrsn1wthW7XcKRqgaZqCSlqNy0SBwF/7lmGSqXc=
github.com/meshplus/bitxhub-model v1.2.1-0.20210728034727-3e559aabfbe3/go.mod h1:IjgoQrsn1wthW7XcKRqgaZqCSlqNy0SBwF/7lmGSqXc=
github.com/meshplus/bitxhub-model v1.2.1-0.20210805064451-03258148acad h1:bB1ozZF+B5G0iiJ1eJ+NSeO+ckKTzTXYCGUurDT1mg4=
github.com/meshplus/bitxhub-model v1.2.1-0.20210805064451-03258148acad/go.mod h1:IjgoQrsn1wthW7XcKRqgaZqCSlqNy0SBwF/7lmGSqXc=
github.com/meshplus/bitxid v0.0.0-20210331074321-62187b1145f5 h1:AIK+w1w46SDjf3BGQstCnzoLRK1OeDullbaATaXbTHc=
github.com/meshplus/bitxid v0.0.0-20210331074321-62187b1145f5/go.mod h1:vAldSRfDe2Qo7exsSTbchVmZWXPY7fhWQrRw18QJHho=
github.com/meshplus/bitxid v0.0.0-20210412025850-e0eaf0f9063a h1:c4ESPDa60Jd4zfzZIGGTyzhfaVM3vKN+xV2G9BwIDGQ=
...
...
@@ -941,6 +958,7 @@ github.com/meshplus/go-bitxhub-client v1.0.0-rc4.0.20200731031000-ec0387c42327/g
github.com/meshplus/go-bitxhub-client v1.0.0-rc4.0.20201023092924-5f9a248146f9/go.mod h1:6e0wKF//AwnJPlzXsfl5EDLRzn+/Wt8+fOEbKsYSFlc=
github.com/meshplus/go-bitxhub-client v1.0.0-rc4.0.20210301024916-b7461066a067/go.mod h1:ZWklYGrAMQcknmMMyxZtRU1IiBRuoYy570QNTp3WJbI=
github.com/meshplus/go-bitxhub-client v1.3.0/go.mod h1:oeX3NbSpHGsc3v2ZSAaYc+WbG9+eKhYLjGCvX/KEmhU=
github.com/meshplus/go-bitxhub-client v1.3.1-0.20210701063659-a0836fbc1c78/go.mod h1:etPPxsG4sQV0QWuVHLWrMPtTQbkt2LCccOa3yDyKIHo=
github.com/meshplus/go-lightp2p v0.0.0-20200817105923-6b3aee40fa54/go.mod h1:G89UJaeqCQFxFdp8wzy1AdKfMtDEhpySau0pjDNeeaw=
github.com/meshplus/pier v1.0.0-rc1.0.20200707085406-951dc93be28b h1:2w2wGZ1XSHosf5vQDP3hE5LbLqRJusXJAW99oX/MrH4=
github.com/meshplus/pier v1.0.0-rc1.0.20200707085406-951dc93be28b/go.mod h1:nRBB9WTl9/mdDlUutQKNh4qkVN3QQWJEM5B+RUxhO8w=
...
...
@@ -962,6 +980,8 @@ github.com/meshplus/pier v1.7.1-0.20210520094508-a8b2d96fd5c5 h1:rgD8Sr6K3r5+X7k
github.com/meshplus/pier v1.7.1-0.20210520094508-a8b2d96fd5c5/go.mod h1:jp2TrTX5iKXEA0UHFyCA62t6vfbogd3rNR/qagfAgNI=
github.com/meshplus/pier v1.7.1-0.20210524093640-1337e0a53318 h1:On8bT4A8mldYLx2ljJyd1DQ/mHmqKgIiOPBCKEhie3o=
github.com/meshplus/pier v1.7.1-0.20210524093640-1337e0a53318/go.mod h1:lRpgDnF72/wpQTBIp5eLxiv5YxLe+XhefYgPyFLN4/4=
github.com/meshplus/pier v1.11.1-0.20210809064238-de527e06d443 h1:MPDYVXTHx0HZO9rPlGEzOxgSe3o8cxr4HeVelH5XlKY=
github.com/meshplus/pier v1.11.1-0.20210809064238-de527e06d443/go.mod h1:hklBupF/Wo2k2+LG2dpR0KTR83kvLnYNUpjsdq/a7UI=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
...
...
@@ -1205,6 +1225,7 @@ github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc=
github.com/shirou/gopsutil v2.20.5+incompatible h1:tYH07UPoQt0OCQdgWWMgYHy3/a9bcxNpBIysykNIP7I=
github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM=
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
...
...
@@ -1220,6 +1241,8 @@ github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
...
...
@@ -1286,6 +1309,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/sykesm/zap-logfmt v0.0.3 h1:3Wrhf7+I9JEUD8B6KPtDAr9j2jrS0/EPLy7GCE1t/+U=
github.com/sykesm/zap-logfmt v0.0.3/go.mod h1:AuBd9xQjAe3URrWT1BBDk2v2onAZHkZkWRMiYZXiZWA=
github.com/sykesm/zap-logfmt v0.0.4 h1:U2WzRvmIWG1wDLCFY3sz8UeEmsdHQjHFNlIdmroVFaI=
github.com/sykesm/zap-logfmt v0.0.4/go.mod h1:AuBd9xQjAe3URrWT1BBDk2v2onAZHkZkWRMiYZXiZWA=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA=
github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA=
...
...
@@ -1313,6 +1338,8 @@ github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4C
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/tjfoc/gmsm v1.3.0/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4=
...
...
@@ -1343,6 +1370,7 @@ github.com/valyala/quicktemplate v1.2.0/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOV
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30/go.mod h1:YkocrP2K2tcw938x9gCOmT5G5eCD6jsTz0SZuyAqwIE=
github.com/wasmerio/go-ext-wasm v0.3.1/go.mod h1:VGyarTzasuS7k5KhSIGpM3tciSZlkP31Mp9VJTHMMeI=
github.com/wasmerio/wasmer-go v1.0.3/go.mod h1:0gzVdSfg6pysA6QVp6iVRPTagC6Wq9pOE8J86WKb2Fk=
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc=
github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM=
github.com/whyrusleeping/go-logging v0.0.1/go.mod h1:lDPYj54zutzG1XYfHAhcc7oNXEburHQBn+Iqd4yS4vE=
...
...
@@ -1430,6 +1458,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
...
...
@@ -1465,6 +1495,8 @@ golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hM
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
...
...
@@ -1512,6 +1544,8 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d h1:1aflnvSoWWLI2k/dMUAl5lvU1YO4Mb4hz0gh+1rjcxU=
golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
...
...
@@ -1528,6 +1562,7 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20171026204733-164713f0dfce/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
...
...
@@ -1588,8 +1623,13 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210105210732-16f7687f5001/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988 h1:EjgCl+fVlIaPJSori0ikSz3uV0DOHKWOJFpv1sAAhBM=
golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
...
...
@@ -1667,6 +1707,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20201009162240-fcf82128ed91/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
...
...
@@ -1746,10 +1788,13 @@ google.golang.org/grpc v1.36.0 h1:o1bcQ6imQMIOpdrO3SWf2z5RV72WbDwdXuK0MDlc8As=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.37.0 h1:uSZWeQJX5j11bIQ4AJoj+McDBo29cY1MCoC1wO3ts+c=
google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0=
google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q=
google.golang.org/grpc/examples v0.0.0-20210510171131-b1940e15f677 h1:wQ50l/w1vgTlPZv1anG/LLXW351vF/Gh5EtmB13/YYE=
google.golang.org/grpc/examples v0.0.0-20210510171131-b1940e15f677/go.mod h1:Ly7ZA/ARzg8fnPU9TyZIxoz33sEUuWX7txiqs8lPTgE=
google.golang.org/grpc/examples v0.0.0-20210519181852-3dd75a6888ce h1:Ch3oxgA17sj8n/1ZTciCtZO7Yvk0G+pUV3C2/rXqYyQ=
google.golang.org/grpc/examples v0.0.0-20210519181852-3dd75a6888ce/go.mod h1:bF8wuZSAZTcbF7ZPKrDI/qY52toTP/yxLpRRY4Eu9Js=
google.golang.org/grpc/examples v0.0.0-20210818220435-8ab16ef276a3 h1:gXMY2FHQpUjqxMJ2i8eM7cjy8Ma9QyUcB41I9WgZkDE=
google.golang.org/grpc/examples v0.0.0-20210818220435-8ab16ef276a3/go.mod h1:bF8wuZSAZTcbF7ZPKrDI/qY52toTP/yxLpRRY4Eu9Js=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
...
...
@@ -1823,6 +1868,8 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.1.3 h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o=
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed h1:WX1yoOaKQfddO/mLzdV4wptyWgoH/6hwLs7QHTixo0I=
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphDJbHOQO1DFFFTeBo=
...
...
receipt.go
View file @
d359a25a
...
...
@@ -2,14 +2,13 @@ package main
import
(
"fmt"
"time"
"github.com/meshplus/bitxhub-model/pb"
)
func
(
c
*
Client
)
generateCallback
(
original
*
pb
.
IBTP
,
args
[][]
byte
,
proof
[]
byte
,
status
bool
)
(
result
*
pb
.
IBTP
,
err
error
)
{
func
(
c
*
Client
)
generateCallback
(
original
*
pb
.
IBTP
,
args
[][]
byte
,
status
bool
)
(
result
*
pb
.
IBTP
,
err
error
)
{
if
original
==
nil
{
return
nil
,
fmt
.
Errorf
(
"got nil ibtp
t
o generate receipt: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"got nil ibtp
T
o generate receipt: %w"
,
err
)
}
pd
:=
&
pb
.
Payload
{}
if
err
:=
pd
.
Unmarshal
(
original
.
Payload
);
err
!=
nil
{
...
...
@@ -20,10 +19,9 @@ func (c *Client) generateCallback(original *pb.IBTP, args [][]byte, proof []byte
if
err
:=
originalContent
.
Unmarshal
(
pd
.
Content
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"ibtp payload unmarshal: %w"
,
err
)
}
content
:=
&
pb
.
Content
{
SrcContractId
:
originalContent
.
DstContractId
,
DstContractId
:
originalContent
.
SrcContractId
,
}
content
:=
&
pb
.
Content
{}
typ
:=
pb
.
IBTP_RECEIPT_SUCCESS
if
status
{
content
.
Func
=
originalContent
.
Callback
...
...
@@ -31,6 +29,11 @@ func (c *Client) generateCallback(original *pb.IBTP, args [][]byte, proof []byte
}
else
{
content
.
Func
=
originalContent
.
Rollback
content
.
Args
=
originalContent
.
ArgsRb
typ
=
pb
.
IBTP_RECEIPT_FAILURE
}
if
original
.
Type
==
pb
.
IBTP_ROLLBACK
{
typ
=
pb
.
IBTP_RECEIPT_ROLLBACK
}
b
,
err
:=
content
.
Marshal
()
...
...
@@ -46,19 +49,13 @@ func (c *Client) generateCallback(original *pb.IBTP, args [][]byte, proof []byte
return
nil
,
err
}
typ
:=
pb
.
IBTP_RECEIPT_SUCCESS
if
!
status
{
typ
=
pb
.
IBTP_RECEIPT_FAILURE
}
return
&
pb
.
IBTP
{
From
:
original
.
From
,
To
:
original
.
To
,
Index
:
original
.
Index
,
Type
:
typ
,
Timestamp
:
time
.
Now
()
.
UnixNano
(),
Proof
:
proof
,
Payload
:
pdb
,
Version
:
original
.
Version
,
From
:
original
.
From
,
To
:
original
.
To
,
Index
:
original
.
Index
,
Type
:
typ
,
Proof
:
original
.
Proof
,
Payload
:
pdb
,
Version
:
original
.
Version
,
},
nil
}
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