Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdimidium committed Apr 16, 2024
1 parent 010016b commit 41cc836
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 50 deletions.
28 changes: 19 additions & 9 deletions chotki.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,14 @@ func (cho *Chotki) OpenTCP(tcp *toytlv.TCPDepot) {
})
}

func (cho *Chotki) ReOpenTCP(tcp *toytlv.TCPDepot) {
func (cho *Chotki) ReOpenTCP(tcp *toytlv.TCPDepot) error {
cho.OpenTCP(tcp)
// ...
io := pebble.IterOptions{}
i := cho.db.NewIter(&io)
i, err := cho.db.NewIter(&io)
if err != nil {
return err
}
for i.SeekGE([]byte{'l'}); i.Valid() && i.Key()[0] == 'L'; i.Next() {
address := string(i.Key()[1:])
err := tcp.Listen(address)
Expand All @@ -213,6 +216,7 @@ func (cho *Chotki) ReOpenTCP(tcp *toytlv.TCPDepot) {
}
}
_ = i.Close()
return nil
}

func (cho *Chotki) AddPacketHose(name string) (feed toyqueue.FeedCloser) {
Expand Down Expand Up @@ -427,33 +431,39 @@ func (cho *Chotki) ObjectKeyRange(oid rdx.ID) (fro, til []byte) {
}

// returns nil for "not found"
func (cho *Chotki) ObjectIterator(oid rdx.ID) *pebble.Iterator {
func (cho *Chotki) ObjectIterator(oid rdx.ID) (*pebble.Iterator, error) {
fro, til := cho.ObjectKeyRange(oid)
io := pebble.IterOptions{
LowerBound: fro,
UpperBound: til,
}
it := cho.db.NewIter(&io)
it, err := cho.db.NewIter(&io)
if err != nil {
return nil, err
}
if it.SeekGE(fro) {
id, rdt := OKeyIdRdt(it.Key())
if rdt == 'O' && id == oid {
return it
return it, nil
}
}
_ = it.Close()
return nil
return nil, nil
}

func (cho *Chotki) GetFieldTLV(id rdx.ID) (rdt byte, tlv []byte) {
func (cho *Chotki) GetFieldTLV(id rdx.ID) (rdt byte, tlv []byte, err error) {
return GetFieldTLV(cho.db, id)
}

func GetFieldTLV(reader pebble.Reader, id rdx.ID) (rdt byte, tlv []byte) {
func GetFieldTLV(reader pebble.Reader, id rdx.ID) (rdt byte, tlv []byte, err error) {
key := OKey(id, 'A')
it := reader.NewIter(&pebble.IterOptions{
it, err := reader.NewIter(&pebble.IterOptions{
LowerBound: []byte{'O'},
UpperBound: []byte{'P'},
})
if err != nil {
return 0, nil, err
}
if it.SeekGE(key) {
fact, r := OKeyIdRdt(it.Key())
if fact == id {
Expand Down
33 changes: 24 additions & 9 deletions debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,51 @@ func ChotkiKVString(key, value []byte) string {
return string(line)
}

func (cho *Chotki) DumpAll() {
_, _ = fmt.Fprintf(os.Stderr, "=====OBJECTS=====\n")
cho.DumpObjects()
_, _ = fmt.Fprintf(os.Stderr, "=====VVS=====\n")
cho.DumpVV()
func (cho *Chotki) DumpAll() error {
fmt.Fprintf(os.Stderr, "=====OBJECTS=====\n")
if err := cho.DumpObjects(); err != nil {
return err
}

fmt.Fprintf(os.Stderr, "=====VVS=====\n")
if err := cho.DumpVV(); err != nil {
return err
}

return nil
}

func (cho *Chotki) DumpObjects() {
func (cho *Chotki) DumpObjects() error {
io := pebble.IterOptions{
LowerBound: []byte{'O'},
UpperBound: []byte{'P'},
}
i := cho.db.NewIter(&io)
i, err := cho.db.NewIter(&io)
if err != nil {
return nil

Check failure on line 44 in debug.go

View workflow job for this annotation

GitHub Actions / Lint

error is not nil (line 42) but it returns nil (nilerr)
}
for i.SeekGE([]byte{'O'}); i.Valid(); i.Next() {
_, _ = fmt.Fprintln(os.Stderr, ChotkiKVString(i.Key(), i.Value()))
}
return nil
}

func (cho *Chotki) DumpVV() {
func (cho *Chotki) DumpVV() error {
io := pebble.IterOptions{
LowerBound: []byte{'V'},
UpperBound: []byte{'W'},
}
i := cho.db.NewIter(&io)
i, err := cho.db.NewIter(&io)
if err != nil {
return err
}
for i.SeekGE(VKey(rdx.ID0)); i.Valid(); i.Next() {
id := rdx.IDFromBytes(i.Key()[1:])
vv := make(rdx.VV)
_ = vv.PutTLV(i.Value())
fmt.Printf("%s -> \t%s\n", id.String(), vv.String())
}
return nil
}

func DumpVPacket(vvs map[rdx.ID]rdx.VV) {
Expand Down
41 changes: 22 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,43 @@ module github.com/drpcorg/chotki
go 1.21.4

require (
github.com/cockroachdb/pebble v1.0.0
github.com/cockroachdb/pebble v1.1.0
github.com/ergochat/readline v0.1.0
github.com/learn-decentralized-systems/toykv v0.0.0-20231218053616-8d6e32388877
github.com/learn-decentralized-systems/toylog v0.1.6
github.com/learn-decentralized-systems/toyqueue v0.1.5
github.com/learn-decentralized-systems/toytlv v0.2.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
)

require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/redact v1.0.8 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.0 // indirect
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
golang.org/x/exp v0.0.0-20200513190911-00229845015e // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.3 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 41cc836

Please sign in to comment.