Merge pull request #320 from meshplus/fix/subscribe-nil-pier

fix(api): fix panic when subscribe pid is nil
This commit is contained in:
Alexader 2021-01-25 14:04:53 +08:00 committed by GitHub
commit c75adafb2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
}