fix(api): fix panic when subscribe pid is nil

This commit is contained in:
Alexader 2021-01-22 10:37:31 +08:00
parent cb59bacb0f
commit 67ab607e88
1 changed files with 6 additions and 0 deletions

View File

@ -26,8 +26,14 @@ func (cbs *ChainBrokerService) Subscribe(req *pb.SubscriptionRequest, server pb.
case pb.SubscriptionRequest_BLOCK_HEADER.String():
return cbs.handleBlockHeaderSubscription(server)
case pb.SubscriptionRequest_INTERCHAIN_TX_WRAPPER.String():
if !types.IsValidAddressByte(req.Extra) {
return fmt.Errorf("invalid pier address to subscribe")
}
return cbs.handleInterchainTxWrapperSubscription(server, types.NewAddressByStr(string(req.Extra)).String(), false)
case pb.SubscriptionRequest_UNION_INTERCHAIN_TX_WRAPPER.String():
if !types.IsValidAddressByte(req.Extra) {
return fmt.Errorf("invalid pier address to subscribe")
}
return cbs.handleInterchainTxWrapperSubscription(server, types.NewAddressByStr(string(req.Extra)).String(), true)
}