mirror of
https://github.com/tendermint/tendermint.git
synced 2026-10-01 12:15:45 +00:00
libs/common: refactor libs common 3 (#4232)
* libs/common: refactor libs common 3 - move nil.go into types folder and make private - move service & baseservice out of common into service pkg ref #4147 Signed-off-by: Marko Baricevic <marbar3778@yahoo.com> * add changelog entry
This commit is contained in:
@@ -3,8 +3,8 @@ package privval
|
||||
import (
|
||||
"time"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -56,7 +56,7 @@ func NewSignerDialerEndpoint(
|
||||
maxConnRetries: defaultMaxDialRetries,
|
||||
}
|
||||
|
||||
sd.BaseService = *cmn.NewBaseService(logger, "SignerDialerEndpoint", sd)
|
||||
sd.BaseService = *service.NewBaseService(logger, "SignerDialerEndpoint", sd)
|
||||
sd.signerEndpoint.timeoutReadWrite = defaultTimeoutReadWriteSeconds * time.Second
|
||||
|
||||
return sd
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,7 +16,7 @@ const (
|
||||
)
|
||||
|
||||
type signerEndpoint struct {
|
||||
cmn.BaseService
|
||||
service.BaseService
|
||||
|
||||
connMtx sync.Mutex
|
||||
conn net.Conn
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
)
|
||||
|
||||
// SignerValidatorEndpointOption sets an optional parameter on the SocketVal.
|
||||
@@ -38,12 +38,12 @@ func NewSignerListenerEndpoint(
|
||||
timeoutAccept: defaultTimeoutAcceptSeconds * time.Second,
|
||||
}
|
||||
|
||||
sc.BaseService = *cmn.NewBaseService(logger, "SignerListenerEndpoint", sc)
|
||||
sc.BaseService = *service.NewBaseService(logger, "SignerListenerEndpoint", sc)
|
||||
sc.signerEndpoint.timeoutReadWrite = defaultTimeoutReadWriteSeconds * time.Second
|
||||
return sc
|
||||
}
|
||||
|
||||
// OnStart implements cmn.Service.
|
||||
// OnStart implements service.Service.
|
||||
func (sl *SignerListenerEndpoint) OnStart() error {
|
||||
sl.connectRequestCh = make(chan struct{})
|
||||
sl.connectionAvailableCh = make(chan net.Conn)
|
||||
@@ -58,7 +58,7 @@ func (sl *SignerListenerEndpoint) OnStart() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnStop implements cmn.Service
|
||||
// OnStop implements service.Service
|
||||
func (sl *SignerListenerEndpoint) OnStop() {
|
||||
sl.instanceMtx.Lock()
|
||||
defer sl.instanceMtx.Unlock()
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ type ValidationRequestHandlerFunc func(
|
||||
chainID string) (SignerMessage, error)
|
||||
|
||||
type SignerServer struct {
|
||||
cmn.BaseService
|
||||
service.BaseService
|
||||
|
||||
endpoint *SignerDialerEndpoint
|
||||
chainID string
|
||||
@@ -33,18 +33,18 @@ func NewSignerServer(endpoint *SignerDialerEndpoint, chainID string, privVal typ
|
||||
validationRequestHandler: DefaultValidationRequestHandler,
|
||||
}
|
||||
|
||||
ss.BaseService = *cmn.NewBaseService(endpoint.Logger, "SignerServer", ss)
|
||||
ss.BaseService = *service.NewBaseService(endpoint.Logger, "SignerServer", ss)
|
||||
|
||||
return ss
|
||||
}
|
||||
|
||||
// OnStart implements cmn.Service.
|
||||
// OnStart implements service.Service.
|
||||
func (ss *SignerServer) OnStart() error {
|
||||
go ss.serviceLoop()
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnStop implements cmn.Service.
|
||||
// OnStop implements service.Service.
|
||||
func (ss *SignerServer) OnStop() {
|
||||
ss.endpoint.Logger.Debug("SignerServer: OnStop calling Close")
|
||||
_ = ss.endpoint.Close()
|
||||
|
||||
Reference in New Issue
Block a user