-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add transactional support to leveldb datastore. #17
Conversation
@@ -130,7 +148,7 @@ func (d *datastore) QueryNew(q dsq.Query) (dsq.Results, error) { | |||
}), nil | |||
} | |||
|
|||
func (d *datastore) QueryOrig(q dsq.Query) (dsq.Results, error) { | |||
func (a *accessor) queryOrig(q dsq.Query) (dsq.Results, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exported QueryOrig
and QueryNew
are not used in IPFS to my knowledge. I made them private, as it feels wrong for these to be exported, but feel free to push back if I shouldn't have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, there we go!
@@ -49,21 +54,34 @@ func NewDatastore(path string, opts *Options) (*datastore, error) { | |||
} | |||
|
|||
return &datastore{ | |||
DB: db, | |||
path: path, | |||
accessor: &accessor{ldb: db}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This accessor
is created with the LevelDB DB itself. The accessor
on NewTransaction()
is created with the transaction. I'm not married to the naming.
func (d *datastore) Put(key ds.Key, value []byte) (err error) { | ||
return d.DB.Put(key.Bytes(), value, nil) | ||
// It allows to plug in either inside the `accessor`. | ||
type levelDbOps interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🎉
} | ||
|
||
func (d *datastore) QueryNew(q dsq.Query) (dsq.Results, error) { | ||
func (a *accessor) queryNew(q dsq.Query) (dsq.Results, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally approve re-scoping this, but just make sure it's not breaking anything unexpectedly
@@ -130,7 +148,7 @@ func (d *datastore) QueryNew(q dsq.Query) (dsq.Results, error) { | |||
}), nil | |||
} | |||
|
|||
func (d *datastore) QueryOrig(q dsq.Query) (dsq.Results, error) { | |||
func (a *accessor) queryOrig(q dsq.Query) (dsq.Results, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, there we go!
Merge ipfs/go-datastore#98 first.