Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion a_main-packr.go

Large diffs are not rendered by default.

408 changes: 220 additions & 188 deletions client.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Fabric struct {
CCID string `toml:"ccid" json:"ccid"`
ChannelId string `mapstructure:"channel_id" toml:"channel_id" json:"channel_id"`
Org string `toml:"org" json:"org"`
ServerPort string `toml:"server_port" json:"server_port"`
TimeoutHeight int64 `mapstructure:"timeout_height" json:"timeout_height"`
}

Expand All @@ -35,7 +36,7 @@ func DefaultConfig() *Config {
Fabric: Fabric{
Name: "fabric",
Username: "Admin",
CCID: "Broker-001",
CCID: "broker",
ChannelId: "mychannel",
Org: "org2",
TimeoutHeight: 30,
Expand Down
39 changes: 20 additions & 19 deletions event.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package main

import (
"fmt"
"strings"

"github.com/cloudflare/cfssl/log"
"github.com/ethereum/go-ethereum/crypto"
"github.com/meshplus/bitxhub-model/pb"
)

type Event struct {
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"`
Index uint64 `json:"index"`
DstFullID string `json:"dst_full_id"`
SrcFullID string `json:"src_full_id"`
Encrypt bool `json:"encrypt"`
CallFunc CallFunc `json:"call_func"`
CallBack CallFunc `json:"callback"`
RollBack CallFunc `json:"rollback"`
}

func (ev *Event) Convert2IBTP(timeoutHeight int64, ibtpType pb.IBTP_Type) *pb.IBTP {
Expand Down Expand Up @@ -44,25 +44,26 @@ 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{
Func: funcSplit[0],
Args: handleArgs(ev.Args),
Callback: funcSplit[1],
ArgsCb: handleArgs(ev.Argscb),
Rollback: funcSplit[2],
ArgsRb: handleArgs(ev.Argsrb),
Func: ev.CallFunc.Func,
Args: ev.CallFunc.Args,
}
data, err := content.Marshal()
if err != nil {
return nil, err
}

var packed []byte
packed = append(packed, []byte(ev.CallFunc.Func)...)
for _, arg := range ev.CallFunc.Args {
packed = append(packed, arg...)
}
hash := crypto.Keccak256(packed)

ibtppd := &pb.Payload{
Content: data,
Encrypted: ev.Encrypt,
Content: data,
Hash: hash,
}
return ibtppd.Marshal()
}
Expand Down
Binary file modified example/contracts.zip
Binary file not shown.
Loading