@cryptotaxi247 / kubo / commits / ee961edef

rm redundant Has

License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Brian Tiger Chow committed Dec 6, 2014 at 15:18 UTC ee961edef5ffc83c0426b4f469a0e309ff0d8534
1 file changed +1 -16
blockservice/blockservice.go
+1 -16
@@ -44,25 +44,10 @@ func New(bs blockstore.Blockstore, rem exchange.Interface) (*BlockService, error
44 func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
45 k := b.Key()
46 log.Debugf("blockservice: storing [%s] in datastore", k)
47 - // TODO(brian): define a block datastore with a Put method which accepts a
48 - // block parameter
49 -
50 - // check if we have it before adding. this is an extra read, but large writes
51 - // are more expensive.
52 - // TODO(jbenet) cheaper has. https://github.com/jbenet/go-datastore/issues/6
53 - has, err := s.Blockstore.Has(k)
47 + err := s.Blockstore.Put(b)
48 if err != nil {
49 return k, err
50 }
57 - if has {
58 - log.Debugf("blockservice: storing [%s] in datastore (already stored)", k)
59 - } else {
60 - log.Debugf("blockservice: storing [%s] in datastore", k)
61 - err := s.Blockstore.Put(b)
62 - if err != nil {
63 - return k, err
64 - }
65 - }
51
52 // TODO this operation rate-limits blockservice operations, we should
53 // consider moving this to an sync process.