Browse Source

mvcc: create TxnWrites from TxnRead with NewReadOnlyTxnWrite

Already used internally by mvcc, but needed by etcdserver txns.
Anthony Romano 8 years ago
parent
commit
da48f1feaf
1 changed files with 3 additions and 1 deletions
  1. 3 1
      mvcc/kv.go

+ 3 - 1
mvcc/kv.go

@@ -93,7 +93,9 @@ func (trw *txnReadWrite) DeleteRange(key, end []byte) (n, rev int64) { panic("un
 func (trw *txnReadWrite) Put(key, value []byte, lease lease.LeaseID) (rev int64) {
 	panic("unexpected Put")
 }
-func (trw *txnReadWrite) Changes() []mvccpb.KeyValue { panic("unexpected Changes") }
+func (trw *txnReadWrite) Changes() []mvccpb.KeyValue { return nil }
+
+func NewReadOnlyTxnWrite(txn TxnRead) TxnWrite { return &txnReadWrite{txn} }
 
 type KV interface {
 	ReadView