Skip to content

Commit b476890

Browse files
authored
fix the status for easier debug (#803)
fix the status for easier debug (#803)
1 parent 08d73cc commit b476890

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

common/constant/statuses.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ var (
66
BlockchainStatusReceivingBlock = 3
77
BlockchainStatusSyncingBlock = 4
88
// BlockchainSendingBlockTransactions needs blockchain lock because transactions are tightly coupled of what blocks the node has
9-
BlockchainSendingBlockTransactions = 5
10-
BlockchainSendingBlocks = 6
9+
BlockchainSendingBlockTransactions = 5
10+
BlockchainSendingBlocks = 6
11+
BlockchainStatusReceivingBlockScanBlockPool = 7
12+
BlockchainStatusReceivingBlockProcessCompletedBlock = 8
1113
)

core/blockchainsync/blockchainSync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (bss *BlockchainSyncService) getMoreBlocks() {
138138
errCasted.Message)
139139
default:
140140
monitoring.IncrementMainchainDownloadCycleDebugger(bss.ChainType, 7)
141-
bss.Logger.Infof("failed to getPeerBlockchainInfo: %v", err)
141+
bss.Logger.Infof("ChainSync: failed to getPeerBlockchainInfo: %v", err)
142142
}
143143
}
144144

@@ -151,7 +151,7 @@ func (bss *BlockchainSyncService) getMoreBlocks() {
151151
monitoring.IncrementMainchainDownloadCycleDebugger(bss.ChainType, 10)
152152
if err != nil {
153153
monitoring.IncrementMainchainDownloadCycleDebugger(bss.ChainType, 11)
154-
bss.Logger.Warnf("\nfailed to DownloadFromPeer: %v\n\n", err)
154+
bss.Logger.Warnf("ChainSync: failed to DownloadFromPeer: %v\n\n", err)
155155
break
156156
}
157157

core/service/blockMainService.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ func (bs *BlockService) ChainWriteLock(actionType int) {
217217

218218
// ChainWriteUnlock unlocks the chain
219219
func (bs *BlockService) ChainWriteUnlock(actionType int) {
220-
monitoring.SetBlockchainStatus(bs.Chaintype, constant.BlockchainStatusIdle)
221-
monitoring.DecrementStatusLockCounter(bs.Chaintype, actionType)
222220
bs.Unlock()
221+
monitoring.DecrementStatusLockCounter(bs.Chaintype, actionType)
222+
monitoring.SetBlockchainStatus(bs.Chaintype, constant.BlockchainStatusIdle)
223223
}
224224

225225
// NewGenesisBlock create new block that is fixed in the value of cumulative difficulty, smith scale, and the block signature
@@ -638,8 +638,8 @@ func (bs *BlockService) PushBlock(previousBlock, block *model.Block, broadcast,
638638

639639
// ScanBlockPool scan the whole block pool to check if there are any block that's legal to be pushed yet
640640
func (bs *BlockService) ScanBlockPool() error {
641-
bs.ChainWriteLock(constant.BlockchainStatusReceivingBlock)
642-
defer bs.ChainWriteUnlock(constant.BlockchainStatusReceivingBlock)
641+
bs.ChainWriteLock(constant.BlockchainStatusReceivingBlockScanBlockPool)
642+
defer bs.ChainWriteUnlock(constant.BlockchainStatusReceivingBlockScanBlockPool)
643643
previousBlock, err := bs.GetLastBlock()
644644
if err != nil {
645645
return err
@@ -1478,8 +1478,8 @@ func (bs *BlockService) WillSmith(
14781478

14791479
// ProcessCompletedBlock to process block that already having all needed transactions
14801480
func (bs *BlockService) ProcessCompletedBlock(block *model.Block) error {
1481-
bs.ChainWriteLock(constant.BlockchainStatusReceivingBlock)
1482-
defer bs.ChainWriteUnlock(constant.BlockchainStatusReceivingBlock)
1481+
bs.ChainWriteLock(constant.BlockchainStatusReceivingBlockProcessCompletedBlock)
1482+
defer bs.ChainWriteUnlock(constant.BlockchainStatusReceivingBlockProcessCompletedBlock)
14831483
lastBlock, err := bs.GetLastBlock()
14841484
if err != nil {
14851485
return err

core/service/blockSpineService.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ func (bs *BlockSpineService) ChainWriteLock(actionType int) {
150150

151151
// ChainWriteUnlock unlocks the chain
152152
func (bs *BlockSpineService) ChainWriteUnlock(actionType int) {
153-
monitoring.SetBlockchainStatus(bs.Chaintype, constant.BlockchainStatusIdle)
154-
monitoring.DecrementStatusLockCounter(bs.Chaintype, actionType)
155153
bs.Unlock()
154+
monitoring.DecrementStatusLockCounter(bs.Chaintype, actionType)
155+
monitoring.SetBlockchainStatus(bs.Chaintype, constant.BlockchainStatusIdle)
156156
}
157157

158158
// NewGenesisBlock create new block that is fixed in the value of cumulative difficulty, smith scale, and the block signature

0 commit comments

Comments
 (0)