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
fdcd26a1
Unverified
Commit
fdcd26a1
authored
May 15, 2020
by
Aiden X
Committed by
GitHub
May 15, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9 from meshplus/refactor/update-fabric-lib
Refactor/update fabric lib and new ibtp payload
parents
a54b3ba0
5213e2b7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
77 additions
and
54 deletions
+77
-54
client.go
client.go
+13
-9
consumer.go
consumer.go
+2
-2
event.go
event.go
+9
-1
broker.go
example/broker/broker.go
+3
-3
data_swapper.go
example/broker/data_swapper.go
+2
-2
helper.go
example/broker/helper.go
+2
-2
meta.go
example/broker/meta.go
+2
-2
transfer.go
example/broker/transfer.go
+2
-2
data_swapper.go
example/data_swapper/data_swapper.go
+2
-2
helper.go
example/transfer/helper.go
+1
-1
transfer.go
example/transfer/transfer.go
+2
-2
go.mod
go.mod
+11
-13
go.sum
go.sum
+0
-0
receipt.go
receipt.go
+26
-13
No files found.
client.go
View file @
fdcd26a1
...
...
@@ -10,13 +10,13 @@ import (
"github.com/Rican7/retry"
"github.com/Rican7/retry/strategy"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
"github.com/hyperledger/fabric-sdk-go/pkg/client/ledger"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/peer"
"github.com/meshplus/bitxhub-kit/log"
"github.com/meshplus/bitxhub-model/pb"
"github.com/meshplus/pier/pkg/model"
...
...
@@ -231,12 +231,16 @@ func (c *Client) SubmitIBTP(ibtp *pb.IBTP) (*model.PluginResponse, error) {
if
err
:=
pd
.
Unmarshal
(
ibtp
.
Payload
);
err
!=
nil
{
return
ret
,
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
)
}
args
:=
util
.
ToChaincodeArgs
(
ibtp
.
From
,
strconv
.
FormatUint
(
ibtp
.
Index
,
10
),
pd
.
DstContractId
)
args
=
append
(
args
,
pd
.
Args
...
)
args
:=
util
.
ToChaincodeArgs
(
ibtp
.
From
,
strconv
.
FormatUint
(
ibtp
.
Index
,
10
),
content
.
DstContractId
)
args
=
append
(
args
,
content
.
Args
...
)
request
:=
channel
.
Request
{
ChaincodeID
:
c
.
meta
.
CCID
,
Fcn
:
pd
.
Func
,
Fcn
:
content
.
Func
,
Args
:
args
,
}
...
...
@@ -271,7 +275,7 @@ func (c *Client) SubmitIBTP(ibtp *pb.IBTP) (*model.PluginResponse, error) {
ret
.
Message
=
response
.
Message
// If no callback function to invoke, then simply return
if
pd
.
Callback
==
""
{
if
content
.
Callback
==
""
{
return
ret
,
nil
}
...
...
@@ -280,9 +284,9 @@ func (c *Client) SubmitIBTP(ibtp *pb.IBTP) (*model.PluginResponse, error) {
return
ret
,
err
}
switch
pd
.
Func
{
switch
content
.
Func
{
case
"interchainGet"
:
newArgs
=
append
(
newArgs
,
pd
.
Args
[
0
])
newArgs
=
append
(
newArgs
,
content
.
Args
[
0
])
newArgs
=
append
(
newArgs
,
result
...
)
case
"interchainCharge"
:
newArgs
=
append
(
newArgs
,
[]
byte
(
"false"
))
...
...
consumer.go
View file @
fdcd26a1
...
...
@@ -4,8 +4,8 @@ import (
"fmt"
"path/filepath"
"github.com/hyperledger/fabric
/protos
/common"
"github.com/hyperledger/fabric
/protos
/peer"
"github.com/hyperledger/fabric
-protos-go
/common"
"github.com/hyperledger/fabric
-protos-go
/peer"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
...
...
event.go
View file @
fdcd26a1
...
...
@@ -43,13 +43,21 @@ func (ev *Event) encryptPayload() ([]byte, error) {
for
_
,
a
:=
range
as
{
args
=
append
(
args
,
[]
byte
(
a
))
}
ibtppd
:=
&
pb
.
Payload
{
content
:=
&
pb
.
Content
{
SrcContractId
:
ev
.
SrcContractID
,
DstContractId
:
ev
.
DstContractID
,
Func
:
ev
.
Func
,
Args
:
args
,
Callback
:
ev
.
Callback
,
}
data
,
err
:=
content
.
Marshal
()
if
err
!=
nil
{
return
nil
,
err
}
ibtppd
:=
&
pb
.
Payload
{
Content
:
data
,
}
return
ibtppd
.
Marshal
()
}
...
...
example/broker/broker.go
View file @
fdcd26a1
...
...
@@ -6,9 +6,9 @@ import (
"strconv"
"strings"
"github.com/hyperledger/fabric
/core/chaincode/lib
/cid"
"github.com/hyperledger/fabric
/core/chaincode
/shim"
pb
"github.com/hyperledger/fabric
/protos
/peer"
"github.com/hyperledger/fabric
-chaincode-go/pkg
/cid"
"github.com/hyperledger/fabric
-chaincode-go
/shim"
pb
"github.com/hyperledger/fabric
-protos-go
/peer"
)
const
(
...
...
example/broker/data_swapper.go
View file @
fdcd26a1
...
...
@@ -5,9 +5,9 @@ import (
"strconv"
"strings"
"github.com/hyperledger/fabric-chaincode-go/shim"
pb
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb
"github.com/hyperledger/fabric/protos/peer"
)
// get interchain account for transfer contract: setData from,index,tid,name_id,amount
...
...
example/broker/helper.go
View file @
fdcd26a1
...
...
@@ -7,8 +7,8 @@ import (
"strconv"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric
/core/chaincode
/shim"
pb
"github.com/hyperledger/fabric
/protos
/peer"
"github.com/hyperledger/fabric
-chaincode-go
/shim"
pb
"github.com/hyperledger/fabric
-protos-go
/peer"
)
type
response
struct
{
...
...
example/broker/meta.go
View file @
fdcd26a1
package
main
import
(
"github.com/hyperledger/fabric
/core/chaincode
/shim"
pb
"github.com/hyperledger/fabric
/protos
/peer"
"github.com/hyperledger/fabric
-chaincode-go
/shim"
pb
"github.com/hyperledger/fabric
-protos-go
/peer"
)
// getOutMeta
...
...
example/broker/transfer.go
View file @
fdcd26a1
...
...
@@ -6,9 +6,9 @@ import (
"strconv"
"strings"
"github.com/hyperledger/fabric-chaincode-go/shim"
pb
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb
"github.com/hyperledger/fabric/protos/peer"
)
// recharge for transfer contract: charge from,index,tid,name_id,amount
...
...
example/data_swapper/data_swapper.go
View file @
fdcd26a1
...
...
@@ -4,9 +4,9 @@ import (
"fmt"
"strings"
"github.com/hyperledger/fabric-chaincode-go/shim"
pb
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb
"github.com/hyperledger/fabric/protos/peer"
)
const
(
...
...
example/transfer/helper.go
View file @
fdcd26a1
...
...
@@ -4,7 +4,7 @@ import (
"fmt"
"strconv"
"github.com/hyperledger/fabric
/core/chaincode
/shim"
"github.com/hyperledger/fabric
-chaincode-go
/shim"
)
func
getUint64
(
stub
shim
.
ChaincodeStubInterface
,
key
string
)
(
uint64
,
error
)
{
...
...
example/transfer/transfer.go
View file @
fdcd26a1
...
...
@@ -5,9 +5,9 @@ import (
"strconv"
"strings"
"github.com/hyperledger/fabric-chaincode-go/shim"
pb
"github.com/hyperledger/fabric-protos-go/peer"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb
"github.com/hyperledger/fabric/protos/peer"
)
const
(
...
...
go.mod
View file @
fdcd26a1
...
...
@@ -3,30 +3,28 @@ module github.com/meshplus/pier-client-fabric
go 1.13
require (
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
github.com/Rican7/retry v0.1.0
github.com/Shopify/sarama v1.26.1 // indirect
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004
github.com/fsouza/go-dockerclient v1.6.3 // indirect
github.com/golang/protobuf v1.3.2
github.com/golang/protobuf v1.4.0
github.com/golangci/golangci-lint v1.23.0 // indirect
github.com/google/certificate-transparency-go v1.1.0 // indirect
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/hyperledger/fabric v1.4.6
github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a // indirect
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-kit v1.0.
0-rc1
github.com/meshplus/bitxhub-model v1.0.0-rc
2
github.com/meshplus/bitxhub-kit v1.0.
1-0.20200511122821-bc96b0c1f6c7
github.com/meshplus/bitxhub-model v1.0.0-rc
4.0.20200429111056-62b55c3d4260
github.com/meshplus/pier v0.0.0-00010101000000-000000000000
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/sirupsen/logrus v1.5.0
github.com/spf13/viper v1.6.1
github.com/sykesm/zap-logfmt v0.0.3 // indirect
)
replace github.com/golang/protobuf => github.com/golang/protobuf v1.3.2
replace google.golang.org/grpc => google.golang.org/grpc v1.28.1
replace gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.2.7
replace golang.org/x/net => golang.org/x/net v0.0.0-20200202094626-16171245cfb2
...
...
go.sum
View file @
fdcd26a1
This diff is collapsed.
Click to expand it.
receipt.go
View file @
fdcd26a1
...
...
@@ -7,34 +7,47 @@ import (
"github.com/meshplus/bitxhub-model/pb"
)
func
(
c
*
Client
)
generateCallback
(
toExecute
*
pb
.
IBTP
,
args
[][]
byte
,
proof
[]
byte
)
(
result
*
pb
.
IBTP
,
err
error
)
{
if
toExecute
==
nil
{
func
(
c
*
Client
)
generateCallback
(
original
*
pb
.
IBTP
,
args
[][]
byte
,
proof
[]
byte
)
(
result
*
pb
.
IBTP
,
err
error
)
{
if
original
==
nil
{
return
nil
,
fmt
.
Errorf
(
"got nil ibtp to generate receipt: %w"
,
err
)
}
pd
:=
&
pb
.
Payload
{}
if
err
:=
pd
.
Unmarshal
(
toExecute
.
Payload
);
err
!=
nil
{
if
err
:=
pd
.
Unmarshal
(
original
.
Payload
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"ibtp payload unmarshal: %w"
,
err
)
}
pdb
:=
&
pb
.
Payload
{
SrcContractId
:
pd
.
DstContractId
,
DstContractId
:
pd
.
SrcContractId
,
Func
:
pd
.
Callback
,
originalContent
:=
&
pb
.
Content
{}
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
,
Func
:
originalContent
.
Callback
,
Args
:
args
,
}
b
,
err
:=
pdb
.
Marshal
()
b
,
err
:=
content
.
Marshal
()
if
err
!=
nil
{
return
nil
,
err
}
retPd
:=
&
pb
.
Payload
{
Content
:
b
,
}
pdb
,
err
:=
retPd
.
Marshal
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
pb
.
IBTP
{
From
:
toExecute
.
From
,
To
:
toExecute
.
To
,
Index
:
toExecute
.
Index
,
From
:
original
.
From
,
To
:
original
.
To
,
Index
:
original
.
Index
,
Type
:
pb
.
IBTP_RECEIPT
,
Timestamp
:
time
.
Now
()
.
UnixNano
(),
Proof
:
proof
,
Payload
:
b
,
Version
:
toExecute
.
Version
,
Payload
:
pd
b
,
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