diff --git a/store/event.go b/store/event.go index 5674b132c..cd7e0815d 100644 --- a/store/event.go +++ b/store/event.go @@ -35,7 +35,7 @@ func (e *Event) IsCreated() bool { return true } - if e.Action == Set && e.Node.PrevValue == "" { + if e.Action == Set && e.PrevNode == nil { return true } @@ -53,7 +53,7 @@ func (event *Event) Response(currentIndex uint64) interface{} { Action: event.Action, Key: event.Node.Key, Value: event.Node.Value, - PrevValue: event.Node.PrevValue, + PrevValue: event.PrevNode.Value, Index: event.Node.ModifiedIndex, TTL: event.Node.TTL, Expiration: event.Node.Expiration, diff --git a/store/node_extern.go b/store/node_extern.go index 727d16c93..1466ea16a 100644 --- a/store/node_extern.go +++ b/store/node_extern.go @@ -10,7 +10,6 @@ import ( // TTL is time to live in second type NodeExtern struct { Key string `json:"key, omitempty"` - PrevValue string `json:"-"` Value string `json:"value,omitempty"` Dir bool `json:"dir,omitempty"` Expiration *time.Time `json:"expiration,omitempty"` diff --git a/store/store.go b/store/store.go index 23168d18c..0709551ce 100644 --- a/store/store.go +++ b/store/store.go @@ -228,8 +228,6 @@ func (s *store) CompareAndSwap(nodePath string, prevValue string, prevIndex uint e.PrevNode = n.Repr(false, false) eNode := e.Node - eNode.PrevValue = n.Value - // if test succeed, write the value n.Write(value, s.CurrentIndex) n.UpdateTTL(expireTime) @@ -273,8 +271,6 @@ func (s *store) Delete(nodePath string, dir, recursive bool) (*Event, error) { if n.IsDir() { eNode.Dir = true - } else { - eNode.PrevValue = n.Value } callback := func(path string) { // notify function @@ -424,7 +420,6 @@ func (s *store) Update(nodePath string, newValue string, expireTime time.Time) ( return nil, etcdErr.NewError(etcdErr.EcodeNotFile, nodePath, currIndex) } - eNode.PrevValue = n.Value n.Write(newValue, nextIndex) eNode.Value = newValue @@ -487,7 +482,6 @@ func (s *store) internalCreate(nodePath string, dir bool, value string, unique, return nil, etcdErr.NewError(etcdErr.EcodeNotFile, nodePath, currIndex) } e.PrevNode = n.Repr(false, false) - eNode.PrevValue, _ = n.Read() n.Remove(false, false, nil) } else { diff --git a/store/store_test.go b/store/store_test.go index 65f29fffc..6a068018d 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -93,7 +93,6 @@ func TestSet(t *testing.T) { assert.Equal(t, e.Action, "set", "") assert.Equal(t, e.Node.Key, "/foo", "") assert.False(t, e.Node.Dir, "") - assert.Equal(t, e.Node.PrevValue, "", "") assert.Equal(t, e.Node.Value, "", "") assert.Nil(t, e.Node.Nodes, "") assert.Nil(t, e.Node.Expiration, "") @@ -106,7 +105,6 @@ func TestSet(t *testing.T) { assert.Equal(t, e.Action, "set", "") assert.Equal(t, e.Node.Key, "/foo", "") assert.False(t, e.Node.Dir, "") - assert.Equal(t, e.Node.PrevValue, "", "") assert.Equal(t, e.Node.Value, "bar", "") assert.Nil(t, e.Node.Nodes, "") assert.Nil(t, e.Node.Expiration, "") @@ -124,7 +122,6 @@ func TestSet(t *testing.T) { assert.Equal(t, e.Action, "set", "") assert.Equal(t, e.Node.Key, "/dir", "") assert.True(t, e.Node.Dir, "") - assert.Equal(t, e.Node.PrevValue, "", "") assert.Equal(t, e.Node.Value, "", "") assert.Nil(t, e.Node.Nodes, "") assert.Nil(t, e.Node.Expiration, "") @@ -141,7 +138,6 @@ func TestStoreCreateValue(t *testing.T) { assert.Equal(t, e.Action, "create", "") assert.Equal(t, e.Node.Key, "/foo", "") assert.False(t, e.Node.Dir, "") - assert.Equal(t, e.Node.PrevValue, "", "") assert.Equal(t, e.Node.Value, "bar", "") assert.Nil(t, e.Node.Nodes, "") assert.Nil(t, e.Node.Expiration, "") @@ -154,7 +150,6 @@ func TestStoreCreateValue(t *testing.T) { assert.Equal(t, e.Action, "create", "") assert.Equal(t, e.Node.Key, "/empty", "") assert.False(t, e.Node.Dir, "") - assert.Equal(t, e.Node.PrevValue, "", "") assert.Equal(t, e.Node.Value, "", "") assert.Nil(t, e.Node.Nodes, "") assert.Nil(t, e.Node.Expiration, "") @@ -200,7 +195,6 @@ func TestStoreUpdateValue(t *testing.T) { assert.Equal(t, e.Action, "update", "") assert.Equal(t, e.Node.Key, "/foo", "") assert.False(t, e.Node.Dir, "") - assert.Equal(t, e.Node.PrevValue, "bar", "") assert.Equal(t, e.Node.Value, "baz", "") assert.Equal(t, e.Node.TTL, 0, "") assert.Equal(t, e.Node.ModifiedIndex, uint64(2), "") @@ -219,7 +213,6 @@ func TestStoreUpdateValue(t *testing.T) { assert.Equal(t, e.Action, "update", "") assert.Equal(t, e.Node.Key, "/foo", "") assert.False(t, e.Node.Dir, "") - assert.Equal(t, e.Node.PrevValue, "baz", "") assert.Equal(t, e.Node.Value, "", "") assert.Equal(t, e.Node.TTL, 0, "") assert.Equal(t, e.Node.ModifiedIndex, uint64(3), "") @@ -436,7 +429,6 @@ func TestStoreCompareAndSwapPrevValue(t *testing.T) { e, err := s.CompareAndSwap("/foo", "bar", 0, "baz", Permanent) assert.Nil(t, err, "") assert.Equal(t, e.Action, "compareAndSwap", "") - assert.Equal(t, e.Node.PrevValue, "bar", "") assert.Equal(t, e.Node.Value, "baz", "") // check pervNode assert.NotNil(t, e.PrevNode, "") @@ -469,7 +461,6 @@ func TestStoreCompareAndSwapPrevIndex(t *testing.T) { e, err := s.CompareAndSwap("/foo", "", 1, "baz", Permanent) assert.Nil(t, err, "") assert.Equal(t, e.Action, "compareAndSwap", "") - assert.Equal(t, e.Node.PrevValue, "bar", "") assert.Equal(t, e.Node.Value, "baz", "") // check pervNode assert.NotNil(t, e.PrevNode, "")