Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'network-clock-improve' into 'master'
Network clock improve See merge request open-platform/chain!245
- Loading branch information
Showing
29 changed files
with
315 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/io/openfuture/chain/core/sync/SyncState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.openfuture.chain.core.sync | ||
|
||
import io.openfuture.chain.core.sync.SyncState.SyncStatusType.NOT_SYNCHRONIZED | ||
import org.springframework.stereotype.Component | ||
import kotlin.math.min | ||
|
||
@Component | ||
class SyncState { | ||
|
||
@Volatile | ||
private var chainStatus: SyncStatusType = NOT_SYNCHRONIZED | ||
|
||
@Volatile | ||
private var clockStatus: SyncStatusType = NOT_SYNCHRONIZED | ||
|
||
|
||
@Synchronized | ||
fun getChainStatus(): SyncStatusType = chainStatus | ||
|
||
@Synchronized | ||
fun getClockStatus(): SyncStatusType = clockStatus | ||
|
||
@Synchronized | ||
fun getNodeStatus(): SyncStatusType = SyncStatusType.values() | ||
.first { min(chainStatus.priority, clockStatus.priority) == it.priority } | ||
|
||
@Synchronized | ||
fun setChainStatus(status: SyncStatusType) { | ||
chainStatus = status | ||
} | ||
|
||
@Synchronized | ||
fun setClockStatus(status: SyncStatusType) { | ||
clockStatus = status | ||
} | ||
|
||
enum class SyncStatusType(val priority: Int) { | ||
SYNCHRONIZED(3), | ||
PROCESSING(2), | ||
NOT_SYNCHRONIZED(1) | ||
} | ||
|
||
} |
27 changes: 0 additions & 27 deletions
27
src/main/kotlin/io/openfuture/chain/core/sync/SyncStatus.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.