some performance tweaks for the dagwriter write path
Jeromy committed
Oct 8, 2014 at 03:42 UTC
bdaee9bcb272f812ded1461a6befbb4ce32444e7
3 files changed
+8
-4
blockservice/blockservice.go
+2
-2
@@ -36,7 +36,7 @@ func NewBlockService(d ds.Datastore, rem exchange.Interface) (*BlockService, err
36
// AddBlock adds a particular block to the service, Putting it into the datastore.
37
func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
38
k := b.Key()
39
- log.Debug("blockservice: storing [%s] in datastore", k.Pretty())
39
+ log.Debug("blockservice: storing [%s] in datastore", k)
40
// TODO(brian): define a block datastore with a Put method which accepts a
41
// block parameter
42
err := s.Datastore.Put(k.DsKey(), b.Data)
@@ -53,7 +53,7 @@ func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
53
// GetBlock retrieves a particular block from the service,
54
// Getting it from the datastore using the key (hash).
55
func (s *BlockService) GetBlock(k u.Key) (*blocks.Block, error) {
56
- log.Debug("BlockService GetBlock: '%s'", k.Pretty())
56
+ log.Debug("BlockService GetBlock: '%s'", k)
57
datai, err := s.Datastore.Get(k.DsKey())
58
if err == nil {
59
log.Debug("Blockservice: Got data in datastore.")
merkledag/merkledag.go
+1
-1
@@ -175,7 +175,7 @@ type DAGService struct {
175
// Add adds a node to the DAGService, storing the block in the BlockService
176
func (n *DAGService) Add(nd *Node) (u.Key, error) {
177
k, _ := nd.Key()
178
- log.Debug("DagService Add [%s]\n", k.Pretty())
178
+ log.Debug("DagService Add [%s]", k)
179
if n == nil {
180
return "", fmt.Errorf("DAGService is nil")
181
}
util/util.go
+5
-1
@@ -39,7 +39,11 @@ var ErrNotFound = ds.ErrNotFound
39
// Key is a string representation of multihash for use with maps.
40
type Key string
41
42
-// Pretty returns Key in a b58 encoded string
42
+// String returns Key in a b58 encoded string
43
+func (k Key) String() string {
44
+ return b58.Encode([]byte(k))
45
+}
46
+
47
func (k Key) Pretty() string {
48
return b58.Encode([]byte(k))
49
}