From 3b1baea2dd9353f42b3a9d93f6bc92ecbe9f4f01 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Thu, 8 Sep 2016 23:58:41 +0200 Subject: format: packfile based on ObjectStorage and CRC32 calculation --- storage/memory/storage.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'storage/memory/storage.go') 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) -- cgit