2021-05-25 01:02:01 +00:00
|
|
|
package migration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/pkg/errors"
|
2021-06-02 23:49:52 +00:00
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1"
|
2021-08-11 20:12:22 +00:00
|
|
|
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
2021-05-25 01:02:01 +00:00
|
|
|
)
|
|
|
|
|
2021-08-11 20:12:22 +00:00
|
|
|
func V1Alpha1ConnectionStateToV1(connState eth.ConnectionState) ethpb.ConnectionState {
|
2021-05-25 01:02:01 +00:00
|
|
|
alphaString := connState.String()
|
|
|
|
v1Value := ethpb.ConnectionState_value[alphaString]
|
|
|
|
return ethpb.ConnectionState(v1Value)
|
|
|
|
}
|
|
|
|
|
2021-08-11 20:12:22 +00:00
|
|
|
func V1Alpha1PeerDirectionToV1(peerDirection eth.PeerDirection) (ethpb.PeerDirection, error) {
|
2021-05-25 01:02:01 +00:00
|
|
|
alphaString := peerDirection.String()
|
2021-08-11 20:12:22 +00:00
|
|
|
if alphaString == eth.PeerDirection_UNKNOWN.String() {
|
2021-05-25 01:02:01 +00:00
|
|
|
return 0, errors.New("peer direction unknown")
|
|
|
|
}
|
|
|
|
v1Value := ethpb.PeerDirection_value[alphaString]
|
|
|
|
return ethpb.PeerDirection(v1Value), nil
|
|
|
|
}
|