Skip to content

Commit

Permalink
rename blockchain to blocksync in certain areas (tendermint#9512)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters authored Oct 6, 2022
1 parent c0bdb24 commit 8d26460
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion blocksync/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestBcStatusResponseMessageValidateBasic(t *testing.T) {
}

//nolint:lll // ignore line length in tests
func TestBlockchainMessageVectors(t *testing.T) {
func TestBlocksyncMessageVectors(t *testing.T) {
block := types.MakeBlock(int64(3), []types.Tx{types.Tx("Hello World")}, nil, nil)
block.Version.Block = 11 // overwrite updated protocol version

Expand Down
2 changes: 1 addition & 1 deletion blocksync/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
)

type consensusReactor interface {
// for when we switch from blockchain reactor and block sync to
// for when we switch from blocksync reactor and block sync to
// the consensus machine
SwitchToConsensus(state sm.State, skipWAL bool)
}
Expand Down
12 changes: 6 additions & 6 deletions blocksync/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ func newReactor(
}

bcReactor := NewReactor(state.Copy(), blockExec, blockStore, fastSync)
bcReactor.SetLogger(logger.With("module", "blockchain"))
bcReactor.SetLogger(logger.With("module", "blocksync"))

return ReactorPair{bcReactor, proxyApp}
}

func TestNoBlockResponse(t *testing.T) {
config = test.ResetTestRoot("blockchain_reactor_test")
config = test.ResetTestRoot("blocksync_reactor_test")
defer os.RemoveAll(config.RootDir)
genDoc, privVals := randGenesisDoc(1, false, 30)

Expand All @@ -164,7 +164,7 @@ func TestNoBlockResponse(t *testing.T) {
reactorPairs[1] = newReactor(t, log.TestingLogger(), genDoc, privVals, 0)

p2p.MakeConnectedSwitches(config.P2P, 2, func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[i].reactor)
s.AddReactor("BLOCKSYNC", reactorPairs[i].reactor)
return s

}, p2p.Connect2Switches)
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestNoBlockResponse(t *testing.T) {
// Alternatively we could actually dial a TCP conn but
// that seems extreme.
func TestBadBlockStopsPeer(t *testing.T) {
config = test.ResetTestRoot("blockchain_reactor_test")
config = test.ResetTestRoot("blocksync_reactor_test")
defer os.RemoveAll(config.RootDir)
genDoc, privVals := randGenesisDoc(1, false, 30)

Expand All @@ -239,7 +239,7 @@ func TestBadBlockStopsPeer(t *testing.T) {
reactorPairs[3] = newReactor(t, log.TestingLogger(), genDoc, privVals, 0)

switches := p2p.MakeConnectedSwitches(config.P2P, 4, func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[i].reactor)
s.AddReactor("BLOCKSYNC", reactorPairs[i].reactor)
return s

}, p2p.Connect2Switches)
Expand Down Expand Up @@ -278,7 +278,7 @@ func TestBadBlockStopsPeer(t *testing.T) {
reactorPairs = append(reactorPairs, lastReactorPair)

switches = append(switches, p2p.MakeConnectedSwitches(config.P2P, 1, func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("BLOCKCHAIN", reactorPairs[len(reactorPairs)-1].reactor)
s.AddReactor("BLOCKSYNC", reactorPairs[len(reactorPairs)-1].reactor)
return s

}, p2p.Connect2Switches)...)
Expand Down
2 changes: 1 addition & 1 deletion node/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To replace the built-in p2p.Reactor, use the CustomReactors option:
dbProvider,
metricsProvider,
logger,
CustomReactors(map[string]p2p.Reactor{"BLOCKCHAIN": customBlockchainReactor}),
CustomReactors(map[string]p2p.Reactor{"BLOCKSYNC": customBlocksyncReactor}),
)
The list of existing reactors can be found in CustomReactors documentation.
Expand Down
18 changes: 9 additions & 9 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ type blockSyncReactor interface {
// result in replacing it with the custom one.
//
// - MEMPOOL
// - BLOCKCHAIN
// - BLOCKSYNC
// - CONSENSUS
// - EVIDENCE
// - PEX
Expand Down Expand Up @@ -441,7 +441,7 @@ func createEvidenceReactor(config *cfg.Config, dbProvider DBProvider,
return evidenceReactor, evidencePool, nil
}

func createBlockchainReactor(config *cfg.Config,
func createBlocksyncReactor(config *cfg.Config,
state sm.State,
blockExec *sm.BlockExecutor,
blockStore *store.BlockStore,
Expand All @@ -457,7 +457,7 @@ func createBlockchainReactor(config *cfg.Config,
return nil, fmt.Errorf("unknown fastsync version %s", config.BlockSync.Version)
}

bcReactor.SetLogger(logger.With("module", "blockchain"))
bcReactor.SetLogger(logger.With("module", "blocksync"))
return bcReactor, nil
}

Expand Down Expand Up @@ -584,7 +584,7 @@ func createSwitch(config *cfg.Config,
)
sw.SetLogger(p2pLogger)
sw.AddReactor("MEMPOOL", mempoolReactor)
sw.AddReactor("BLOCKCHAIN", bcReactor)
sw.AddReactor("BLOCKSYNC", bcReactor)
sw.AddReactor("CONSENSUS", consensusReactor)
sw.AddReactor("EVIDENCE", evidenceReactor)
sw.AddReactor("STATESYNC", stateSyncReactor)
Expand Down Expand Up @@ -803,7 +803,7 @@ func NewNode(config *cfg.Config,
return nil, err
}

// make block executor for consensus and blockchain reactors to execute blocks
// make block executor for consensus and blocksync reactors to execute blocks
blockExec := sm.NewBlockExecutor(
stateStore,
logger.With("module", "state"),
Expand All @@ -814,10 +814,10 @@ func NewNode(config *cfg.Config,
sm.BlockExecutorWithMetrics(smMetrics),
)

// Make BlockchainReactor. Don't start block sync if we're doing a state sync first.
bcReactor, err := createBlockchainReactor(config, state, blockExec, blockStore, blockSync && !stateSync, logger)
// Make BlocksyncReactor. Don't start block sync if we're doing a state sync first.
bcReactor, err := createBlocksyncReactor(config, state, blockExec, blockStore, blockSync && !stateSync, logger)
if err != nil {
return nil, fmt.Errorf("could not create blockchain reactor: %w", err)
return nil, fmt.Errorf("could not create blocksync reactor: %w", err)
}

// Make ConsensusReactor. Don't enable fully if doing a state sync and/or block sync first.
Expand Down Expand Up @@ -990,7 +990,7 @@ func (n *Node) OnStart() error {
if n.stateSync {
bcR, ok := n.bcReactor.(blockSyncReactor)
if !ok {
return fmt.Errorf("this blockchain reactor does not support switching from state sync")
return fmt.Errorf("this blocksync reactor does not support switching from state sync")
}
err := startStateSync(n.stateSyncReactor, bcR, n.consensusReactor, n.stateSyncProvider,
n.config.StateSync, n.config.BlockSyncMode, n.stateStore, n.blockStore, n.stateSyncGenesis)
Expand Down
8 changes: 4 additions & 4 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func TestNodeNewNodeCustomReactors(t *testing.T) {
RecvMessageCapacity: 100,
},
}
customBlockchainReactor := p2pmock.NewReactor()
customBlocksyncReactor := p2pmock.NewReactor()

nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile())
require.NoError(t, err)
Expand All @@ -440,7 +440,7 @@ func TestNodeNewNodeCustomReactors(t *testing.T) {
DefaultDBProvider,
DefaultMetricsProvider(config.Instrumentation),
log.TestingLogger(),
CustomReactors(map[string]p2p.Reactor{"FOO": cr, "BLOCKCHAIN": customBlockchainReactor}),
CustomReactors(map[string]p2p.Reactor{"FOO": cr, "BLOCKSYNC": customBlocksyncReactor}),
)
require.NoError(t, err)

Expand All @@ -451,8 +451,8 @@ func TestNodeNewNodeCustomReactors(t *testing.T) {
assert.True(t, cr.IsRunning())
assert.Equal(t, cr, n.Switch().Reactor("FOO"))

assert.True(t, customBlockchainReactor.IsRunning())
assert.Equal(t, customBlockchainReactor, n.Switch().Reactor("BLOCKCHAIN"))
assert.True(t, customBlocksyncReactor.IsRunning())
assert.Equal(t, customBlocksyncReactor, n.Switch().Reactor("BLOCKSYNC"))

channels := n.NodeInfo().(p2p.DefaultNodeInfo).Channels
assert.Contains(t, channels, mempl.MempoolChannel)
Expand Down

0 comments on commit 8d26460

Please sign in to comment.