From bdaee9bcb272f812ded1461a6befbb4ce32444e7 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 8 Oct 2014 03:42:29 +0000 Subject: [PATCH] some performance tweaks for the dagwriter write path --- blockservice/blockservice.go | 4 ++-- merkledag/merkledag.go | 2 +- util/util.go | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/blockservice/blockservice.go b/blockservice/blockservice.go index b8e445568..dcf15ce95 100644 --- a/blockservice/blockservice.go +++ b/blockservice/blockservice.go @@ -36,7 +36,7 @@ func NewBlockService(d ds.Datastore, rem exchange.Interface) (*BlockService, err // AddBlock adds a particular block to the service, Putting it into the datastore. func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) { k := b.Key() - log.Debug("blockservice: storing [%s] in datastore", k.Pretty()) + log.Debug("blockservice: storing [%s] in datastore", k) // TODO(brian): define a block datastore with a Put method which accepts a // block parameter err := s.Datastore.Put(k.DsKey(), b.Data) @@ -53,7 +53,7 @@ func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) { // GetBlock retrieves a particular block from the service, // Getting it from the datastore using the key (hash). func (s *BlockService) GetBlock(k u.Key) (*blocks.Block, error) { - log.Debug("BlockService GetBlock: '%s'", k.Pretty()) + log.Debug("BlockService GetBlock: '%s'", k) datai, err := s.Datastore.Get(k.DsKey()) if err == nil { log.Debug("Blockservice: Got data in datastore.") diff --git a/merkledag/merkledag.go b/merkledag/merkledag.go index 05440cd6e..d7e8148ed 100644 --- a/merkledag/merkledag.go +++ b/merkledag/merkledag.go @@ -175,7 +175,7 @@ type DAGService struct { // Add adds a node to the DAGService, storing the block in the BlockService func (n *DAGService) Add(nd *Node) (u.Key, error) { k, _ := nd.Key() - log.Debug("DagService Add [%s]\n", k.Pretty()) + log.Debug("DagService Add [%s]", k) if n == nil { return "", fmt.Errorf("DAGService is nil") } diff --git a/util/util.go b/util/util.go index 5a9d21e81..d82df4a6f 100644 --- a/util/util.go +++ b/util/util.go @@ -39,7 +39,11 @@ var ErrNotFound = ds.ErrNotFound // Key is a string representation of multihash for use with maps. type Key string -// Pretty returns Key in a b58 encoded string +// String returns Key in a b58 encoded string +func (k Key) String() string { + return b58.Encode([]byte(k)) +} + func (k Key) Pretty() string { return b58.Encode([]byte(k)) }