veyron2/storage: Move DEntry to veyron/services/store/raw.

DEntry is used only by syncd, so it doesn't need to be in the public API.

Change-Id: I957c7fb11056f4e7b8450b742a6c5760e5b4c4b5
diff --git a/runtimes/google/vsync/vsyncd.go b/runtimes/google/vsync/vsyncd.go
index 9df19d0..ceb0785 100644
--- a/runtimes/google/vsync/vsyncd.go
+++ b/runtimes/google/vsync/vsyncd.go
@@ -18,7 +18,6 @@
 	"veyron2/ipc"
 	"veyron2/naming"
 	"veyron2/security"
-	"veyron2/storage"
 	"veyron2/vlog"
 	"veyron2/vom"
 
@@ -137,7 +136,7 @@
 	// Register these Watch data types with VOM.
 	// TODO(tilaks): why aren't they auto-retrieved from the IDL?
 	vom.Register(&raw.Mutation{})
-	vom.Register(&storage.DEntry{})
+	vom.Register(&raw.DEntry{})
 
 	// Channel to propagate close event to all threads.
 	s.closed = make(chan struct{})
diff --git a/runtimes/google/vsync/watcher_test.go b/runtimes/google/vsync/watcher_test.go
index 835b3eb..ac23e76 100644
--- a/runtimes/google/vsync/watcher_test.go
+++ b/runtimes/google/vsync/watcher_test.go
@@ -166,8 +166,8 @@
 				PriorVersion: 0x0,
 				Version:      0x4d65822107fcfd52,
 				Value:        "value-root",
-				Dir: []storage.DEntry{
-					storage.DEntry{
+				Dir: []raw.DEntry{
+					raw.DEntry{
 						Name: "a",
 						ID: storage.ID{0x8, 0x2b, 0xc4, 0x2e, 0x15, 0xaf, 0x4f, 0xcf,
 							0x61, 0x1d, 0x7f, 0x19, 0xa8, 0xd7, 0x83, 0x1f},
@@ -186,8 +186,8 @@
 				PriorVersion: 0x0,
 				Version:      0x57e9d1860d1d68d8,
 				Value:        "value-a",
-				Dir: []storage.DEntry{
-					storage.DEntry{
+				Dir: []raw.DEntry{
+					raw.DEntry{
 						Name: "b",
 						ID: storage.ID{0x6e, 0x4a, 0x32, 0x7c, 0x29, 0x7d, 0x76, 0xfb,
 							0x51, 0x42, 0xb1, 0xb1, 0xd9, 0x5b, 0x2d, 0x7},
@@ -222,13 +222,13 @@
 				PriorVersion: 0x57e9d1860d1d68d8,
 				Version:      0x365a858149c6e2d1,
 				Value:        "value-a",
-				Dir: []storage.DEntry{
-					storage.DEntry{
+				Dir: []raw.DEntry{
+					raw.DEntry{
 						Name: "b",
 						ID: storage.ID{0x6e, 0x4a, 0x32, 0x7c, 0x29, 0x7d, 0x76, 0xfb,
 							0x51, 0x42, 0xb1, 0xb1, 0xd9, 0x5b, 0x2d, 0x7},
 					},
-					storage.DEntry{
+					raw.DEntry{
 						Name: "c",
 						ID: storage.ID{0x70, 0xff, 0x65, 0xec, 0xf, 0x82, 0x5f, 0x44,
 							0xb6, 0x9f, 0x89, 0x5e, 0xea, 0x75, 0x9d, 0x71},
@@ -263,8 +263,8 @@
 				PriorVersion: 0x365a858149c6e2d1,
 				Version:      0xa858149c6e2d1000,
 				Value:        "value-a",
-				Dir: []storage.DEntry{
-					storage.DEntry{
+				Dir: []raw.DEntry{
+					raw.DEntry{
 						Name: "c",
 						ID: storage.ID{0x70, 0xff, 0x65, 0xec, 0xf, 0x82, 0x5f, 0x44,
 							0xb6, 0x9f, 0x89, 0x5e, 0xea, 0x75, 0x9d, 0x71},
diff --git a/services/store/memstore/refs/builder.go b/services/store/memstore/refs/builder.go
index 18582f2..b7d591f 100644
--- a/services/store/memstore/refs/builder.go
+++ b/services/store/memstore/refs/builder.go
@@ -5,6 +5,7 @@
 	"strconv"
 
 	"veyron/runtimes/google/lib/functional"
+	"veyron/services/store/raw"
 
 	"veyron2/storage"
 )
@@ -42,7 +43,7 @@
 }
 
 // AddDEntries adds the references contained in the DEntry list.
-func (b *Builder) AddDEntries(d []*storage.DEntry) {
+func (b *Builder) AddDEntries(d []*raw.DEntry) {
 	for _, de := range d {
 		b.refs = b.refs.Put(&Ref{ID: de.ID, Path: NewSingletonPath(de.Name)})
 	}
diff --git a/services/store/memstore/refs/refs.go b/services/store/memstore/refs/refs.go
index c7f791b..9823379 100644
--- a/services/store/memstore/refs/refs.go
+++ b/services/store/memstore/refs/refs.go
@@ -4,6 +4,7 @@
 import (
 	"veyron/runtimes/google/lib/functional"
 	"veyron/runtimes/google/lib/functional/rb"
+	"veyron/services/store/raw"
 
 	"veyron2/storage"
 )
@@ -40,12 +41,12 @@
 }
 
 // FlattenDir flattens the directory map into an association list.
-func FlattenDir(d Dir) []*storage.DEntry {
-	l := make([]*storage.DEntry, d.Len())
+func FlattenDir(d Dir) []*raw.DEntry {
+	l := make([]*raw.DEntry, d.Len())
 	i := 0
 	d.Iter(func(v interface{}) bool {
 		r := v.(*Ref)
-		l[i] = &storage.DEntry{ID: r.ID, Name: r.Path.hd}
+		l[i] = &raw.DEntry{ID: r.ID, Name: r.Path.hd}
 		i++
 		return true
 	})
@@ -53,7 +54,7 @@
 }
 
 // BuildDir builds a Dir from the association list.
-func BuildDir(l []*storage.DEntry) Dir {
+func BuildDir(l []*raw.DEntry) Dir {
 	d := EmptyDir
 	for _, de := range l {
 		d = d.Put(&Ref{ID: de.ID, Path: NewSingletonPath(de.Name)})
diff --git a/services/store/memstore/state/log.go b/services/store/memstore/state/log.go
index 79996b5..426a751 100644
--- a/services/store/memstore/state/log.go
+++ b/services/store/memstore/state/log.go
@@ -39,7 +39,7 @@
 type value struct {
 	ID      storage.ID
 	Value   interface{}
-	Dir     []*storage.DEntry
+	Dir     []*raw.DEntry
 	Version raw.Version
 }
 
diff --git a/services/store/memstore/state/mutable_snapshot.go b/services/store/memstore/state/mutable_snapshot.go
index 85b403c..2ac285b 100644
--- a/services/store/memstore/state/mutable_snapshot.go
+++ b/services/store/memstore/state/mutable_snapshot.go
@@ -90,7 +90,7 @@
 	// Dir is the set of new directory entries.
 	//
 	// TODO(jyh): Replace this with a delta, to support large directories.
-	Dir []*storage.DEntry
+	Dir []*raw.DEntry
 
 	// Refs are the set of references in the Value and Dir.
 	refs refs.Set
@@ -481,10 +481,10 @@
 	return nil
 }
 
-// TODO(tilaks): revisit when vsync.Mutation.Dir is of type []*storage.DEntry
+// TODO(tilaks): revisit when vsync.Mutation.Dir is of type []*raw.DEntry
 // (once we support optional structs in the idl).
-func unflattenDir(fdir []storage.DEntry) []*storage.DEntry {
-	pdir := make([]*storage.DEntry, len(fdir))
+func unflattenDir(fdir []raw.DEntry) []*raw.DEntry {
+	pdir := make([]*raw.DEntry, len(fdir))
 	for i, _ := range fdir {
 		pdir[i] = &fdir[i]
 	}
diff --git a/services/store/memstore/store_test.go b/services/store/memstore/store_test.go
index bd1da25..000dceb 100644
--- a/services/store/memstore/store_test.go
+++ b/services/store/memstore/store_test.go
@@ -368,11 +368,11 @@
 }
 
 var (
-	empty = []storage.DEntry{}
+	empty = []raw.DEntry{}
 )
 
-func dir(name string, id storage.ID) []storage.DEntry {
-	return []storage.DEntry{storage.DEntry{
+func dir(name string, id storage.ID) []raw.DEntry {
+	return []raw.DEntry{raw.DEntry{
 		Name: name,
 		ID:   id,
 	}}
diff --git a/services/store/memstore/testing/util.go b/services/store/memstore/testing/util.go
index a030884..8c60190 100644
--- a/services/store/memstore/testing/util.go
+++ b/services/store/memstore/testing/util.go
@@ -342,17 +342,17 @@
 }
 
 var (
-	EmptyDir = []storage.DEntry{}
+	EmptyDir = []raw.DEntry{}
 )
 
-func DirOf(name string, id storage.ID) []storage.DEntry {
-	return []storage.DEntry{storage.DEntry{
+func DirOf(name string, id storage.ID) []raw.DEntry {
+	return []raw.DEntry{raw.DEntry{
 		Name: name,
 		ID:   id,
 	}}
 }
 
-func ExpectMutationExists(t *testing.T, changes []types.Change, id storage.ID, pre, post raw.Version, isRoot bool, value string, dir []storage.DEntry) {
+func ExpectMutationExists(t *testing.T, changes []types.Change, id storage.ID, pre, post raw.Version, isRoot bool, value string, dir []raw.DEntry) {
 	change := findMutation(t, changes, id)
 	if change.State != types.Exists {
 		t.Fatalf("Expected id to exist: %v", id)
@@ -428,7 +428,7 @@
 	panic("Should not reach here")
 }
 
-func expectDirEquals(t *testing.T, actual, expected []storage.DEntry) {
+func expectDirEquals(t *testing.T, actual, expected []raw.DEntry) {
 	if len(actual) != len(expected) {
 		t.Fatalf("Expected Dir to have %v refs, but had %v", len(expected), len(actual))
 	}
diff --git a/services/store/memstore/watch/raw_processor.go b/services/store/memstore/watch/raw_processor.go
index 50af5ac..a5c012e 100644
--- a/services/store/memstore/watch/raw_processor.go
+++ b/services/store/memstore/watch/raw_processor.go
@@ -182,10 +182,10 @@
 	return changes, nil
 }
 
-// TODO(tilaks): revisit when raw.Mutation.Dir is of type []*storage.DEntry
+// TODO(tilaks): revisit when raw.Mutation.Dir is of type []*raw.DEntry
 // (once we support optional structs in the idl).
-func flattenDir(pdir []*storage.DEntry) []storage.DEntry {
-	fdir := make([]storage.DEntry, len(pdir))
+func flattenDir(pdir []*raw.DEntry) []raw.DEntry {
+	fdir := make([]raw.DEntry, len(pdir))
 	for i, p := range pdir {
 		fdir[i] = *p
 	}
diff --git a/services/store/raw/service.vdl b/services/store/raw/service.vdl
index 4af33bb..00b6eaa 100644
--- a/services/store/raw/service.vdl
+++ b/services/store/raw/service.vdl
@@ -26,6 +26,12 @@
 // time (as agreed upon by the two stores).
 type Version uint64
 
+// DEntry is a directory entry.
+type DEntry struct {
+  Name string
+  ID   storage.ID
+}
+
 // Mutation represents an update to an entry in the store, and contains enough
 // information for a privileged service to replicate the update elsewhere.
 type Mutation struct {
@@ -50,7 +56,7 @@
 
   // Dir is the implicit directory of this entry, and may contain references
   // to other entries in the store.
-  Dir []storage.DEntry
+  Dir []DEntry
 }
 
 // Request specifies how to resume from a previous Watch call.
diff --git a/services/store/raw/service.vdl.go b/services/store/raw/service.vdl.go
index 0a277dd..213f083 100644
--- a/services/store/raw/service.vdl.go
+++ b/services/store/raw/service.vdl.go
@@ -25,6 +25,12 @@
 // time (as agreed upon by the two stores).
 type Version uint64
 
+// DEntry is a directory entry.
+type DEntry struct {
+	Name string
+	ID   storage.ID
+}
+
 // Mutation represents an update to an entry in the store, and contains enough
 // information for a privileged service to replicate the update elsewhere.
 type Mutation struct {
@@ -44,7 +50,7 @@
 	Value _gen_vdlutil.Any
 	// Dir is the implicit directory of this entry, and may contain references
 	// to other entries in the store.
-	Dir []storage.DEntry
+	Dir []DEntry
 }
 
 // Request specifies how to resume from a previous Watch call.
@@ -529,7 +535,7 @@
 				_gen_wiretype.FieldType{Type: 0x3, Name: "Name"},
 				_gen_wiretype.FieldType{Type: 0x49, Name: "ID"},
 			},
-			"veyron2/storage.DEntry", []string(nil)},
+			"veyron/services/store/raw.DEntry", []string(nil)},
 		_gen_wiretype.SliceType{Elem: 0x4b, Name: "", Tags: []string(nil)}, _gen_wiretype.StructType{
 			[]_gen_wiretype.FieldType{
 				_gen_wiretype.FieldType{Type: 0x49, Name: "ID"},