mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
44 lines
1015 B
Go
44 lines
1015 B
Go
|
package validator_helpers
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"google.golang.org/grpc"
|
||
|
)
|
||
|
|
||
|
// Use an interface with a private dummy function to force all other packages to call NewNodeConnection
|
||
|
type NodeConnection interface {
|
||
|
GetGrpcClientConn() *grpc.ClientConn
|
||
|
GetBeaconApiUrl() string
|
||
|
GetBeaconApiTimeout() time.Duration
|
||
|
dummy()
|
||
|
}
|
||
|
|
||
|
type nodeConnection struct {
|
||
|
grpcClientConn *grpc.ClientConn
|
||
|
beaconApiUrl string
|
||
|
beaconApiTimeout time.Duration
|
||
|
}
|
||
|
|
||
|
func (c *nodeConnection) GetGrpcClientConn() *grpc.ClientConn {
|
||
|
return c.grpcClientConn
|
||
|
}
|
||
|
|
||
|
func (c *nodeConnection) GetBeaconApiUrl() string {
|
||
|
return c.beaconApiUrl
|
||
|
}
|
||
|
|
||
|
func (c *nodeConnection) GetBeaconApiTimeout() time.Duration {
|
||
|
return c.beaconApiTimeout
|
||
|
}
|
||
|
|
||
|
func (*nodeConnection) dummy() {}
|
||
|
|
||
|
func NewNodeConnection(grpcConn *grpc.ClientConn, beaconApiUrl string, beaconApiTimeout time.Duration) NodeConnection {
|
||
|
conn := &nodeConnection{}
|
||
|
conn.grpcClientConn = grpcConn
|
||
|
conn.beaconApiUrl = beaconApiUrl
|
||
|
conn.beaconApiTimeout = beaconApiTimeout
|
||
|
return conn
|
||
|
}
|