2019-10-09 14:22:53 +00:00
|
|
|
package gethbridge
|
|
|
|
|
|
|
|
import (
|
2019-11-21 16:19:22 +00:00
|
|
|
whispertypes "github.com/status-im/status-go/protocol/transport/whisper/types"
|
|
|
|
protocol "github.com/status-im/status-go/protocol/types"
|
2019-10-09 14:22:53 +00:00
|
|
|
whisper "github.com/status-im/whisper/whisperv6"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewGethEnvelopeErrorWrapper returns a whispertypes.EnvelopeError object that mimics Geth's EnvelopeError
|
|
|
|
func NewGethEnvelopeErrorWrapper(envelopeError *whisper.EnvelopeError) *whispertypes.EnvelopeError {
|
|
|
|
if envelopeError == nil {
|
|
|
|
panic("envelopeError should not be nil")
|
|
|
|
}
|
|
|
|
|
|
|
|
return &whispertypes.EnvelopeError{
|
2019-11-21 16:19:22 +00:00
|
|
|
Hash: protocol.Hash(envelopeError.Hash),
|
2019-10-09 14:22:53 +00:00
|
|
|
Code: mapGethErrorCode(envelopeError.Code),
|
|
|
|
Description: envelopeError.Description,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func mapGethErrorCode(code uint) uint {
|
|
|
|
switch code {
|
|
|
|
case whisper.EnvelopeTimeNotSynced:
|
|
|
|
return whispertypes.EnvelopeTimeNotSynced
|
|
|
|
case whisper.EnvelopeOtherError:
|
|
|
|
return whispertypes.EnvelopeOtherError
|
|
|
|
}
|
|
|
|
return whispertypes.EnvelopeOtherError
|
|
|
|
}
|