etcdserver/api/v2store/node.go
func (n *node) Compare(prevValue string, prevIndex uint64) (ok bool, which int) {
	indexMatch := prevIndex == 0 || n.ModifiedIndex == prevIndex
	valueMatch := prevValue == "" || n.Value == prevValue
	ok = valueMatch && indexMatch
	switch {
	case valueMatch && indexMatch:
		which = CompareMatch
	case indexMatch && !valueMatch:
		which = CompareValueNotMatch
	case valueMatch && !indexMatch:
		which = CompareIndexNotMatch
	default:
		which = CompareNotMatch
	}
	return ok, which
}
func (n *node) Compare(prevValue string, prevIndex uint64) (ok bool, which int) {
	indexMatch := prevIndex == 0 || n.ModifiedIndex == prevIndex
	valueMatch := prevValue == "" || n.Value == prevValue
	ok = valueMatch && indexMatch
	switch {
	case valueMatch && indexMatch:
		which = CompareMatch
	case indexMatch && !valueMatch:
		which = CompareValueNotMatch
	case valueMatch && !indexMatch:
		which = CompareIndexNotMatch
	default:
		which = CompareNotMatch
	}
	return ok, which
}
func ( n * node ) Compare ( prevValue string , prevIndex uint64 ) ( ok bool , which int ) { indexMatch := prevIndex == 0 || n . ModifiedIndex == prevIndex valueMatch := prevValue == " " || n . Value == prevValue ok = valueMatch && indexMatch switch { case valueMatch && indexMatch : which = CompareMatch case indexMatch && ! valueMatch : which = CompareValueNotMatch case valueMatch && ! indexMatch : which = CompareIndexNotMatch default : which = CompareNotMatch } return ok , which }
// Compare function compares node index and value with provided ones.
// second result value explains result and equals to one of Compare.. constants
Compare function compares node index and value with provided ones . second result value explains result and equals to one of Compare .. constants