From 54c0ae17f4ecf2ada41815d96c1acecb69e22244 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 22 Jul 2020 15:26:57 -0400 Subject: [PATCH 1/2] Implement buffered blocktore GetSize() --- lib/bufbstore/buf_bstore.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bufbstore/buf_bstore.go b/lib/bufbstore/buf_bstore.go index 4b430828b..edc08770c 100644 --- a/lib/bufbstore/buf_bstore.go +++ b/lib/bufbstore/buf_bstore.go @@ -104,7 +104,12 @@ func (bs *BufferedBS) Get(c cid.Cid) (block.Block, error) { } func (bs *BufferedBS) GetSize(c cid.Cid) (int, error) { - panic("nyi") + s, err := bs.read.GetSize(c) + if err == bstore.ErrNotFound || s == 0 { + return bs.write.GetSize(c) + } + + return 0, err } func (bs *BufferedBS) Put(blk block.Block) error { From df801470caffed263829508b46378df0421ec905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 23 Jul 2020 10:23:44 +0200 Subject: [PATCH 2/2] Return size in bufbs.GetSize --- lib/bufbstore/buf_bstore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bufbstore/buf_bstore.go b/lib/bufbstore/buf_bstore.go index edc08770c..4000df7d6 100644 --- a/lib/bufbstore/buf_bstore.go +++ b/lib/bufbstore/buf_bstore.go @@ -109,7 +109,7 @@ func (bs *BufferedBS) GetSize(c cid.Cid) (int, error) { return bs.write.GetSize(c) } - return 0, err + return s, err } func (bs *BufferedBS) Put(blk block.Block) error {