changes per code review
This commit is contained in:
parent
f303907acd
commit
0bcb069e04
3 changed files with 16 additions and 16 deletions
14
db/db.go
14
db/db.go
|
@ -361,9 +361,9 @@ func IterCF(db *grocksdb.DB, opts *IterOptions) <-chan *prefixes.PrefixRowKV {
|
||||||
close(ch)
|
close(ch)
|
||||||
ro.Destroy()
|
ro.Destroy()
|
||||||
if opts.DB != nil {
|
if opts.DB != nil {
|
||||||
|
opts.DoneChan <- struct{}{}
|
||||||
opts.DB.ItMut.Lock()
|
opts.DB.ItMut.Lock()
|
||||||
delete(opts.DB.OpenIterators, iterKey)
|
delete(opts.DB.OpenIterators, iterKey)
|
||||||
opts.DoneChan <- struct{}{}
|
|
||||||
opts.DB.ItMut.Unlock()
|
opts.DB.ItMut.Unlock()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -445,7 +445,7 @@ func (db *ReadOnlyDBColumnFamily) selectFrom(prefix []byte, startKey, stopKey pr
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Prefix and handle
|
// Prefix and handle
|
||||||
options := NewIterateOptions().WithPrefix(prefix).WithCfHandle(handle)
|
options := NewIterateOptions().WithDB(db).WithPrefix(prefix).WithCfHandle(handle)
|
||||||
// Start and stop bounds
|
// Start and stop bounds
|
||||||
options = options.WithStart(startKey.PackKey()).WithStop(stopKey.PackKey()).WithIncludeStop(true)
|
options = options.WithStart(startKey.PackKey()).WithStop(stopKey.PackKey()).WithIncludeStop(true)
|
||||||
// Don't include the key
|
// Don't include the key
|
||||||
|
@ -606,8 +606,8 @@ func GetDBColumnFamilies(name string, secondayPath string, cfNames []string) (*R
|
||||||
LastState: nil,
|
LastState: nil,
|
||||||
Height: 0,
|
Height: 0,
|
||||||
Headers: nil,
|
Headers: nil,
|
||||||
ShutdownChan: make(chan struct{}),
|
ShutdownChan: make(chan struct{}, 1),
|
||||||
DoneChan: make(chan struct{}),
|
DoneChan: make(chan struct{}, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = myDB.ReadDBState() //TODO: Figure out right place for this
|
err = myDB.ReadDBState() //TODO: Figure out right place for this
|
||||||
|
@ -833,7 +833,7 @@ func (db *ReadOnlyDBColumnFamily) InitHeaders() error {
|
||||||
// endKey := prefixes.NewHeaderKey(db.LastState.Height)
|
// endKey := prefixes.NewHeaderKey(db.LastState.Height)
|
||||||
startKeyRaw := startKey.PackKey()
|
startKeyRaw := startKey.PackKey()
|
||||||
// endKeyRaw := endKey.PackKey()
|
// endKeyRaw := endKey.PackKey()
|
||||||
options := NewIterateOptions().WithPrefix([]byte{prefixes.Header}).WithCfHandle(handle)
|
options := NewIterateOptions().WithDB(db).WithPrefix([]byte{prefixes.Header}).WithCfHandle(handle)
|
||||||
options = options.WithIncludeKey(false).WithIncludeValue(true) //.WithIncludeStop(true)
|
options = options.WithIncludeKey(false).WithIncludeValue(true) //.WithIncludeStop(true)
|
||||||
options = options.WithStart(startKeyRaw) //.WithStop(endKeyRaw)
|
options = options.WithStart(startKeyRaw) //.WithStop(endKeyRaw)
|
||||||
|
|
||||||
|
@ -856,7 +856,7 @@ func (db *ReadOnlyDBColumnFamily) InitTxCounts() error {
|
||||||
|
|
||||||
db.TxCounts = stack.NewSliceBacked[uint32](InitialTxCountSize)
|
db.TxCounts = stack.NewSliceBacked[uint32](InitialTxCountSize)
|
||||||
|
|
||||||
options := NewIterateOptions().WithPrefix([]byte{prefixes.TxCount}).WithCfHandle(handle)
|
options := NewIterateOptions().WithDB(db).WithPrefix([]byte{prefixes.TxCount}).WithCfHandle(handle)
|
||||||
options = options.WithIncludeKey(false).WithIncludeValue(true).WithIncludeStop(true)
|
options = options.WithIncludeKey(false).WithIncludeValue(true).WithIncludeStop(true)
|
||||||
|
|
||||||
ch := IterCF(db.DB, options)
|
ch := IterCF(db.DB, options)
|
||||||
|
@ -1080,7 +1080,7 @@ func GenerateTestData(prefix byte, fileName string) {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
options := NewIterateOptions()
|
options := NewIterateOptions().WithDB(db)
|
||||||
options.WithRawKey(true).WithRawValue(true).WithIncludeValue(true)
|
options.WithRawKey(true).WithRawValue(true).WithIncludeValue(true)
|
||||||
options.WithPrefix([]byte{prefix})
|
options.WithPrefix([]byte{prefix})
|
||||||
|
|
||||||
|
|
16
db/db_get.go
16
db/db_get.go
|
@ -94,7 +94,7 @@ func (db *ReadOnlyDBColumnFamily) GetHeaders(height uint32, count uint32) ([][11
|
||||||
|
|
||||||
startKeyRaw := prefixes.NewHeaderKey(height).PackKey()
|
startKeyRaw := prefixes.NewHeaderKey(height).PackKey()
|
||||||
endKeyRaw := prefixes.NewHeaderKey(height + count).PackKey()
|
endKeyRaw := prefixes.NewHeaderKey(height + count).PackKey()
|
||||||
options := NewIterateOptions().WithPrefix([]byte{prefixes.Header}).WithCfHandle(handle)
|
options := NewIterateOptions().WithDB(db).WithPrefix([]byte{prefixes.Header}).WithCfHandle(handle)
|
||||||
options = options.WithIncludeKey(false).WithIncludeValue(true) //.WithIncludeStop(true)
|
options = options.WithIncludeKey(false).WithIncludeValue(true) //.WithIncludeStop(true)
|
||||||
options = options.WithStart(startKeyRaw).WithStop(endKeyRaw)
|
options = options.WithStart(startKeyRaw).WithStop(endKeyRaw)
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ func (db *ReadOnlyDBColumnFamily) GetBalance(hashX []byte) (uint64, uint64, erro
|
||||||
startKeyRaw := startKey.PackKey()
|
startKeyRaw := startKey.PackKey()
|
||||||
endKeyRaw := endKey.PackKey()
|
endKeyRaw := endKey.PackKey()
|
||||||
// Prefix and handle
|
// Prefix and handle
|
||||||
options := NewIterateOptions().WithPrefix([]byte{prefixes.UTXO}).WithCfHandle(handle)
|
options := NewIterateOptions().WithDB(db).WithPrefix([]byte{prefixes.UTXO}).WithCfHandle(handle)
|
||||||
// Start and stop bounds
|
// Start and stop bounds
|
||||||
options = options.WithStart(startKeyRaw).WithStop(endKeyRaw).WithIncludeStop(true)
|
options = options.WithStart(startKeyRaw).WithStop(endKeyRaw).WithIncludeStop(true)
|
||||||
// Don't include the key
|
// Don't include the key
|
||||||
|
@ -346,7 +346,7 @@ func (db *ReadOnlyDBColumnFamily) GetStreamsAndChannelRepostedByChannelHashes(re
|
||||||
for _, reposterChannelHash := range reposterChannelHashes {
|
for _, reposterChannelHash := range reposterChannelHashes {
|
||||||
key := prefixes.NewChannelToClaimKeyWHash(reposterChannelHash)
|
key := prefixes.NewChannelToClaimKeyWHash(reposterChannelHash)
|
||||||
rawKeyPrefix := key.PartialPack(1)
|
rawKeyPrefix := key.PartialPack(1)
|
||||||
options := NewIterateOptions().WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
options := NewIterateOptions().WithDB(db).WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
||||||
options = options.WithIncludeKey(false).WithIncludeValue(true)
|
options = options.WithIncludeKey(false).WithIncludeValue(true)
|
||||||
ch := IterCF(db.DB, options)
|
ch := IterCF(db.DB, options)
|
||||||
// for stream := range Iterate(db.DB, prefixes.ChannelToClaim, []byte{reposterChannelHash}, false) {
|
// for stream := range Iterate(db.DB, prefixes.ChannelToClaim, []byte{reposterChannelHash}, false) {
|
||||||
|
@ -420,7 +420,7 @@ func (db *ReadOnlyDBColumnFamily) GetShortClaimIdUrl(name string, normalizedName
|
||||||
log.Printf("partialKey: %#v\n", partialKey)
|
log.Printf("partialKey: %#v\n", partialKey)
|
||||||
keyPrefix := partialKey.PartialPack(2)
|
keyPrefix := partialKey.PartialPack(2)
|
||||||
// Prefix and handle
|
// Prefix and handle
|
||||||
options := NewIterateOptions().WithPrefix(prefix).WithCfHandle(handle)
|
options := NewIterateOptions().WithDB(db).WithPrefix(prefix).WithCfHandle(handle)
|
||||||
// Start and stop bounds
|
// Start and stop bounds
|
||||||
options = options.WithStart(keyPrefix).WithStop(keyPrefix)
|
options = options.WithStart(keyPrefix).WithStop(keyPrefix)
|
||||||
// Don't include the key
|
// Don't include the key
|
||||||
|
@ -518,7 +518,7 @@ func (db *ReadOnlyDBColumnFamily) GetActiveAmount(claimHash []byte, txoType uint
|
||||||
startKeyRaw := startKey.PartialPack(3)
|
startKeyRaw := startKey.PartialPack(3)
|
||||||
endKeyRaw := endKey.PartialPack(3)
|
endKeyRaw := endKey.PartialPack(3)
|
||||||
// Prefix and handle
|
// Prefix and handle
|
||||||
options := NewIterateOptions().WithPrefix([]byte{prefixes.ActiveAmount}).WithCfHandle(handle)
|
options := NewIterateOptions().WithDB(db).WithPrefix([]byte{prefixes.ActiveAmount}).WithCfHandle(handle)
|
||||||
// Start and stop bounds
|
// Start and stop bounds
|
||||||
options = options.WithStart(startKeyRaw).WithStop(endKeyRaw)
|
options = options.WithStart(startKeyRaw).WithStop(endKeyRaw)
|
||||||
// Don't include the key
|
// Don't include the key
|
||||||
|
@ -674,7 +674,7 @@ func (db *ReadOnlyDBColumnFamily) ControllingClaimIter() <-chan *prefixes.Prefix
|
||||||
key := prefixes.NewClaimTakeoverKey("")
|
key := prefixes.NewClaimTakeoverKey("")
|
||||||
var rawKeyPrefix []byte = nil
|
var rawKeyPrefix []byte = nil
|
||||||
rawKeyPrefix = key.PartialPack(0)
|
rawKeyPrefix = key.PartialPack(0)
|
||||||
options := NewIterateOptions().WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
options := NewIterateOptions().WithDB(db).WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
||||||
options = options.WithIncludeValue(true) //.WithIncludeStop(true)
|
options = options.WithIncludeValue(true) //.WithIncludeStop(true)
|
||||||
ch := IterCF(db.DB, options)
|
ch := IterCF(db.DB, options)
|
||||||
return ch
|
return ch
|
||||||
|
@ -785,7 +785,7 @@ func (db *ReadOnlyDBColumnFamily) BidOrderNameIter(normalizedName string) <-chan
|
||||||
key := prefixes.NewBidOrderKey(normalizedName)
|
key := prefixes.NewBidOrderKey(normalizedName)
|
||||||
var rawKeyPrefix []byte = nil
|
var rawKeyPrefix []byte = nil
|
||||||
rawKeyPrefix = key.PartialPack(1)
|
rawKeyPrefix = key.PartialPack(1)
|
||||||
options := NewIterateOptions().WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
options := NewIterateOptions().WithDB(db).WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
||||||
options = options.WithIncludeValue(true) //.WithIncludeStop(true)
|
options = options.WithIncludeValue(true) //.WithIncludeStop(true)
|
||||||
ch := IterCF(db.DB, options)
|
ch := IterCF(db.DB, options)
|
||||||
return ch
|
return ch
|
||||||
|
@ -803,7 +803,7 @@ func (db *ReadOnlyDBColumnFamily) ClaimShortIdIter(normalizedName string, claimI
|
||||||
} else {
|
} else {
|
||||||
rawKeyPrefix = key.PartialPack(1)
|
rawKeyPrefix = key.PartialPack(1)
|
||||||
}
|
}
|
||||||
options := NewIterateOptions().WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
options := NewIterateOptions().WithDB(db).WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
||||||
options = options.WithIncludeValue(true) //.WithIncludeStop(true)
|
options = options.WithIncludeValue(true) //.WithIncludeStop(true)
|
||||||
ch := IterCF(db.DB, options)
|
ch := IterCF(db.DB, options)
|
||||||
return ch
|
return ch
|
||||||
|
|
|
@ -326,7 +326,7 @@ func (db *ReadOnlyDBColumnFamily) ResolveClaimInChannel(channelHash []byte, norm
|
||||||
|
|
||||||
key := prefixes.NewChannelToClaimKey(channelHash, normalizedName)
|
key := prefixes.NewChannelToClaimKey(channelHash, normalizedName)
|
||||||
rawKeyPrefix := key.PartialPack(2)
|
rawKeyPrefix := key.PartialPack(2)
|
||||||
options := NewIterateOptions().WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
options := NewIterateOptions().WithDB(db).WithCfHandle(handle).WithPrefix(rawKeyPrefix)
|
||||||
options = options.WithIncludeValue(true) //.WithIncludeStop(true)
|
options = options.WithIncludeValue(true) //.WithIncludeStop(true)
|
||||||
ch := IterCF(db.DB, options)
|
ch := IterCF(db.DB, options)
|
||||||
// TODO: what's a good default size for this?
|
// TODO: what's a good default size for this?
|
||||||
|
|
Loading…
Reference in a new issue