VOL-1616 / VOL-1611 : Fix device state issue and memory discrepencies

- Applied mutex on node object to resolve in-memory data conflicts
- Introduced a refresh period for in-memory data

Amendments:

- Fixed node.go file format
- Bumped VERSION to 2.1.0-dev
- Use a RLock for GetLastUpdate

Change-Id: I57e88fe3ec5cceed0d4fcdb240ae9191b49ebe33
diff --git a/db/model/non_persisted_revision.go b/db/model/non_persisted_revision.go
index d7b0b58..6075b3f 100644
--- a/db/model/non_persisted_revision.go
+++ b/db/model/non_persisted_revision.go
@@ -25,6 +25,7 @@
 	"reflect"
 	"sort"
 	"sync"
+	"time"
 )
 
 // TODO: Cache logic will have to be revisited to cleanup unused entries in memory (disabled for now)
@@ -55,6 +56,7 @@
 	WeakRef      string
 	Name         string
 	discarded    bool
+	lastUpdate   time.Time
 }
 
 func NewNonPersistedRevision(root *root, branch *Branch, data interface{}, children map[string][]Revision) Revision {
@@ -290,6 +292,7 @@
 	newRev.Root = npr.Root
 	newRev.Name = npr.Name
 	newRev.Branch = branch
+	newRev.lastUpdate = npr.lastUpdate
 
 	newRev.Children = make(map[string][]Revision)
 	for entryName, childrenEntry := range branch.GetLatest().GetAllChildren() {
@@ -313,6 +316,7 @@
 	updatedRev.Hash = npr.Hash
 	updatedRev.Branch = branch
 	updatedRev.Name = npr.Name
+	updatedRev.lastUpdate = npr.lastUpdate
 
 	updatedRev.Children = make(map[string][]Revision)
 	for entryName, childrenEntry := range branch.GetLatest().GetAllChildren() {
@@ -395,6 +399,7 @@
 	newRev.Hash = npr.Hash
 	newRev.Branch = branch
 	newRev.Name = npr.Name
+	newRev.lastUpdate = npr.lastUpdate
 
 	newRev.Children = make(map[string][]Revision)
 	for entryName, childrenEntry := range children {
@@ -426,6 +431,24 @@
 	}
 }
 
+func (npr *NonPersistedRevision) SetLastUpdate(ts ...time.Time) {
+	npr.mutex.Lock()
+	defer npr.mutex.Unlock()
+
+	if ts != nil && len(ts) > 0 {
+		npr.lastUpdate = ts[0]
+	} else {
+		npr.lastUpdate = time.Now()
+	}
+}
+
+func (npr *NonPersistedRevision) GetLastUpdate() time.Time {
+	npr.mutex.RLock()
+	defer npr.mutex.RUnlock()
+
+	return npr.lastUpdate
+}
+
 func (npr *NonPersistedRevision) LoadFromPersistence(path string, txid string, blobs map[string]*kvstore.KVPair) []Revision {
 	// stub... required by interface
 	return nil