rocksdb #29
16
db/db.go
|
@ -10,8 +10,8 @@ import (
|
||||||
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lbryio/hub/db/db_stack"
|
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
"github.com/lbryio/hub/db/prefixes"
|
"github.com/lbryio/hub/db/prefixes"
|
||||||
|
"github.com/lbryio/hub/db/stack"
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
"github.com/lbryio/hub/internal"
|
"github.com/lbryio/hub/internal"
|
||||||
"github.com/lbryio/hub/internal/metrics"
|
"github.com/lbryio/hub/internal/metrics"
|
||||||
pb "github.com/lbryio/hub/protobuf/go"
|
pb "github.com/lbryio/hub/protobuf/go"
|
||||||
|
@ -48,10 +48,10 @@ type ReadOnlyDBColumnFamily struct {
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
DB *grocksdb.DB
|
DB *grocksdb.DB
|
||||||
Handles map[string]*grocksdb.ColumnFamilyHandle
|
Handles map[string]*grocksdb.ColumnFamilyHandle
|
||||||
Opts *grocksdb.ReadOptions
|
Opts *grocksdb.ReadOptions
|
||||||
TxCounts *db_stack.SliceBackedStack
|
TxCounts *stack.SliceBacked
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
Height uint32
|
Height uint32
|
||||||
LastState *prefixes.DBStateValue
|
LastState *prefixes.DBStateValue
|
||||||
Headers *db_stack.SliceBackedStack
|
Headers *stack.SliceBacked
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
BlockingChannelHashes [][]byte
|
BlockingChannelHashes [][]byte
|
||||||
FilteringChannelHashes [][]byte
|
FilteringChannelHashes [][]byte
|
||||||
BlockedStreams map[string][]byte
|
BlockedStreams map[string][]byte
|
||||||
|
@ -410,6 +410,7 @@ func Iter(db *grocksdb.DB, opts *IterOptions) <-chan *prefixes.PrefixRowKV {
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
// GetDB functions that open and return a db
|
// GetDB functions that open and return a db
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// GetWriteDBCF opens a db for writing with all columns families opened.
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
func GetWriteDBCF(name string) (*grocksdb.DB, []*grocksdb.ColumnFamilyHandle, error) {
|
func GetWriteDBCF(name string) (*grocksdb.DB, []*grocksdb.ColumnFamilyHandle, error) {
|
||||||
opts := grocksdb.NewDefaultOptions()
|
opts := grocksdb.NewDefaultOptions()
|
||||||
cfOpt := grocksdb.NewDefaultOptions()
|
cfOpt := grocksdb.NewDefaultOptions()
|
||||||
|
@ -461,6 +462,7 @@ func GetProdDB(name string, secondaryPath string) (*ReadOnlyDBColumnFamily, func
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
return db, cleanup, nil
|
return db, cleanup, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDBColumnFamilies gets a db with the specified column families and secondary path.
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
func GetDBColumnFamilies(name string, secondayPath string, cfNames []string) (*ReadOnlyDBColumnFamily, error) {
|
func GetDBColumnFamilies(name string, secondayPath string, cfNames []string) (*ReadOnlyDBColumnFamily, error) {
|
||||||
opts := grocksdb.NewDefaultOptions()
|
opts := grocksdb.NewDefaultOptions()
|
||||||
roOpts := grocksdb.NewDefaultReadOptions()
|
roOpts := grocksdb.NewDefaultReadOptions()
|
||||||
|
@ -565,6 +567,7 @@ func (db *ReadOnlyDBColumnFamily) Unwind() {
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
db.Headers.Pop()
|
db.Headers.Pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Shutdown shuts down the db.
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
func (db *ReadOnlyDBColumnFamily) Shutdown() {
|
func (db *ReadOnlyDBColumnFamily) Shutdown() {
|
||||||
db.ShutdownChan <- struct{}{}
|
db.ShutdownChan <- struct{}{}
|
||||||
<-db.DoneChan
|
<-db.DoneChan
|
||||||
|
@ -709,7 +712,7 @@ func (db *ReadOnlyDBColumnFamily) InitHeaders() error {
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: figure out a reasonable default and make it a constant
|
//TODO: figure out a reasonable default and make it a constant
|
||||||
👀 :eyes:
|
|||||||
db.Headers = db_stack.NewSliceBackedStack(12000)
|
db.Headers = stack.NewSliceBacked(12000)
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
|
|
||||||
startKey := prefixes.NewHeaderKey(0)
|
startKey := prefixes.NewHeaderKey(0)
|
||||||
// endKey := prefixes.NewHeaderKey(db.LastState.Height)
|
// endKey := prefixes.NewHeaderKey(db.LastState.Height)
|
||||||
|
@ -736,7 +739,7 @@ func (db *ReadOnlyDBColumnFamily) InitTxCounts() error {
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
db.TxCounts = db_stack.NewSliceBackedStack(InitialTxCountSize)
|
db.TxCounts = stack.NewSliceBacked(InitialTxCountSize)
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
|
|
||||||
options := NewIterateOptions().WithPrefix([]byte{prefixes.TxCount}).WithCfHandle(handle)
|
options := NewIterateOptions().WithPrefix([]byte{prefixes.TxCount}).WithCfHandle(handle)
|
||||||
options = options.WithIncludeKey(false).WithIncludeValue(true).WithIncludeStop(true)
|
options = options.WithIncludeKey(false).WithIncludeValue(true).WithIncludeStop(true)
|
||||||
|
@ -769,6 +772,7 @@ func (db *ReadOnlyDBColumnFamily) RunGetBlocksAndFilters() {
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBlocksAndFilters gets the blocked and filtered channels and streams from the database.
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
func (db *ReadOnlyDBColumnFamily) GetBlocksAndFilters() error {
|
func (db *ReadOnlyDBColumnFamily) GetBlocksAndFilters() error {
|
||||||
blockedChannels, blockedStreams, err := db.GetStreamsAndChannelRepostedByChannelHashes(db.BlockingChannelHashes)
|
blockedChannels, blockedStreams, err := db.GetStreamsAndChannelRepostedByChannelHashes(db.BlockingChannelHashes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -789,6 +793,7 @@ func (db *ReadOnlyDBColumnFamily) GetBlocksAndFilters() error {
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDBCF Get the database and open given column families.
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
func GetDBCF(name string, cf string) (*grocksdb.DB, []*grocksdb.ColumnFamilyHandle, error) {
|
func GetDBCF(name string, cf string) (*grocksdb.DB, []*grocksdb.ColumnFamilyHandle, error) {
|
||||||
opts := grocksdb.NewDefaultOptions()
|
opts := grocksdb.NewDefaultOptions()
|
||||||
cfOpt := grocksdb.NewDefaultOptions()
|
cfOpt := grocksdb.NewDefaultOptions()
|
||||||
|
@ -808,6 +813,7 @@ func GetDBCF(name string, cf string) (*grocksdb.DB, []*grocksdb.ColumnFamilyHand
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
return db, handles, nil
|
return db, handles, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDB Get the database.
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|||||||
func GetDB(name string) (*grocksdb.DB, error) {
|
func GetDB(name string) (*grocksdb.DB, error) {
|
||||||
opts := grocksdb.NewDefaultOptions()
|
opts := grocksdb.NewDefaultOptions()
|
||||||
db, err := grocksdb.OpenDbAsSecondary(opts, name, "asdf")
|
db, err := grocksdb.OpenDbAsSecondary(opts, name, "asdf")
|
||||||
|
|
||||||
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
no need to start these with N no need to start these with N
and many of these are unused and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families typo: Famlies -> Families
this can be unexported this can be unexported
still need this? still need this?
typo typo
👀 :eyes:
I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation. I agree the "N" can go. I copied these all over from the Python. where I believe they are similarly unused, because I thought it might be the defacto documentation.
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this. ```
// Valid returns false only when an Iterator has iterated past either the
// first or the last key in the database.
func (iter *Iterator) Valid() bool {
return C.rocksdb_iter_valid(iter.c) != 0
}
```
If our iterator was to try to go off the end of the db, or the front if we're going backwards, we need to check this.
|
|
@ -11,10 +11,14 @@ import (
|
||||||
"github.com/linxGnu/grocksdb"
|
"github.com/linxGnu/grocksdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetExpirationHeight returns the expiration height for the given height. Uses
|
||||||
|
// the original claim expiration time.
|
||||||
func GetExpirationHeight(lastUpdatedHeight uint32) uint32 {
|
func GetExpirationHeight(lastUpdatedHeight uint32) uint32 {
|
||||||
return GetExpirationHeightFull(lastUpdatedHeight, false)
|
return GetExpirationHeightFull(lastUpdatedHeight, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetExpirationHeightFull returns the expiration height for the given height.
|
||||||
|
// Takes boolean to indicated whether to use extended or original expiration time.
|
||||||
func GetExpirationHeightFull(lastUpdatedHeight uint32, extended bool) uint32 {
|
func GetExpirationHeightFull(lastUpdatedHeight uint32, extended bool) uint32 {
|
||||||
unclear what the diff between this and previous function is. whats a full expiration height? unclear what the diff between this and previous function is. whats a full expiration height?
That's just an internal distinction because it takes the optional boolean to use the extended expiration time. I added a comment. That's just an internal distinction because it takes the optional boolean to use the extended expiration time. I added a comment.
|
|||||||
if extended {
|
if extended {
|
||||||
return lastUpdatedHeight + ExtendedClaimExpirationTime
|
return lastUpdatedHeight + ExtendedClaimExpirationTime
|
||||||
|
@ -35,6 +39,7 @@ func (db *ReadOnlyDBColumnFamily) EnsureHandle(prefix byte) (*grocksdb.ColumnFam
|
||||||
return handle, nil
|
return handle, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBlockHash returns the block hash for the given height.
|
||||||
func (db *ReadOnlyDBColumnFamily) GetBlockHash(height uint32) ([]byte, error) {
|
func (db *ReadOnlyDBColumnFamily) GetBlockHash(height uint32) ([]byte, error) {
|
||||||
handle, err := db.EnsureHandle(prefixes.BlockHash)
|
handle, err := db.EnsureHandle(prefixes.BlockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -77,6 +82,7 @@ func (db *ReadOnlyDBColumnFamily) GetHeader(height uint32) ([]byte, error) {
|
||||||
return rawValue, nil
|
return rawValue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetStreamsAndChannelRepostedByChannelHashes returns a map of streams and channel hashes that are reposted by the given channel hashes.
|
||||||
func (db *ReadOnlyDBColumnFamily) GetStreamsAndChannelRepostedByChannelHashes(reposterChannelHashes [][]byte) (map[string][]byte, map[string][]byte, error) {
|
func (db *ReadOnlyDBColumnFamily) GetStreamsAndChannelRepostedByChannelHashes(reposterChannelHashes [][]byte) (map[string][]byte, map[string][]byte, error) {
|
||||||
handle, err := db.EnsureHandle(prefixes.ChannelToClaim)
|
handle, err := db.EnsureHandle(prefixes.ChannelToClaim)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -119,6 +125,7 @@ func (db *ReadOnlyDBColumnFamily) GetStreamsAndChannelRepostedByChannelHashes(re
|
||||||
return streams, channels, nil
|
return streams, channels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetClaimsInChannelCount returns the number of claims in the given channel.
|
||||||
func (db *ReadOnlyDBColumnFamily) GetClaimsInChannelCount(channelHash []byte) (uint32, error) {
|
func (db *ReadOnlyDBColumnFamily) GetClaimsInChannelCount(channelHash []byte) (uint32, error) {
|
||||||
handle, err := db.EnsureHandle(prefixes.ChannelCount)
|
handle, err := db.EnsureHandle(prefixes.ChannelCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
// iterator.go contains the implementation for iterators on rocksdb used by the hub
|
// iteroptions.go contains the implementation for iterators on rocksdb used by the hub
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -1,4 +1,4 @@
|
||||||
package db_stack
|
package stack
|
||||||
|
|
||||||
// The db_stack package contains the implementation of a generic slice backed stack
|
// The db_stack package contains the implementation of a generic slice backed stack
|
||||||
// used for tracking various states in the hub, i.e. headers and txcounts
|
// used for tracking various states in the hub, i.e. headers and txcounts
|
||||||
|
@ -9,21 +9,21 @@ import (
|
||||||
"github.com/lbryio/hub/internal"
|
"github.com/lbryio/hub/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SliceBackedStack struct {
|
type SliceBacked struct {
|
||||||
slice []interface{}
|
slice []interface{}
|
||||||
len uint32
|
len uint32
|
||||||
mut sync.RWMutex
|
mut sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSliceBackedStack(size int) *SliceBackedStack {
|
func NewSliceBacked(size int) *SliceBacked {
|
||||||
return &SliceBackedStack{
|
return &SliceBacked{
|
||||||
slice: make([]interface{}, size),
|
slice: make([]interface{}, size),
|
||||||
len: 0,
|
len: 0,
|
||||||
mut: sync.RWMutex{},
|
mut: sync.RWMutex{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SliceBackedStack) Push(v interface{}) {
|
func (s *SliceBacked) Push(v interface{}) {
|
||||||
s.mut.Lock()
|
s.mut.Lock()
|
||||||
defer s.mut.Unlock()
|
defer s.mut.Unlock()
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func (s *SliceBackedStack) Push(v interface{}) {
|
||||||
s.len++
|
s.len++
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SliceBackedStack) Pop() interface{} {
|
func (s *SliceBacked) Pop() interface{} {
|
||||||
s.mut.Lock()
|
s.mut.Lock()
|
||||||
defer s.mut.Unlock()
|
defer s.mut.Unlock()
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func (s *SliceBackedStack) Pop() interface{} {
|
||||||
return s.slice[s.len]
|
return s.slice[s.len]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SliceBackedStack) Get(i uint32) interface{} {
|
func (s *SliceBacked) Get(i uint32) interface{} {
|
||||||
s.mut.RLock()
|
s.mut.RLock()
|
||||||
defer s.mut.RUnlock()
|
defer s.mut.RUnlock()
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func (s *SliceBackedStack) Get(i uint32) interface{} {
|
||||||
return s.slice[i]
|
return s.slice[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SliceBackedStack) GetTip() interface{} {
|
func (s *SliceBacked) GetTip() interface{} {
|
||||||
s.mut.RLock()
|
s.mut.RLock()
|
||||||
defer s.mut.RUnlock()
|
defer s.mut.RUnlock()
|
||||||
|
|
||||||
|
@ -66,27 +66,27 @@ func (s *SliceBackedStack) GetTip() interface{} {
|
||||||
return s.slice[s.len-1]
|
return s.slice[s.len-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SliceBackedStack) Len() uint32 {
|
func (s *SliceBacked) Len() uint32 {
|
||||||
s.mut.RLock()
|
s.mut.RLock()
|
||||||
defer s.mut.RUnlock()
|
defer s.mut.RUnlock()
|
||||||
|
|
||||||
return s.len
|
return s.len
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SliceBackedStack) Cap() int {
|
func (s *SliceBacked) Cap() int {
|
||||||
s.mut.RLock()
|
s.mut.RLock()
|
||||||
defer s.mut.RUnlock()
|
defer s.mut.RUnlock()
|
||||||
|
|
||||||
return cap(s.slice)
|
return cap(s.slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SliceBackedStack) GetSlice() []interface{} {
|
func (s *SliceBacked) GetSlice() []interface{} {
|
||||||
// This is not thread safe so I won't bother with locking
|
// This is not thread safe so I won't bother with locking
|
||||||
return s.slice
|
return s.slice
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is dangerous because it assumes underlying types
|
// This function is dangerous because it assumes underlying types
|
||||||
func (s *SliceBackedStack) TxCountsBisectRight(txNum, rootTxNum uint32) (uint32, uint32) {
|
func (s *SliceBacked) TxCountsBisectRight(txNum, rootTxNum uint32) (uint32, uint32) {
|
||||||
s.mut.RLock()
|
s.mut.RLock()
|
||||||
defer s.mut.RUnlock()
|
defer s.mut.RUnlock()
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package db_stack_test
|
package stack_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lbryio/hub/db/db_stack"
|
"github.com/lbryio/hub/db/stack"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPush(t *testing.T) {
|
func TestPush(t *testing.T) {
|
||||||
var want uint32 = 3
|
var want uint32 = 3
|
||||||
|
|
||||||
stack := db_stack.NewSliceBackedStack(10)
|
stack := stack.NewSliceBacked(10)
|
||||||
|
|
||||||
stack.Push(0)
|
stack.Push(0)
|
||||||
stack.Push(1)
|
stack.Push(1)
|
||||||
|
@ -22,7 +22,7 @@ func TestPush(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPushPop(t *testing.T) {
|
func TestPushPop(t *testing.T) {
|
||||||
stack := db_stack.NewSliceBackedStack(10)
|
stack := stack.NewSliceBacked(10)
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
stack.Push(i)
|
stack.Push(i)
|
||||||
|
@ -46,20 +46,20 @@ func TestPushPop(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doPushes(stack *db_stack.SliceBackedStack, numPushes int) {
|
func doPushes(stack *stack.SliceBacked, numPushes int) {
|
||||||
for i := 0; i < numPushes; i++ {
|
for i := 0; i < numPushes; i++ {
|
||||||
stack.Push(i)
|
stack.Push(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func doPops(stack *db_stack.SliceBackedStack, numPops int) {
|
func doPops(stack *stack.SliceBacked, numPops int) {
|
||||||
for i := 0; i < numPops; i++ {
|
for i := 0; i < numPops; i++ {
|
||||||
stack.Pop()
|
stack.Pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMultiThreaded(t *testing.T) {
|
func TestMultiThreaded(t *testing.T) {
|
||||||
stack := db_stack.NewSliceBackedStack(100000)
|
stack := stack.NewSliceBacked(100000)
|
||||||
|
|
||||||
go doPushes(stack, 100000)
|
go doPushes(stack, 100000)
|
||||||
go doPushes(stack, 100000)
|
go doPushes(stack, 100000)
|
||||||
|
@ -83,7 +83,7 @@ func TestMultiThreaded(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
stack := db_stack.NewSliceBackedStack(10)
|
stack := stack.NewSliceBacked(10)
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
stack.Push(i)
|
stack.Push(i)
|
||||||
|
@ -107,7 +107,7 @@ func TestGet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLenCap(t *testing.T) {
|
func TestLenCap(t *testing.T) {
|
||||||
stack := db_stack.NewSliceBackedStack(10)
|
stack := stack.NewSliceBacked(10)
|
||||||
|
|
||||||
if got := stack.Len(); got != 0 {
|
if got := stack.Len(); got != 0 {
|
||||||
t.Errorf("got %v, want %v", got, 0)
|
t.Errorf("got %v, want %v", got, 0)
|
|
@ -1,5 +1,8 @@
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
|
// internal types that need their own file to avoid circular imports.
|
||||||
|
|
||||||
|
// HeightHash struct for the height subscription endpoint.
|
||||||
type HeightHash struct {
|
type HeightHash struct {
|
||||||
docs plz docs plz
|
|||||||
Height uint64
|
Height uint64
|
||||||
BlockHash []byte
|
BlockHash []byte
|
||||||
|
|
|
@ -13,8 +13,6 @@ const (
|
||||||
ServeCmd = iota
|
ServeCmd = iota
|
||||||
SearchCmd = iota
|
SearchCmd = iota
|
||||||
DBCmd = iota
|
DBCmd = iota
|
||||||
what are cmd2 and cmd3? what do they mean? what are cmd2 and cmd3? what do they mean?
These were things I added for testing, I removed them from the main function but missed removing them here. I'll get rid of them. These were things I added for testing, I removed them from the main function but missed removing them here. I'll get rid of them.
|
|||||||
DBCmd2 = iota
|
|
||||||
DBCmd3 = iota
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Args struct contains the arguments to the hub server.
|
// Args struct contains the arguments to the hub server.
|
||||||
|
@ -106,8 +104,6 @@ func ParseArgs(searchRequest *pb.SearchRequest) *Args {
|
||||||
serveCmd := parser.NewCommand("serve", "start the hub server")
|
serveCmd := parser.NewCommand("serve", "start the hub server")
|
||||||
searchCmd := parser.NewCommand("search", "claim search")
|
searchCmd := parser.NewCommand("search", "claim search")
|
||||||
dbCmd := parser.NewCommand("db", "db testing")
|
dbCmd := parser.NewCommand("db", "db testing")
|
||||||
dbCmd2 := parser.NewCommand("db2", "db testing")
|
|
||||||
dbCmd3 := parser.NewCommand("db3", "db testing")
|
|
||||||
|
|
||||||
host := parser.String("", "rpchost", &argparse.Options{Required: false, Help: "RPC host", Default: DefaultHost})
|
host := parser.String("", "rpchost", &argparse.Options{Required: false, Help: "RPC host", Default: DefaultHost})
|
||||||
port := parser.String("", "rpcport", &argparse.Options{Required: false, Help: "RPC port", Default: DefaultPort})
|
port := parser.String("", "rpcport", &argparse.Options{Required: false, Help: "RPC port", Default: DefaultPort})
|
||||||
|
@ -210,10 +206,6 @@ func ParseArgs(searchRequest *pb.SearchRequest) *Args {
|
||||||
args.CmdType = SearchCmd
|
args.CmdType = SearchCmd
|
||||||
} else if dbCmd.Happened() {
|
} else if dbCmd.Happened() {
|
||||||
args.CmdType = DBCmd
|
args.CmdType = DBCmd
|
||||||
} else if dbCmd2.Happened() {
|
|
||||||
args.CmdType = DBCmd2
|
|
||||||
} else if dbCmd3.Happened() {
|
|
||||||
args.CmdType = DBCmd3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if *text != "" {
|
if *text != "" {
|
||||||
|
|
|
@ -146,6 +146,50 @@ func (s *Server) Run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LoadDatabase(args *Args) (*db.ReadOnlyDBColumnFamily, error) {
|
||||||
|
tmpName, err := ioutil.TempDir("", "go-lbry-hub")
|
||||||
|
if err != nil {
|
||||||
|
logrus.Info(err)
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
logrus.Info("tmpName", tmpName)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Info(err)
|
||||||
|
}
|
||||||
|
myDB, _, err := db.GetProdDB(args.DBPath, tmpName)
|
||||||
|
// dbShutdown = func() {
|
||||||
|
// db.Shutdown(myDB)
|
||||||
|
// }
|
||||||
|
if err != nil {
|
||||||
|
// Can't load the db, fail loudly
|
||||||
|
logrus.Info(err)
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
blockingChannelHashes := make([][]byte, 0, 10)
|
||||||
|
filteringChannelHashes := make([][]byte, 0, 10)
|
||||||
|
|
||||||
|
for _, id := range args.BlockingChannelIds {
|
||||||
|
hash, err := hex.DecodeString(id)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Warn("Invalid channel id: ", id)
|
||||||
|
}
|
||||||
|
blockingChannelHashes = append(blockingChannelHashes, hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, id := range args.FilteringChannelIds {
|
||||||
|
hash, err := hex.DecodeString(id)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Warn("Invalid channel id: ", id)
|
||||||
|
}
|
||||||
|
filteringChannelHashes = append(filteringChannelHashes, hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
myDB.BlockingChannelHashes = blockingChannelHashes
|
||||||
|
myDB.FilteringChannelHashes = filteringChannelHashes
|
||||||
|
return myDB, nil
|
||||||
|
}
|
||||||
|
|
||||||
// MakeHubServer takes the arguments given to a hub when it's started and
|
// MakeHubServer takes the arguments given to a hub when it's started and
|
||||||
// initializes everything. It loads information about previously known peers,
|
// initializes everything. It loads information about previously known peers,
|
||||||
// creates needed internal data structures, and initializes goroutines.
|
// creates needed internal data structures, and initializes goroutines.
|
||||||
|
@ -200,46 +244,10 @@ func MakeHubServer(ctx context.Context, args *Args) *Server {
|
||||||
var myDB *db.ReadOnlyDBColumnFamily
|
var myDB *db.ReadOnlyDBColumnFamily
|
||||||
// var dbShutdown = func() {}
|
// var dbShutdown = func() {}
|
||||||
if !args.DisableResolve {
|
if !args.DisableResolve {
|
||||||
tmpName, err := ioutil.TempDir("", "go-lbry-hub")
|
myDB, err = LoadDatabase(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Info(err)
|
logrus.Warning(err)
|
||||||
log.Fatal(err)
|
|
||||||
}
|
}
|
||||||
logrus.Info("tmpName", tmpName)
|
|
||||||
if err != nil {
|
|
||||||
logrus.Info(err)
|
|
||||||
}
|
|
||||||
myDB, _, err = db.GetProdDB(args.DBPath, tmpName)
|
|
||||||
// dbShutdown = func() {
|
|
||||||
// db.Shutdown(myDB)
|
|
||||||
// }
|
|
||||||
if err != nil {
|
|
||||||
// Can't load the db, fail loudly
|
|
||||||
logrus.Info(err)
|
|
||||||
log.Fatalln(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
blockingChannelHashes := make([][]byte, 0, 10)
|
|
||||||
filteringChannelHashes := make([][]byte, 0, 10)
|
|
||||||
|
|
||||||
for _, id := range args.BlockingChannelIds {
|
|
||||||
hash, err := hex.DecodeString(id)
|
|
||||||
if err != nil {
|
|
||||||
logrus.Warn("Invalid channel id: ", id)
|
|
||||||
}
|
|
||||||
blockingChannelHashes = append(blockingChannelHashes, hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, id := range args.FilteringChannelIds {
|
|
||||||
hash, err := hex.DecodeString(id)
|
|
||||||
if err != nil {
|
|
||||||
logrus.Warn("Invalid channel id: ", id)
|
|
||||||
}
|
|
||||||
filteringChannelHashes = append(filteringChannelHashes, hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
myDB.BlockingChannelHashes = blockingChannelHashes
|
|
||||||
myDB.FilteringChannelHashes = filteringChannelHashes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s := &Server{
|
s := &Server{
|
||||||
|
|
no need to start these with N
and many of these are unused
is this really no big deal? seems like an error to me but idk rocksdb
typo: Famlies -> Families
this can be unexported
still need this?
typo
👀