From 05e0a506b49f447ce1a82150e43ef02dd9f01779 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 29 Jan 2019 14:42:45 -0500 Subject: [PATCH] better debug output --- cmd/test.go | 8 ++++++-- store/memory.go | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/test.go b/cmd/test.go index e7b7839..fbd8b0d 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "os" "os/signal" "strconv" @@ -12,7 +13,6 @@ import ( "github.com/lbryio/reflector.go/reflector" "github.com/lbryio/reflector.go/store" - "github.com/davecgh/go-spew/spew" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -50,5 +50,9 @@ func testCmd(cmd *cobra.Command, args []string) { <-interruptChan peerServer.Shutdown() reflectorServer.Shutdown() - spew.Dump(memStore) + + fmt.Println("Blobs in store") + for hash, blob := range memStore.Debug() { + fmt.Printf("%s: %d bytes\n", hash, len(blob)) + } } diff --git a/store/memory.go b/store/memory.go index 4f9ee34..f7eee95 100644 --- a/store/memory.go +++ b/store/memory.go @@ -47,3 +47,8 @@ func (m *MemoryBlobStore) Delete(hash string) error { delete(m.blobs, hash) return nil } + +// Debug returns the blobs in memory. It's useful for testing and debugging. +func (m *MemoryBlobStore) Debug() map[string][]byte { + return m.blobs +}