func (t *TreeMemoryCache) View(cb func(TreeDatabaseTransaction) error) error {
	return t.underlyingStore.View(func(underlyingTx TreeDatabaseTransaction) error {
		t.lock.RLock()

		dirtyCopy := make(map[chainhash.Hash]Node)
		dirtyKVCopy := make(map[chainhash.Hash]chainhash.Hash)
		toRemoveCopy := make(map[chainhash.Hash]struct{})

		for k, v := range t.dirty {
			dirtyCopy[k] = v
		}

		for k, v := range t.dirtyKV {
			dirtyKVCopy[k] = v
		}

		for k := range t.toRemove {
			toRemoveCopy[k] = struct{}{}
		}

		t.lock.RUnlock()

		tx := &TreeMemoryCacheTransaction{
			underlyingTransaction: underlyingTx,
			root:                  t.root,
			dirty:                 dirtyCopy,
			dirtyKV:               dirtyKVCopy,
			toRemove:              toRemoveCopy,
			update:                false,
		}

		return cb(tx)
	})
}
// View creates a view transaction for the cache.
View creates a view transaction for the cache.
// View creates a view transaction for the cache .
func (t *TreeMemoryCache) View(cb func(TreeDatabaseTransaction) error) error {
	return t.underlyingStore.View(func(underlyingTx TreeDatabaseTransaction) error {
		t.lock.RLock()
		dirtyCopy := make(map[chainhash.Hash]Node)
		dirtyKVCopy := make(map[chainhash.Hash]chainhash.Hash)
		toRemoveCopy := make(map[chainhash.Hash]struct{})
		for k, v := range t.dirty {
			dirtyCopy[k] = v
		}
		for k, v := range t.dirtyKV {
			dirtyKVCopy[k] = v
		}
		for k := range t.toRemove {
			toRemoveCopy[k] = struct{}{}
		}
		t.lock.RUnlock()
		tx := &TreeMemoryCacheTransaction{
			underlyingTransaction: underlyingTx,
			root:                  t.root,
			dirty:                 dirtyCopy,
			dirtyKV:               dirtyKVCopy,
			toRemove:              toRemoveCopy,
			update:                false,
		}
		return cb(tx)
	})
}
func ( t * TreeMemoryCache ) View ( cb func ( TreeDatabaseTransaction ) error ) error { return t . underlyingStore . View ( func ( underlyingTx TreeDatabaseTransaction ) error { t . lock . RLock ( ) dirtyCopy := make ( map [ chainhash . Hash ] Node ) dirtyKVCopy := make ( map [ chainhash . Hash ] chainhash . Hash ) toRemoveCopy := make ( map [ chainhash . Hash ] struct { } ) for k , v := range t . dirty { dirtyCopy [ k ] = v } for k , v := range t . dirtyKV { dirtyKVCopy [ k ] = v } for k := range t . toRemove { toRemoveCopy [ k ] = struct { } { } } t . lock . RUnlock ( ) tx := & TreeMemoryCacheTransaction { underlyingTransaction : underlyingTx , root : t . root , dirty : dirtyCopy , dirtyKV : dirtyKVCopy , toRemove : toRemoveCopy , update : false , } return cb ( tx ) } ) }
View creates a view transaction for the cache.
View creates a view transaction for the cache .