batch.go
func (db *DB) NewWriteBatch() *WriteBatch {
	txn := db.newTransaction(true, true)
	// If we let it stay at zero, compactions would not allow older key versions to be deleted,
	// because the read timestamps of pending txns, would be zero. Therefore, we set it to the
	// maximum read timestamp that's done. This allows compactions to discard key versions below
	// this read timestamp, while also not blocking on pending txns to finish before starting this
	// one.
	txn.readTs = db.orc.readMark.DoneUntil()
	return &WriteBatch{db: db, txn: txn}
}
func (db *DB) NewWriteBatch() *WriteBatch {
	txn := db.newTransaction(true, true)
	// If we let it stay at zero, compactions would not allow older key versions to be deleted,
	// because the read timestamps of pending txns, would be zero. Therefore, we set it to the
	// maximum read timestamp that's done. This allows compactions to discard key versions below
	// this read timestamp, while also not blocking on pending txns to finish before starting this
	// one.
	txn.readTs = db.orc.readMark.DoneUntil()
	return &WriteBatch{db: db, txn: txn}
}
// NewWriteBatch creates a new WriteBatch. This provides a way to conveniently do a lot of writes,
// batching them up as tightly as possible in a single transaction and using callbacks to avoid
// waiting for them to commit, thus achieving good performance. This API hides away the logic of
// creating and committing transactions. Due to the nature of SSI guaratees provided by Badger,
// blind writes can never encounter transaction conflicts (ErrConflict).