@ -129,6 +129,7 @@ type blockStore interface {
type BlockchainReactor struct {
type BlockchainReactor struct {
p2p . BaseReactor
p2p . BaseReactor
fastSync bool // if true, enable fast sync on start
events chan Event // XXX: Rename eventsFromPeers
events chan Event // XXX: Rename eventsFromPeers
scheduler * Routine
scheduler * Routine
processor * Routine
processor * Routine
@ -156,7 +157,7 @@ type blockApplier interface {
// XXX: unify naming in this package around tmState
// XXX: unify naming in this package around tmState
// XXX: V1 stores a copy of state as initialState, which is never mutated. Is that nessesary?
// XXX: V1 stores a copy of state as initialState, which is never mutated. Is that nessesary?
func newReactor ( state state . State , store blockStore , reporter behaviour . Reporter ,
func newReactor ( state state . State , store blockStore , reporter behaviour . Reporter ,
blockApplier blockApplier , bufferSize int ) * BlockchainReactor {
blockApplier blockApplier , bufferSize int , fastSync bool ) * BlockchainReactor {
scheduler := newScheduler ( state . LastBlockHeight , time . Now ( ) )
scheduler := newScheduler ( state . LastBlockHeight , time . Now ( ) )
pContext := newProcessorContext ( store , blockApplier , state )
pContext := newProcessorContext ( store , blockApplier , state )
// TODO: Fix naming to just newProcesssor
// TODO: Fix naming to just newProcesssor
@ -170,6 +171,7 @@ func newReactor(state state.State, store blockStore, reporter behaviour.Reporter
store : store ,
store : store ,
reporter : reporter ,
reporter : reporter ,
logger : log . NewNopLogger ( ) ,
logger : log . NewNopLogger ( ) ,
fastSync : fastSync ,
}
}
}
}
@ -180,7 +182,7 @@ func NewBlockchainReactor(
store blockStore ,
store blockStore ,
fastSync bool ) * BlockchainReactor {
fastSync bool ) * BlockchainReactor {
reporter := behaviour . NewMockReporter ( )
reporter := behaviour . NewMockReporter ( )
return newReactor ( state , store , reporter , blockApplier , 1000 )
return newReactor ( state , store , reporter , blockApplier , 1000 , fastSync )
}
}
// SetSwitch implements Reactor interface.
// SetSwitch implements Reactor interface.
@ -224,9 +226,11 @@ func (r *BlockchainReactor) SetLogger(logger log.Logger) {
// Start implements cmn.Service interface
// Start implements cmn.Service interface
func ( r * BlockchainReactor ) Start ( ) error {
func ( r * BlockchainReactor ) Start ( ) error {
r . reporter = behaviour . NewSwitchReporter ( r . BaseReactor . Switch )
r . reporter = behaviour . NewSwitchReporter ( r . BaseReactor . Switch )
go r . scheduler . start ( )
go r . processor . start ( )
go r . demux ( )
if r . fastSync {
go r . scheduler . start ( )
go r . processor . start ( )
go r . demux ( )
}
return nil
return nil
}
}