Skip to content

fix the status for easier debug #803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions common/constant/statuses.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var (
BlockchainStatusReceivingBlock = 3
BlockchainStatusSyncingBlock = 4
// BlockchainSendingBlockTransactions needs blockchain lock because transactions are tightly coupled of what blocks the node has
BlockchainSendingBlockTransactions = 5
BlockchainSendingBlocks = 6
BlockchainSendingBlockTransactions = 5
BlockchainSendingBlocks = 6
BlockchainStatusReceivingBlockScanBlockPool = 7
BlockchainStatusReceivingBlockProcessCompletedBlock = 8
)
4 changes: 2 additions & 2 deletions core/blockchainsync/blockchainSync.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (bss *BlockchainSyncService) getMoreBlocks() {
errCasted.Message)
default:
monitoring.IncrementMainchainDownloadCycleDebugger(bss.ChainType, 7)
bss.Logger.Infof("failed to getPeerBlockchainInfo: %v", err)
bss.Logger.Infof("ChainSync: failed to getPeerBlockchainInfo: %v", err)
}
}

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

Expand Down
12 changes: 6 additions & 6 deletions core/service/blockMainService.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ func (bs *BlockService) ChainWriteLock(actionType int) {

// ChainWriteUnlock unlocks the chain
func (bs *BlockService) ChainWriteUnlock(actionType int) {
monitoring.SetBlockchainStatus(bs.Chaintype, constant.BlockchainStatusIdle)
monitoring.DecrementStatusLockCounter(bs.Chaintype, actionType)
bs.Unlock()
monitoring.DecrementStatusLockCounter(bs.Chaintype, actionType)
monitoring.SetBlockchainStatus(bs.Chaintype, constant.BlockchainStatusIdle)
}

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

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

// ProcessCompletedBlock to process block that already having all needed transactions
func (bs *BlockService) ProcessCompletedBlock(block *model.Block) error {
bs.ChainWriteLock(constant.BlockchainStatusReceivingBlock)
defer bs.ChainWriteUnlock(constant.BlockchainStatusReceivingBlock)
bs.ChainWriteLock(constant.BlockchainStatusReceivingBlockProcessCompletedBlock)
defer bs.ChainWriteUnlock(constant.BlockchainStatusReceivingBlockProcessCompletedBlock)
lastBlock, err := bs.GetLastBlock()
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions core/service/blockSpineService.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ func (bs *BlockSpineService) ChainWriteLock(actionType int) {

// ChainWriteUnlock unlocks the chain
func (bs *BlockSpineService) ChainWriteUnlock(actionType int) {
monitoring.SetBlockchainStatus(bs.Chaintype, constant.BlockchainStatusIdle)
monitoring.DecrementStatusLockCounter(bs.Chaintype, actionType)
bs.Unlock()
monitoring.DecrementStatusLockCounter(bs.Chaintype, actionType)
monitoring.SetBlockchainStatus(bs.Chaintype, constant.BlockchainStatusIdle)
}

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