Exemplo n.º 1
0
// Interface towards the Grapher
func (self *latestTransformer) TransformClientMutation(mutation grapher.MutationNode, concurrent <-chan grapher.MutationNode) (err os.Error) {
	mut, e := decodeGenericMutation(mutation)
	if e != nil {
		log.Printf("Err: Decoding")
		return e
	}

	// If any of these is later, then the mutation is transformed into the epsilon operation
	for m := range concurrent {
		if m.Time() > mut.Time {
			mutation.SetOperation([]byte("null"))
			return
		}
	}
	return
}
Exemplo n.º 2
0
// Interface towards the Grapher
func (self *latestTransformer) TransformMutation(mutation grapher.MutationNode, rollback <-chan grapher.MutationNode, concurrent []string) (err os.Error) {
	mut, e := decodeGenericMutation(mutation)
	if e != nil {
		return e
	}

	// Get a list of all concurrent mutations
	conc := make(map[string]bool)
	for _, id := range concurrent {
		conc[id] = true
	}
	for m := range rollback {
		// Skip those which are not concurrent
		if _, ok := conc[m.BlobRef()]; !ok {
			continue
		}
		if m.Time() > mut.Time {
			mutation.SetOperation([]byte("null"))
			return
		}
	}
	return
}