rocksdb #29

Merged
jeffreypicard merged 93 commits from feature/27/jeffreypicard/rocksdb into master 2022-04-29 17:04:01 +02:00
6 changed files with 34 additions and 34 deletions
Showing only changes of commit 78715bc128 - Show all commits

View file

@ -10,6 +10,7 @@ import (
dbpkg "github.com/lbryio/hub/db"
"github.com/lbryio/hub/db/prefixes"
"github.com/lbryio/lbry.go/v2/extras/util"
"github.com/linxGnu/grocksdb"
)
@ -282,7 +283,7 @@ func TestOpenFullDB(t *testing.T) {
// FIXME: Needs new data format
func TestResolve(t *testing.T) {
filePath := "../testdata/P_cat.csv"
filePath := "../testdata/P_resolve.csv"
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
if err != nil {
t.Error(err)
@ -414,19 +415,20 @@ func TestGetTXOToClaim(t *testing.T) {
// TestPrintClaimToTXO Utility function to cat the ClaimToTXO csv.
func TestPrintClaimToTXO(t *testing.T) {
filePath := "../testdata/E_2.csv"
filePath := "../testdata/E_resolve.csv"
CatCSV(filePath)
}
// TestGetClaimToTXO Tests getting a ClaimToTXO value from the db.
func TestGetClaimToTXO(t *testing.T) {
claimHashStr := "00000324e40fcb63a0b517a3660645e9bd99244a"
claimHashStr := "2556ed1cab9d17f2a9392030a9ad7f5d138f11bd"
want := uint32(0x6284e3)
claimHash, err := hex.DecodeString(claimHashStr)
if err != nil {
t.Error(err)
return
}
filePath := "../testdata/E_2.csv"
filePath := "../testdata/E_resolve.csv"
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
if err != nil {
t.Error(err)
@ -438,29 +440,38 @@ func TestGetClaimToTXO(t *testing.T) {
t.Error(err)
return
}
log.Println(res)
if res.TxNum != want {
t.Errorf("Expected %d, got %d", want, res.TxNum)
}
log.Printf("res: %#v\n", res)
}
// TestPrintClaimTakeover Utility function to cat the ClaimTakeover csv.
func TestPrintClaimTakeover(t *testing.T) {
filePath := "../testdata/P_cat.csv"
filePath := "../testdata/P_resolve.csv"
CatCSV(filePath)
}
// TestGetControlingClaim Tests getting a controlling claim value from the db
// based on a name.
func TestGetControllingClaim(t *testing.T) {
filePath := "../testdata/P_cat.csv"
claimName := util.NormalizeName("@Styxhexenhammer666")
claimHash := "2556ed1cab9d17f2a9392030a9ad7f5d138f11bd"
filePath := "../testdata/P_resolve.csv"
db, _, toDefer, err := OpenAndFillTmpDBColumnFamlies(filePath)
if err != nil {
t.Error(err)
return
}
defer toDefer()
res, err := dbpkg.GetControllingClaim(db, "cat")
res, err := dbpkg.GetControllingClaim(db, claimName)
if err != nil {
t.Error(err)
return
}
got := hex.EncodeToString(res.ClaimHash)
if claimHash != got {
t.Errorf("Expected %s, got %s", claimHash, got)
}
log.Println(res)
}

13
main.go
View file

@ -3,6 +3,7 @@ package main
import (
"bytes"
"context"
"encoding/hex"
"fmt"
"log"
"os"
lyoshenka commented 2022-04-15 16:10:08 +02:00 (Migrated from github.com)
Review

prolly here just for profiling, right?

prolly here just for profiling, right?
jeffreypicard commented 2022-04-20 15:55:49 +02:00 (Migrated from github.com)
Review

yeah

yeah
@ -110,10 +111,16 @@ func main() {
return
} else if args.CmdType == server.DBCmd3 {
// channelHash, _ := hex.DecodeString("2556ed1cab9d17f2a9392030a9ad7f5d138f11bd")
var rawPrefix byte = prefixes.DBState
channelHash, _ := hex.DecodeString("2556ed1cab9d17f2a9392030a9ad7f5d138f11bd")
// name := util.NormalizeName("@Styxhexenhammer666")
var rawPrefix byte = prefixes.ClaimToTXO
var startRaw []byte = nil
prefix := []byte{rawPrefix}
columnFamily := string(prefix)
// start := prefixes.NewClaimTakeoverKey(name)
start := prefixes.NewClaimToTXOKey(channelHash)
startRaw = start.PackKey()
// start := &prefixes.ChannelCountKey{
// Prefix: prefix,
// ChannelHash: channelHash,
@ -123,7 +130,7 @@ func main() {
options := &db.IterOptions{
FillCache: false,
Prefix: prefix,
Start: nil,
Start: startRaw,
Stop: nil,
IncludeStart: true,
IncludeStop: false,

11
testdata/E_2.csv vendored
View file

@ -1,11 +0,0 @@
E,,
E,45000000a420c44374f4f399ab4807fa1901eefc87,0297ec2100000297ec21000000000000000f42400100246167656e63652d64c3a974727569742c2d6e6f7576656175782d736b696e732d6c65616b
E,45000000c27eef5ea69e0d73f118826c7e326bb469,00371d66000000371d660000000000001dcd650001000e4d696e696174757265486f757365
E,4500000110e40894573f528c393fbcec7a472ec853,01516b32000001516b3200000000000000989680010021696f2d3137372d4e6f616d2d43686f6d736b792d6f6e2d434f494e54454c50524f
E,4500000324e40fcb63a0b517a3660645e9bd99244a,030bb6ba0000030bb6ba000000000000000f424001001b436f6e616e2d4578696c65732d526169642d4561726c792d457261
E,45000003d1538a0f19f5cd4bc1a62cc294f5c89934,011c7c990000011c7c99000000000000000f424001001130322d636172726167652d68616e646c65
E,45000008d47beeff8325e795a8604226145b01702b,02dbb2a2000002dbb2a2000000000000000186a001001039643336363661336161313231376138
E,4500000906499e073e94370ceff37cb21c28212444,0369842d00000369842d000000000000000186a001001033333465356465363139306534323466
E,45000009c3172e034a255f3c03566dca84bb9f046a,0225c69c000002251b0f0000000000000007a120010028617574686f722d73746f726965732d706f64636173742d657069736f64652d3734332d6b6172656e
E,45000009ca6e0caaaef16872b4bd4f6f1b8c2363e2,02b16956000002b16956000000000000000f4240010027554e2d504f55522d43454e542d28312d292d28536f72616c2c2d4162c3a963c3a9646169726529
E,4500000ad9ded2e15d18987900d09e9b29ef33d03e,02c972b3000002c972b3000000000000000186a0010006313331333333
Internal server error - Forgejo: Beyond coding. We forge.

500

Internal server error

Forgejo version: 9.0.1+gitea-1.22.0