From d884cd263b554ac34e52a80f4221e830bbceb67c Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Tue, 22 Sep 2015 17:46:53 -0700 Subject: [PATCH] make dataStoreCommon private --- datas/datastore_common.go | 12 ++++++------ datas/local_datastore.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/datas/datastore_common.go b/datas/datastore_common.go index eea9519be7..ae4237303f 100644 --- a/datas/datastore_common.go +++ b/datas/datastore_common.go @@ -7,7 +7,7 @@ import ( "github.com/attic-labs/noms/types" ) -type DataStoreCommon struct { +type dataStoreCommon struct { chunks.ChunkStore head *Commit } @@ -17,20 +17,20 @@ func commitFromRef(commitRef ref.Ref, cs chunks.ChunkSource) *Commit { return &c } -func (ds *DataStoreCommon) MaybeHead() (Commit, bool) { +func (ds *dataStoreCommon) MaybeHead() (Commit, bool) { if ds.head == nil { return NewCommit(), false } return *ds.head, true } -func (ds *DataStoreCommon) Head() Commit { +func (ds *dataStoreCommon) Head() Commit { c, ok := ds.MaybeHead() d.Chk.True(ok, "DataStore has no Head.") return c } -func (ds *DataStoreCommon) commit(v types.Value) bool { +func (ds *dataStoreCommon) commit(v types.Value) bool { p := NewSetOfCommit() if head, ok := ds.MaybeHead(); ok { p = p.Insert(head) @@ -38,12 +38,12 @@ func (ds *DataStoreCommon) commit(v types.Value) bool { return ds.commitWithParents(v, p) } -func (ds *DataStoreCommon) commitWithParents(v types.Value, p SetOfCommit) bool { +func (ds *dataStoreCommon) commitWithParents(v types.Value, p SetOfCommit) bool { return ds.doCommit(NewCommit().SetParents(p.NomsValue()).SetValue(v)) } // doCommit manages concurrent access the single logical piece of mutable state: the current head. doCommit is optimistic in that it is attempting to update head making the assumption that currentRootRef is the ref of the current head. The call to UpdateRoot below will fail if that assumption fails (e.g. because of a race with another writer) and the entire algorithm must be tried again. -func (ds *DataStoreCommon) doCommit(commit Commit) bool { +func (ds *dataStoreCommon) doCommit(commit Commit) bool { currentRootRef := ds.Root() // Note: |currentHead| may be different from ds.head and *must* be consistent with currentRootRef. diff --git a/datas/local_datastore.go b/datas/local_datastore.go index ce68998cb3..90755b1b51 100644 --- a/datas/local_datastore.go +++ b/datas/local_datastore.go @@ -8,23 +8,23 @@ import ( // DataStore provides versioned storage for noms values. Each DataStore instance represents one moment in history. Heads() returns the Commit from each active fork at that moment. The Commit() method returns a new DataStore, representing a new moment in history. type LocalDataStore struct { - DataStoreCommon + dataStoreCommon } func newLocalDataStore(cs chunks.ChunkStore) *LocalDataStore { rootRef := cs.Root() if rootRef == (ref.Ref{}) { - return &LocalDataStore{DataStoreCommon{cs, nil}} + return &LocalDataStore{dataStoreCommon{cs, nil}} } - return &LocalDataStore{DataStoreCommon{cs, commitFromRef(rootRef, cs)}} + return &LocalDataStore{dataStoreCommon{cs, commitFromRef(rootRef, cs)}} } -func newDataStoreInternal(cs chunks.ChunkStore) DataStoreCommon { +func newDataStoreInternal(cs chunks.ChunkStore) dataStoreCommon { if (cs.Root() == ref.Ref{}) { - return DataStoreCommon{cs, nil} + return dataStoreCommon{cs, nil} } - return DataStoreCommon{cs, commitFromRef(cs.Root(), cs)} + return dataStoreCommon{cs, commitFromRef(cs.Root(), cs)} } func (lds *LocalDataStore) Commit(v types.Value) (DataStore, bool) {