diff --git a/client.go b/client.go index dab96f3..4f3ee60 100755 --- a/client.go +++ b/client.go @@ -1,15 +1,17 @@ +//nolint:dupl,unparam package main import ( "encoding/binary" "encoding/json" "fmt" - "github.com/meshplus/bitxhub-core/agency" "os" "strconv" "strings" "time" + "github.com/meshplus/bitxhub-core/agency" + "github.com/Rican7/retry" "github.com/Rican7/retry/strategy" "github.com/golang/protobuf/proto" @@ -129,10 +131,7 @@ func (c *Client) Initialize(configPath string, extra []byte, mode string) error // m = make(map[string]*pb.Interchain) // } - mgh, err := newFabricHandler(contractmeta.EventFilter, eventC) - if err != nil { - return err - } + mgh := newFabricHandler(contractmeta.EventFilter, eventC) done := make(chan bool) csm, err := NewConsumer(configPath, contractmeta, mgh, done) @@ -316,6 +315,7 @@ func (c *Client) getProof(response channel.Response) ([]byte, error) { return nil }, strategy.Wait(2*time.Second)); err != nil { logger.Error("Can't get proof", "error", err.Error()) + return nil, err } return proof, nil @@ -400,6 +400,9 @@ func (c *Client) SubmitIBTP(from string, index uint64, serviceID string, ibtpTyp destFullID := c.bitxhubID + ":" + c.appchainID + ":" + serviceID servicePair := from + "-" + destFullID ibtp, err := c.GetReceiptMessage(servicePair, index) + if err != nil { + return nil, err + } ret.Result = ibtp return ret, nil @@ -891,11 +894,11 @@ type handler struct { ID string } -func newFabricHandler(eventFilter string, eventC chan *pb.IBTP) (*handler, error) { +func newFabricHandler(eventFilter string, eventC chan *pb.IBTP) *handler { return &handler{ eventC: eventC, eventFilter: eventFilter, - }, nil + } } func (h *handler) HandleMessage(deliveries *fab.CCEvent, payload []byte) { @@ -910,14 +913,14 @@ func (h *handler) HandleMessage(deliveries *fab.CCEvent, payload []byte) { } } -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) - } +// 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 -} +// return splits[0], splits[1], splits[2], nil +// } func parseServicePair(servicePair string) (string, string, error) { splits := strings.Split(servicePair, "-") @@ -928,9 +931,9 @@ func parseServicePair(servicePair string) (string, string, error) { return splits[0], splits[1], nil } -func genServicePair(from, to string) string { - return fmt.Sprintf("%s-%s", from, to) -} +// func genServicePair(from, to string) string { +// return fmt.Sprintf("%s-%s", from, to) +// } func (c *Client) GetOffChainData(request *pb.GetDataRequest) (*pb.OffChainDataInfo, error) { //TODO implement me diff --git a/consumer.go b/consumer.go index 9d1e1b7..d46bdf1 100755 --- a/consumer.go +++ b/consumer.go @@ -1,3 +1,4 @@ +//nolint:unparam package main import ( diff --git a/event.go b/event.go index a311a57..e3f4907 100644 --- a/event.go +++ b/event.go @@ -1,8 +1,6 @@ package main import ( - "strings" - "github.com/cloudflare/cfssl/log" "github.com/ethereum/go-ethereum/crypto" "github.com/meshplus/bitxhub-model/pb" @@ -34,14 +32,14 @@ func (ev *Event) Convert2IBTP(timeoutHeight int64, ibtpType pb.IBTP_Type) *pb.IB } } -func handleArgs(args string) [][]byte { - argsBytes := make([][]byte, 0) - as := strings.Split(args, ",") - for _, a := range as { - argsBytes = append(argsBytes, []byte(a)) - } - return argsBytes -} +// func handleArgs(args string) [][]byte { +// argsBytes := make([][]byte, 0) +// as := strings.Split(args, ",") +// for _, a := range as { +// argsBytes = append(argsBytes, []byte(a)) +// } +// return argsBytes +// } func (ev *Event) encryptPayload() ([]byte, error) { content := &pb.Content{ diff --git a/receipt.go b/receipt.go index 51a1abf..e7c336a 100644 --- a/receipt.go +++ b/receipt.go @@ -1,3 +1,4 @@ +//nolint:unparam package main import ( diff --git a/verify.go b/verify.go index 3fb6b81..0a2b29f 100644 --- a/verify.go +++ b/verify.go @@ -1,8 +1,8 @@ +//nolint:unparam package main import ( "context" - "encoding/binary" "encoding/json" "fmt" "math/big" @@ -145,10 +145,10 @@ func addressArrayContains(addrs []string, address []byte) bool { return false } -func uint64ToBytesInBigEndian(i uint64) []byte { - bytes := make([]byte, 8) +// func uint64ToBytesInBigEndian(i uint64) []byte { +// bytes := make([]byte, 8) - binary.BigEndian.PutUint64(bytes, i) +// binary.BigEndian.PutUint64(bytes, i) - return bytes -} +// return bytes +// }