mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 19:24:14 +08:00
blockservice: signal add optimization
This commit is contained in:
@ -37,7 +37,6 @@ func NewBlockService(d ds.Datastore, rem exchange.Interface) (*BlockService, err
|
|||||||
// AddBlock adds a particular block to the service, Putting it into the datastore.
|
// AddBlock adds a particular block to the service, Putting it into the datastore.
|
||||||
func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
|
func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
|
||||||
k := b.Key()
|
k := b.Key()
|
||||||
log.Debug("blockservice: storing [%s] in datastore", k)
|
|
||||||
// TODO(brian): define a block datastore with a Put method which accepts a
|
// TODO(brian): define a block datastore with a Put method which accepts a
|
||||||
// block parameter
|
// block parameter
|
||||||
|
|
||||||
@ -48,7 +47,10 @@ func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return k, err
|
return k, err
|
||||||
}
|
}
|
||||||
if !has {
|
if has {
|
||||||
|
log.Debugf("blockservice: storing [%s] in datastore (already stored)", k)
|
||||||
|
} else {
|
||||||
|
log.Debugf("blockservice: storing [%s] in datastore", k)
|
||||||
err := s.Datastore.Put(k.DsKey(), b.Data)
|
err := s.Datastore.Put(k.DsKey(), b.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return k, err
|
return k, err
|
||||||
|
Reference in New Issue
Block a user