aboutsummaryrefslogtreecommitdiffstats
path: root/storage/memory/storage.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-08 23:58:41 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-08 23:58:41 +0200
commit3b1baea2dd9353f42b3a9d93f6bc92ecbe9f4f01 (patch)
treed255b7e6edbcbaba1f98cf0c666a82c0f9750019 /storage/memory/storage.go
parent2293a3dbda0a96f5cbac851bb73e1e675417e4f3 (diff)
downloadgo-git-3b1baea2dd9353f42b3a9d93f6bc92ecbe9f4f01.tar.gz
format: packfile based on ObjectStorage and CRC32 calculation
Diffstat (limited to 'storage/memory/storage.go')
-rw-r--r--storage/memory/storage.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/storage/memory/storage.go b/storage/memory/storage.go
index 1bf99fc..6a56d6a 100644
--- a/storage/memory/storage.go
+++ b/storage/memory/storage.go
@@ -143,6 +143,7 @@ func (o *ObjectStorage) Get(t core.ObjectType, h core.Hash) (core.Object, error)
if !ok || (core.AnyObject != t && obj.Type() != t) {
return nil, core.ErrObjectNotFound
}
+
return obj, nil
}
@@ -192,6 +193,15 @@ func (tx *TxObjectStorage) Set(obj core.Object) (core.Hash, error) {
return h, nil
}
+func (tx *TxObjectStorage) Get(t core.ObjectType, h core.Hash) (core.Object, error) {
+ obj, ok := tx.Objects[h]
+ if !ok || (core.AnyObject != t && obj.Type() != t) {
+ return nil, core.ErrObjectNotFound
+ }
+
+ return obj, nil
+}
+
func (tx *TxObjectStorage) Commit() error {
for h, obj := range tx.Objects {
delete(tx.Objects, h)