MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / commit

Method commit

driver/ipfs-synckv/write_batch.go:77–97  ·  view source on GitHub ↗

commit executes the batch with given write options.

(sync bool)

Source from the content-addressed store, hash-verified

75 return w.db.ipfsDB.Delete(w.db.ctx, metaKey)
76 })
77
78 w.db.cache.Del(key)
79}
80
81// commit executes the batch with given write options.
82func (w *WriteBatch) commit(sync bool) error {
83 if w.err != nil {
84 return w.err
85 }
86
87 // 1. Execute all IPFS operations first.
88 for _, op := range w.ipfsOps {
89 if err := op(); err != nil {
90 // If any IPFS operation fails, abort the entire batch.
91 // The local wbatch will be discarded.
92 return fmt.Errorf("ipfs operation failed during batch commit, aborting: %w", err)
93 }
94 }
95
96 // 2. If all IPFS operations succeed, commit the local leveldb batch.
97 var wo *opt.WriteOptions
98 if sync {
99 wo = w.db.syncOpts
100 }

Callers 2

CommitMethod · 0.95
SyncCommitMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected