internal/ethapi/api: In GetQuorumPayload, return error if PrivateTransactionManager is not enabled (rather than panic)

This commit is contained in:
Patrick Mylund Nielsen 2016-12-02 10:27:39 -05:00
parent 4b3acd454c
commit 45d697ec31
1 changed files with 15 additions and 15 deletions

View File

@ -467,21 +467,21 @@ func (s *PublicBlockChainAPI) GetUncleCountByBlockHash(ctx context.Context, bloc
// GetQuorumPayload returns the contents of a private transaction
func (s *PublicBlockChainAPI) GetQuorumPayload(digestHex string) (string, error) {
if private.P == nil {
panic("PublicBlockChainApi.GetQuorumPayload: PrivateTransactionManager is not enabled")
}
b, err := hex.DecodeString(digestHex)
if err != nil {
return "", err
}
if len(b) != 64 {
return "", fmt.Errorf("Expected a Quorum digest of length 64, but got %d", len(b))
}
data, err := private.P.Receive(b)
if err != nil {
return "", err
}
return fmt.Sprintf("0x%x", data), nil
if private.P == nil {
return "", fmt.Errorf("PrivateTransactionManager is not enabled")
}
b, err := hex.DecodeString(digestHex)
if err != nil {
return "", err
}
if len(b) != 64 {
return "", fmt.Errorf("Expected a Quorum digest of length 64, but got %d", len(b))
}
data, err := private.P.Receive(b)
if err != nil {
return "", err
}
return fmt.Sprintf("0x%x", data), nil
}
// GetCode returns the code stored at the given address in the state for the given block number.