diff --git a/export.go b/export.go index f2e49e465..6a6eb5c1c 100644 --- a/export.go +++ b/export.go @@ -78,7 +78,7 @@ func newExporterWithOptions(tree *ImmutableTree, optimistic bool) (*Exporter, er // export exports nodes func (e *Exporter) export(ctx context.Context) { - e.tree.root.traversePost(e.tree, true, func(node *Node) bool { + _ = e.tree.root.traversePost(e.tree, true, func(node *Node) bool { exportNode := &ExportNode{ Key: node.key, Value: node.value, diff --git a/import.go b/import.go index 2499a5627..c76616b00 100644 --- a/import.go +++ b/import.go @@ -178,7 +178,9 @@ func (i *Importer) OptimisticAdd(exportNode *ExportNode) error { } i.batchSize++ - i.sendBatchIfFull() + if err := i.sendBatchIfFull(); err != nil { + return errors.New("failed sending db write batch") + } return nil } @@ -263,9 +265,8 @@ func (i *Importer) Commit() error { return ErrNoImport } - if i.optimistic { - // All keys should be already imported - } else { + // Optimistic: All keys should be already imported + if !i.optimistic { switch len(i.stack) { case 0: if err := i.batch.Set(i.tree.ndb.nodeKey(GetRootKey(i.version)), []byte{}); err != nil { diff --git a/node.go b/node.go index 97d54a865..f035d6645 100644 --- a/node.go +++ b/node.go @@ -707,6 +707,7 @@ func (node *Node) calcBalance(t *ImmutableTree) (int, error) { } // traverse is a wrapper over traverseInRange when we want the whole tree +// nolint: unparam func (node *Node) traverse(t *ImmutableTree, ascending bool, cb func(*Node) bool) bool { return node.traverseInRange(t, nil, nil, ascending, false, false, func(node *Node) bool { return cb(node)