LWW Register Merge
LWW Register Merge
A Last-Write-Wins (LWW) register stores a value with a timestamp and node ID. To merge two registers:
- The higher timestamp wins.
- If timestamps are equal, the higher
NodeIDwins.
Return the merged register.
Types
type LWW struct {
Value string
Timestamp int64
NodeID int
}
Function signature
func MergeLWW(a, b LWW) LWW
Example
a = {Value:"x", Timestamp:10, NodeID:1}
b = {Value:"y", Timestamp:10, NodeID:2}
output = b
Run tests to see results
No issues detected