mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 15:04:22 +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:
@@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
"github.com/tendermint/tendermint/p2p"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
@@ -244,7 +244,7 @@ func sendProposalAndParts(
|
||||
// byzantine consensus reactor
|
||||
|
||||
type ByzantineReactor struct {
|
||||
cmn.Service
|
||||
service.Service
|
||||
reactor *Reactor
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -13,6 +13,7 @@ import (
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/fail"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
@@ -72,7 +73,7 @@ type evidencePool interface {
|
||||
// commits blocks to the chain and executes them against the application.
|
||||
// The internal state machine receives input from peers, the internal validator, and from a timer.
|
||||
type State struct {
|
||||
cmn.BaseService
|
||||
service.BaseService
|
||||
|
||||
// config details
|
||||
config *cfg.ConsensusConfig
|
||||
@@ -174,7 +175,7 @@ func NewState(
|
||||
// Don't call scheduleRound0 yet.
|
||||
// We do that upon Start().
|
||||
cs.reconstructLastCommit(state)
|
||||
cs.BaseService = *cmn.NewBaseService(nil, "State", cs)
|
||||
cs.BaseService = *service.NewBaseService(nil, "State", cs)
|
||||
for _, option := range options {
|
||||
option(cs)
|
||||
}
|
||||
@@ -275,7 +276,7 @@ func (cs *State) LoadCommit(height int64) *types.Commit {
|
||||
return cs.blockStore.LoadBlockCommit(height)
|
||||
}
|
||||
|
||||
// OnStart implements cmn.Service.
|
||||
// OnStart implements service.Service.
|
||||
// It loads the latest state via the WAL, and starts the timeout and receive routines.
|
||||
func (cs *State) OnStart() error {
|
||||
if err := cs.evsw.Start(); err != nil {
|
||||
@@ -351,7 +352,7 @@ func (cs *State) startRoutines(maxSteps int) {
|
||||
go cs.receiveRoutine(maxSteps)
|
||||
}
|
||||
|
||||
// OnStop implements cmn.Service.
|
||||
// OnStop implements service.Service.
|
||||
func (cs *State) OnStop() {
|
||||
cs.evsw.Stop()
|
||||
cs.timeoutTicker.Stop()
|
||||
|
||||
+5
-5
@@ -3,8 +3,8 @@ package consensus
|
||||
import (
|
||||
"time"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -29,7 +29,7 @@ type TimeoutTicker interface {
|
||||
// Timeouts are scheduled along the tickChan,
|
||||
// and fired on the tockChan.
|
||||
type timeoutTicker struct {
|
||||
cmn.BaseService
|
||||
service.BaseService
|
||||
|
||||
timer *time.Timer
|
||||
tickChan chan timeoutInfo // for scheduling timeouts
|
||||
@@ -43,12 +43,12 @@ func NewTimeoutTicker() TimeoutTicker {
|
||||
tickChan: make(chan timeoutInfo, tickTockBufferSize),
|
||||
tockChan: make(chan timeoutInfo, tickTockBufferSize),
|
||||
}
|
||||
tt.BaseService = *cmn.NewBaseService(nil, "TimeoutTicker", tt)
|
||||
tt.BaseService = *service.NewBaseService(nil, "TimeoutTicker", tt)
|
||||
tt.stopTimer() // don't want to fire until the first scheduled timeout
|
||||
return tt
|
||||
}
|
||||
|
||||
// OnStart implements cmn.Service. It starts the timeout routine.
|
||||
// OnStart implements service.Service. It starts the timeout routine.
|
||||
func (t *timeoutTicker) OnStart() error {
|
||||
|
||||
go t.timeoutRoutine()
|
||||
@@ -56,7 +56,7 @@ func (t *timeoutTicker) OnStart() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnStop implements cmn.Service. It stops the timeout routine.
|
||||
// OnStop implements service.Service. It stops the timeout routine.
|
||||
func (t *timeoutTicker) OnStop() {
|
||||
t.BaseService.OnStop()
|
||||
t.stopTimer()
|
||||
|
||||
+3
-2
@@ -14,6 +14,7 @@ import (
|
||||
auto "github.com/tendermint/tendermint/libs/autofile"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
tmtime "github.com/tendermint/tendermint/types/time"
|
||||
)
|
||||
@@ -78,7 +79,7 @@ type WAL interface {
|
||||
// so it's either reading or appending - must read to end to start appending
|
||||
// again.
|
||||
type baseWAL struct {
|
||||
cmn.BaseService
|
||||
service.BaseService
|
||||
|
||||
group *auto.Group
|
||||
|
||||
@@ -107,7 +108,7 @@ func NewWAL(walFile string, groupOptions ...func(*auto.Group)) (*baseWAL, error)
|
||||
enc: NewWALEncoder(group),
|
||||
flushInterval: walDefaultFlushInterval,
|
||||
}
|
||||
wal.BaseService = *cmn.NewBaseService(nil, "baseWAL", wal)
|
||||
wal.BaseService = *service.NewBaseService(nil, "baseWAL", wal)
|
||||
return wal, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user