From 0f8a4af62ebc2113e477eb5cab13daa40a69a8cd Mon Sep 17 00:00:00 2001 From: Alexandr Burdiyan Date: Sun, 18 Aug 2024 00:01:27 +0200 Subject: [PATCH] deps(backend): adopt sqlite package Instead of treating our SQLite bindings as a fork of crawshaw.io/sqlite we now adopt the package directly into our code base. The upstream is abandoned, and we've made modifications to it beyond the point of converging the forks. We'll be making even more changes in the face of new features introduced in Go 1.23, so it make sense to adopt the package now and start ownging it entirely. --- .plzconfig | 1 - .vscode/settings.json | 1 - backend/BUILD.plz | 18 ++--- backend/api/activity/v1alpha/activity.go | 3 +- backend/api/apis.go | 3 +- backend/api/documents/v3alpha/documents.go | 5 +- backend/api/entities/v1alpha/entities.go | 5 +- backend/api/groups/v1alpha/db.go.off | 4 +- backend/api/groups/v1alpha/groups.go.off | 4 +- backend/api/networking/v1alpha/networking.go | 4 +- backend/cmd/monitord/Dockerfile | 1 - backend/cmd/relayd/Dockerfile | 1 - backend/cmd/seed-daemon/Dockerfile | 1 - backend/cmd/seed-site/Dockerfile | 1 - backend/cmd/seed-site/sites/daemon.go.off | 2 +- backend/cmd/seed-site/sites/sites.go.off | 4 +- backend/daemon/daemon.go | 3 +- backend/daemon/metrics.go | 3 +- backend/index/blockstore.go | 5 +- backend/index/blockstore_test.go | 3 +- backend/index/index.go | 5 +- backend/index/index_blockstore.go | 3 +- backend/index/index_sql.go | 4 +- backend/index/reindex.go | 5 +- backend/lndhub/lndhub.go | 4 +- backend/lndhub/lndhub_test.go | 4 +- backend/lndhub/lndhubsql/lndhub.go | 2 +- backend/lndhub/lndhubsql/queries.gen.go | 2 +- backend/mttnet/connect.go | 4 +- backend/mttnet/last_seen.go | 3 +- backend/mttnet/list_blobs.go | 5 +- backend/mttnet/list_peers.go | 5 +- backend/mttnet/mttnet.go | 3 +- backend/mttnet/providing.go | 5 +- backend/mttnet/syncing.go | 5 +- backend/storage/dbext/dbext.go | 2 +- backend/storage/schema_test.go | 4 +- backend/storage/sqlite.go | 4 +- backend/storage/storage.go | 2 +- backend/storage/storage_migrations.go | 4 +- backend/syncing/syncing.go | 5 +- backend/syncing/worker.go | 3 +- backend/util/dqb/dqb.go | 2 +- .../util}/sqlite/.gitignore | 0 {third_party => backend/util}/sqlite/LICENSE | 0 {third_party => backend/util}/sqlite/Makefile | 0 backend/util/sqlite/NOTICE | 3 + {third_party => backend/util}/sqlite/auth.go | 0 .../util}/sqlite/auth_test.go | 2 +- .../util}/sqlite/backup.go | 0 .../util}/sqlite/backup_test.go | 4 +- {third_party => backend/util}/sqlite/blob.go | 0 .../util}/sqlite/blob_test.go | 2 +- .../util}/sqlite/blocking_step.c | 0 .../util}/sqlite/blocking_step.h | 0 .../util}/sqlite/c/dummy.go | 0 .../util}/sqlite/c/sqlite3.c | 0 {third_party => backend/util}/sqlite/doc.go | 17 ++--- {third_party => backend/util}/sqlite/dummy.go | 3 +- {third_party => backend/util}/sqlite/error.go | 0 .../util}/sqlite/export_test.go | 0 .../util}/sqlite/extension.go | 0 .../util}/sqlite/extension_test.go | 2 +- {third_party => backend/util}/sqlite/func.go | 0 .../util}/sqlite/func_test.go | 2 +- .../util}/sqlite/incrementor.go | 0 .../util}/sqlite/incrementor_test.go | 0 {third_party => backend/util}/sqlite/link.go | 0 .../util}/sqlite/openflags.go | 0 .../util}/sqlite/session.go | 0 .../util}/sqlite/session_test.go | 4 +- .../util}/sqlite/snapshot.go | 0 .../util}/sqlite/snapshot_test.go | 4 +- .../util}/sqlite/sqlite.go | 0 .../util}/sqlite/sqlite3.h | 0 .../util}/sqlite/sqlite3ext.h | 0 .../util}/sqlite/sqlite_test.go | 4 +- .../util}/sqlite/sqlitex/buffer.go | 2 +- .../util}/sqlite/sqlitex/buffer_test.go | 2 +- .../util}/sqlite/sqlitex/exec.go | 4 +- .../util}/sqlite/sqlitex/exec_test.go | 4 +- .../util}/sqlite/sqlitex/file.go | 2 +- .../util}/sqlite/sqlitex/file_test.go | 3 +- .../util}/sqlite/sqlitex/pool.go | 2 +- .../util}/sqlite/sqlitex/pool_test.go | 4 +- .../util}/sqlite/sqlitex/query.go | 2 +- .../util}/sqlite/sqlitex/rand_id.go | 2 +- .../util}/sqlite/sqlitex/rand_id_test.go | 4 +- .../util}/sqlite/sqlitex/savepoint.go | 2 +- .../util}/sqlite/sqlitex/savepoint_test.go | 2 +- .../util}/sqlite/sqlitex/snapshot.go | 2 +- .../util}/sqlite/sqlitex/tx.go | 2 +- .../util}/sqlite/static.go | 0 .../util}/sqlite/wrappers.c | 0 .../util}/sqlite/wrappers.h | 0 backend/util/sqlitedbg/sqlitedbg.go | 4 +- backend/util/sqlitedbg/sqlitedbg_test.go | 2 +- backend/util/sqlitegen/example/queries.gen.go | 2 +- .../util/sqlitegen/example/schema/schema.go | 4 +- backend/util/sqlitegen/queries.go | 2 +- backend/util/sqlitegen/queries_test.golden | 2 +- backend/util/sqlitegen/schema.go | 4 +- backend/util/sqlitegen/schema_test.go | 4 +- backend/util/sqlitegen/sqlitegen.go | 2 +- backend/wallet/wallet.go | 3 +- backend/wallet/wallet_test.go | 3 +- backend/wallet/walletsql/queries.gen.go | 2 +- backend/wallet/walletsql/wallet.go | 2 +- go.mod | 4 +- third_party/BUILD.plz | 15 ----- third_party/sqlite/.gitrepo | 12 ---- third_party/sqlite/.travis.yml | 11 --- third_party/sqlite/README.md | 67 ------------------- third_party/sqlite/appveyor.yml | 26 ------- third_party/sqlite/go.mod | 5 -- third_party/sqlite/go.sum | 2 - 116 files changed, 149 insertions(+), 272 deletions(-) rename {third_party => backend/util}/sqlite/.gitignore (100%) rename {third_party => backend/util}/sqlite/LICENSE (100%) rename {third_party => backend/util}/sqlite/Makefile (100%) create mode 100644 backend/util/sqlite/NOTICE rename {third_party => backend/util}/sqlite/auth.go (100%) rename {third_party => backend/util}/sqlite/auth_test.go (97%) rename {third_party => backend/util}/sqlite/backup.go (100%) rename {third_party => backend/util}/sqlite/backup_test.go (96%) rename {third_party => backend/util}/sqlite/blob.go (100%) rename {third_party => backend/util}/sqlite/blob_test.go (99%) rename {third_party => backend/util}/sqlite/blocking_step.c (100%) rename {third_party => backend/util}/sqlite/blocking_step.h (100%) rename {third_party => backend/util}/sqlite/c/dummy.go (100%) rename {third_party => backend/util}/sqlite/c/sqlite3.c (100%) rename {third_party => backend/util}/sqlite/doc.go (96%) rename {third_party => backend/util}/sqlite/dummy.go (91%) rename {third_party => backend/util}/sqlite/error.go (100%) rename {third_party => backend/util}/sqlite/export_test.go (100%) rename {third_party => backend/util}/sqlite/extension.go (100%) rename {third_party => backend/util}/sqlite/extension_test.go (99%) rename {third_party => backend/util}/sqlite/func.go (100%) rename {third_party => backend/util}/sqlite/func_test.go (99%) rename {third_party => backend/util}/sqlite/incrementor.go (100%) rename {third_party => backend/util}/sqlite/incrementor_test.go (100%) rename {third_party => backend/util}/sqlite/link.go (100%) rename {third_party => backend/util}/sqlite/openflags.go (100%) rename {third_party => backend/util}/sqlite/session.go (100%) rename {third_party => backend/util}/sqlite/session_test.go (99%) rename {third_party => backend/util}/sqlite/snapshot.go (100%) rename {third_party => backend/util}/sqlite/snapshot_test.go (98%) rename {third_party => backend/util}/sqlite/sqlite.go (100%) rename {third_party => backend/util}/sqlite/sqlite3.h (100%) rename {third_party => backend/util}/sqlite/sqlite3ext.h (100%) rename {third_party => backend/util}/sqlite/sqlite_test.go (99%) rename {third_party => backend/util}/sqlite/sqlitex/buffer.go (99%) rename {third_party => backend/util}/sqlite/sqlitex/buffer_test.go (99%) rename {third_party => backend/util}/sqlite/sqlitex/exec.go (98%) rename {third_party => backend/util}/sqlite/sqlitex/exec_test.go (98%) rename {third_party => backend/util}/sqlite/sqlitex/file.go (99%) rename {third_party => backend/util}/sqlite/sqlitex/file_test.go (97%) rename {third_party => backend/util}/sqlite/sqlitex/pool.go (99%) rename {third_party => backend/util}/sqlite/sqlitex/pool_test.go (98%) rename {third_party => backend/util}/sqlite/sqlitex/query.go (98%) rename {third_party => backend/util}/sqlite/sqlitex/rand_id.go (98%) rename {third_party => backend/util}/sqlite/sqlitex/rand_id_test.go (96%) rename {third_party => backend/util}/sqlite/sqlitex/savepoint.go (99%) rename {third_party => backend/util}/sqlite/sqlitex/savepoint_test.go (99%) rename {third_party => backend/util}/sqlite/sqlitex/snapshot.go (97%) rename {third_party => backend/util}/sqlite/sqlitex/tx.go (97%) rename {third_party => backend/util}/sqlite/static.go (100%) rename {third_party => backend/util}/sqlite/wrappers.c (100%) rename {third_party => backend/util}/sqlite/wrappers.h (100%) delete mode 100644 third_party/BUILD.plz delete mode 100644 third_party/sqlite/.gitrepo delete mode 100644 third_party/sqlite/.travis.yml delete mode 100644 third_party/sqlite/README.md delete mode 100644 third_party/sqlite/appveyor.yml delete mode 100644 third_party/sqlite/go.mod delete mode 100644 third_party/sqlite/go.sum diff --git a/.plzconfig b/.plzconfig index 39d21b20..30a0c8f6 100644 --- a/.plzconfig +++ b/.plzconfig @@ -4,7 +4,6 @@ SelfUpdate = false [parse] BlacklistDirs = "node_modules" BlacklistDirs = "target" -BlacklistDirs = "third_party" BuildDefsDir = "build/rules" BuildFileName = "BUILD.plz" GitFunctions = true diff --git a/.vscode/settings.json b/.vscode/settings.json index 18d28b02..2673eeec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -80,7 +80,6 @@ "-", "-plz-out", "+backend", - "+third_party", "+proto", "+build" ] diff --git a/backend/BUILD.plz b/backend/BUILD.plz index 0161e6dc..3b9e3a4f 100644 --- a/backend/BUILD.plz +++ b/backend/BUILD.plz @@ -5,7 +5,11 @@ subinclude("//build/rules/go:defs", "//build/rules/codegen:defs") go_binary( name = "seed-daemon", srcs = glob( - ["**/*.go"], + [ + "**/*.go", + "**/*.c", + "**/*.h", + ], exclude = ["**/*_test.go"], ) + [ "//backend/lndhub/lndhubsql:go_library", @@ -17,9 +21,6 @@ go_binary( gomod = "//:gomod", package = "./cmd/seed-daemon", visibility = ["PUBLIC"], - deps = [ - "//third_party:sqlite", - ], ) go_binary( @@ -35,7 +36,11 @@ go_binary( go_binary( name = "seed-gateway", srcs = glob( - ["**/*.go"], + [ + "**/*.go", + "**/*.c", + "**/*.h", + ], exclude = ["**/*_test.go"], ) + [ "//backend/lndhub/lndhubsql:go_library", @@ -47,7 +52,4 @@ go_binary( gomod = "//:gomod", package = "./cmd/seed-gateway", visibility = ["PUBLIC"], - deps = [ - "//third_party:sqlite", - ], ) diff --git a/backend/api/activity/v1alpha/activity.go b/backend/api/activity/v1alpha/activity.go index bc82ee99..811c9cce 100644 --- a/backend/api/activity/v1alpha/activity.go +++ b/backend/api/activity/v1alpha/activity.go @@ -5,7 +5,8 @@ import ( activity "seed/backend/genproto/activity/v1alpha" "time" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + "google.golang.org/grpc" ) diff --git a/backend/api/apis.go b/backend/api/apis.go index 91ded905..47bd3da1 100644 --- a/backend/api/apis.go +++ b/backend/api/apis.go @@ -13,7 +13,8 @@ import ( "seed/backend/mttnet" "seed/backend/syncing" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + "google.golang.org/grpc" ) diff --git a/backend/api/documents/v3alpha/documents.go b/backend/api/documents/v3alpha/documents.go index 9f158fa8..180a87f4 100644 --- a/backend/api/documents/v3alpha/documents.go +++ b/backend/api/documents/v3alpha/documents.go @@ -15,8 +15,9 @@ import ( "seed/backend/util/dqb" "seed/backend/util/errutil" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" cbornode "github.com/ipfs/go-ipld-cbor" diff --git a/backend/api/entities/v1alpha/entities.go b/backend/api/entities/v1alpha/entities.go index 824af95d..fbfee723 100644 --- a/backend/api/entities/v1alpha/entities.go +++ b/backend/api/entities/v1alpha/entities.go @@ -18,8 +18,9 @@ import ( "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + "golang.org/x/exp/slices" "google.golang.org/grpc" ) diff --git a/backend/api/groups/v1alpha/db.go.off b/backend/api/groups/v1alpha/db.go.off index bff98a4f..fcf907da 100644 --- a/backend/api/groups/v1alpha/db.go.off +++ b/backend/api/groups/v1alpha/db.go.off @@ -10,8 +10,8 @@ import ( "seed/backend/pkg/errutil" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" "github.com/ipfs/go-cid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/backend/api/groups/v1alpha/groups.go.off b/backend/api/groups/v1alpha/groups.go.off index 8fca630d..a6fbff68 100644 --- a/backend/api/groups/v1alpha/groups.go.off +++ b/backend/api/groups/v1alpha/groups.go.off @@ -27,8 +27,8 @@ import ( "sync" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p/core/peer" "github.com/multiformats/go-multiaddr" diff --git a/backend/api/networking/v1alpha/networking.go b/backend/api/networking/v1alpha/networking.go index 79f09f33..4e0e47cc 100644 --- a/backend/api/networking/v1alpha/networking.go +++ b/backend/api/networking/v1alpha/networking.go @@ -12,8 +12,8 @@ import ( "seed/backend/util/dqb" "strings" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" "github.com/libp2p/go-libp2p/core/peer" "google.golang.org/grpc" diff --git a/backend/cmd/monitord/Dockerfile b/backend/cmd/monitord/Dockerfile index 09bd5595..c0768c38 100644 --- a/backend/cmd/monitord/Dockerfile +++ b/backend/cmd/monitord/Dockerfile @@ -2,7 +2,6 @@ FROM golang:1.23.0-alpine AS builder WORKDIR /code COPY go.mod go.sum ./ -COPY third_party ./third_party RUN go mod download COPY backend ./backend RUN apk add build-base diff --git a/backend/cmd/relayd/Dockerfile b/backend/cmd/relayd/Dockerfile index 4043bc67..1d38408a 100644 --- a/backend/cmd/relayd/Dockerfile +++ b/backend/cmd/relayd/Dockerfile @@ -2,7 +2,6 @@ FROM golang:1.23.0-alpine AS builder WORKDIR /code COPY go.mod go.sum ./ -COPY third_party ./third_party RUN go mod download COPY backend ./backend RUN go install ./backend/cmd/relayd/ diff --git a/backend/cmd/seed-daemon/Dockerfile b/backend/cmd/seed-daemon/Dockerfile index 272337aa..3ebc162e 100644 --- a/backend/cmd/seed-daemon/Dockerfile +++ b/backend/cmd/seed-daemon/Dockerfile @@ -5,7 +5,6 @@ ARG COMMIT_HASH ARG BRANCH ARG DATE COPY go.mod go.sum ./ -COPY third_party ./third_party RUN go mod download COPY backend ./backend COPY monitoring ./monitoring diff --git a/backend/cmd/seed-site/Dockerfile b/backend/cmd/seed-site/Dockerfile index 0b0346ab..2c5ca965 100644 --- a/backend/cmd/seed-site/Dockerfile +++ b/backend/cmd/seed-site/Dockerfile @@ -5,7 +5,6 @@ ARG COMMIT_HASH ARG BRANCH ARG DATE COPY go.mod go.sum ./ -COPY third_party ./third_party RUN go mod download COPY backend ./backend COPY monitoring ./monitoring diff --git a/backend/cmd/seed-site/sites/daemon.go.off b/backend/cmd/seed-site/sites/daemon.go.off index fdd1a8f3..673dde92 100644 --- a/backend/cmd/seed-site/sites/daemon.go.off +++ b/backend/cmd/seed-site/sites/daemon.go.off @@ -17,7 +17,7 @@ import ( "seed/backend/pkg/future" "seed/backend/pkg/libp2px" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" "github.com/multiformats/go-multiaddr" "google.golang.org/grpc" ) diff --git a/backend/cmd/seed-site/sites/sites.go.off b/backend/cmd/seed-site/sites/sites.go.off index 0b1f90a7..f5795451 100644 --- a/backend/cmd/seed-site/sites/sites.go.off +++ b/backend/cmd/seed-site/sites/sites.go.off @@ -22,8 +22,8 @@ import ( rpcpeer "google.golang.org/grpc/peer" "google.golang.org/grpc/status" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p/core/peer" "github.com/multiformats/go-multiaddr" diff --git a/backend/daemon/daemon.go b/backend/daemon/daemon.go index 3b855313..2f2afa17 100644 --- a/backend/daemon/daemon.go +++ b/backend/daemon/daemon.go @@ -23,7 +23,8 @@ import ( "seed/backend/util/future" "seed/backend/wallet" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + "github.com/ipfs/boxo/exchange" "github.com/ipfs/boxo/exchange/offline" "go.opentelemetry.io/otel" diff --git a/backend/daemon/metrics.go b/backend/daemon/metrics.go index 9ae887e9..f631c447 100644 --- a/backend/daemon/metrics.go +++ b/backend/daemon/metrics.go @@ -3,7 +3,8 @@ package daemon import ( "runtime" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/collectors" "github.com/prometheus/client_golang/prometheus/promauto" diff --git a/backend/index/blockstore.go b/backend/index/blockstore.go index b79f158e..3fa83441 100644 --- a/backend/index/blockstore.go +++ b/backend/index/blockstore.go @@ -6,8 +6,9 @@ import ( "seed/backend/ipfs" "seed/backend/util/dqb" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + blockstore "github.com/ipfs/boxo/blockstore" blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" diff --git a/backend/index/blockstore_test.go b/backend/index/blockstore_test.go index 0f424793..974a9a43 100644 --- a/backend/index/blockstore_test.go +++ b/backend/index/blockstore_test.go @@ -8,7 +8,8 @@ import ( "seed/backend/util/must" "testing" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" cbornode "github.com/ipfs/go-ipld-cbor" diff --git a/backend/index/index.go b/backend/index/index.go index 0be45dd2..a9c95399 100644 --- a/backend/index/index.go +++ b/backend/index/index.go @@ -14,8 +14,9 @@ import ( "strings" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + blockstore "github.com/ipfs/boxo/blockstore" "github.com/ipfs/boxo/provider" "github.com/ipfs/go-cid" diff --git a/backend/index/index_blockstore.go b/backend/index/index_blockstore.go index 1ab28a81..4a765b6a 100644 --- a/backend/index/index_blockstore.go +++ b/backend/index/index_blockstore.go @@ -4,7 +4,8 @@ import ( "context" "seed/backend/ipfs" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" "github.com/multiformats/go-multicodec" diff --git a/backend/index/index_sql.go b/backend/index/index_sql.go index ae5fd4c8..c13590ba 100644 --- a/backend/index/index_sql.go +++ b/backend/index/index_sql.go @@ -7,8 +7,8 @@ import ( "seed/backend/util/maybe" "seed/backend/util/sqlitegen" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) // dbStructuralBlobsInsert inserts a structural blob. diff --git a/backend/index/reindex.go b/backend/index/reindex.go index bf7def39..7fa7f900 100644 --- a/backend/index/reindex.go +++ b/backend/index/reindex.go @@ -7,8 +7,9 @@ import ( "slices" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + "github.com/ipfs/go-cid" "github.com/multiformats/go-multicodec" "go.uber.org/zap" diff --git a/backend/lndhub/lndhub.go b/backend/lndhub/lndhub.go index 2b1fd6af..1db4db11 100644 --- a/backend/lndhub/lndhub.go +++ b/backend/lndhub/lndhub.go @@ -17,11 +17,11 @@ import ( "time" "unicode" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" "github.com/btcsuite/btcd/chaincfg" "github.com/lightningnetwork/lnd/zpay32" "github.com/mitchellh/mapstructure" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) const ( diff --git a/backend/lndhub/lndhub_test.go b/backend/lndhub/lndhub_test.go index ea5aa78f..9bb63e17 100644 --- a/backend/lndhub/lndhub_test.go +++ b/backend/lndhub/lndhub_test.go @@ -14,10 +14,10 @@ import ( "testing" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" "github.com/btcsuite/btcd/btcutil" "github.com/stretchr/testify/require" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) const ( diff --git a/backend/lndhub/lndhubsql/lndhub.go b/backend/lndhub/lndhubsql/lndhub.go index e08d25a0..3955b9f6 100644 --- a/backend/lndhub/lndhubsql/lndhub.go +++ b/backend/lndhub/lndhubsql/lndhub.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) const ( diff --git a/backend/lndhub/lndhubsql/queries.gen.go b/backend/lndhub/lndhubsql/queries.gen.go index 5be39628..2ead06b8 100644 --- a/backend/lndhub/lndhubsql/queries.gen.go +++ b/backend/lndhub/lndhubsql/queries.gen.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" "seed/backend/util/sqlitegen" ) diff --git a/backend/mttnet/connect.go b/backend/mttnet/connect.go index c6ac3233..43c7f122 100644 --- a/backend/mttnet/connect.go +++ b/backend/mttnet/connect.go @@ -11,8 +11,8 @@ import ( "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" "github.com/libp2p/go-libp2p/core/event" "github.com/libp2p/go-libp2p/core/network" diff --git a/backend/mttnet/last_seen.go b/backend/mttnet/last_seen.go index da808f7c..f53bd382 100644 --- a/backend/mttnet/last_seen.go +++ b/backend/mttnet/last_seen.go @@ -4,7 +4,8 @@ import ( "math/rand" "time" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + "github.com/libp2p/go-libp2p/core/host" ) diff --git a/backend/mttnet/list_blobs.go b/backend/mttnet/list_blobs.go index 976d439d..2c3a772e 100644 --- a/backend/mttnet/list_blobs.go +++ b/backend/mttnet/list_blobs.go @@ -7,8 +7,9 @@ import ( p2p "seed/backend/genproto/p2p/v1alpha" "seed/backend/util/dqb" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + "github.com/ipfs/go-cid" "go.uber.org/zap" ) diff --git a/backend/mttnet/list_peers.go b/backend/mttnet/list_peers.go index 193a4586..f0f03581 100644 --- a/backend/mttnet/list_peers.go +++ b/backend/mttnet/list_peers.go @@ -8,8 +8,9 @@ import ( "seed/backend/util/dqb" "strings" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + "github.com/libp2p/go-libp2p/core/peer" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/backend/mttnet/mttnet.go b/backend/mttnet/mttnet.go index 8deed9c6..1b5f54ea 100644 --- a/backend/mttnet/mttnet.go +++ b/backend/mttnet/mttnet.go @@ -15,7 +15,8 @@ import ( "seed/backend/util/must" "time" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + provider "github.com/ipfs/boxo/provider" "github.com/ipfs/go-datastore" dssync "github.com/ipfs/go-datastore/sync" diff --git a/backend/mttnet/providing.go b/backend/mttnet/providing.go index 0507ba69..566c9e55 100644 --- a/backend/mttnet/providing.go +++ b/backend/mttnet/providing.go @@ -9,8 +9,9 @@ import ( "seed/backend/util/dqb" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + "github.com/ipfs/boxo/provider" "github.com/ipfs/go-cid" "github.com/multiformats/go-multicodec" diff --git a/backend/mttnet/syncing.go b/backend/mttnet/syncing.go index c06514eb..6d5832ed 100644 --- a/backend/mttnet/syncing.go +++ b/backend/mttnet/syncing.go @@ -7,8 +7,9 @@ import ( "seed/backend/syncing/rbsr" "seed/backend/util/dqb" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + "github.com/ipfs/go-cid" ) diff --git a/backend/storage/dbext/dbext.go b/backend/storage/dbext/dbext.go index 530d81bc..f1361deb 100644 --- a/backend/storage/dbext/dbext.go +++ b/backend/storage/dbext/dbext.go @@ -1,7 +1,7 @@ // Package dbext provides our custom extensions for SQLite. package dbext -// #cgo CFLAGS: -I ../../../third_party/sqlite +// #cgo CFLAGS: -I ../../util/sqlite // #cgo CFLAGS: -DSQLITE_CORE // #include "dbext.h" import "C" diff --git a/backend/storage/schema_test.go b/backend/storage/schema_test.go index e85bd5b3..b40af8fa 100644 --- a/backend/storage/schema_test.go +++ b/backend/storage/schema_test.go @@ -5,9 +5,9 @@ import ( "fmt" "testing" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" "github.com/stretchr/testify/require" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) func TestSchemaForeignKeyIndexes(t *testing.T) { diff --git a/backend/storage/sqlite.go b/backend/storage/sqlite.go index e312abbb..4ed82a96 100644 --- a/backend/storage/sqlite.go +++ b/backend/storage/sqlite.go @@ -11,9 +11,9 @@ import ( "testing" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" "github.com/stretchr/testify/require" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) import "C" diff --git a/backend/storage/storage.go b/backend/storage/storage.go index 415f9b2f..e7960b1b 100644 --- a/backend/storage/storage.go +++ b/backend/storage/storage.go @@ -10,9 +10,9 @@ import ( "seed/backend/core" "seed/backend/logging" - "crawshaw.io/sqlite/sqlitex" "github.com/libp2p/go-libp2p/core/crypto" "go.uber.org/zap" + "seed/backend/util/sqlite/sqlitex" ) // Store is a storage directory on a filesystem. diff --git a/backend/storage/storage_migrations.go b/backend/storage/storage_migrations.go index a85164c0..a73addc3 100644 --- a/backend/storage/storage_migrations.go +++ b/backend/storage/storage_migrations.go @@ -8,9 +8,9 @@ import ( "path/filepath" "seed/backend/core" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" "github.com/libp2p/go-libp2p/core/crypto" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" "golang.org/x/exp/slices" ) diff --git a/backend/syncing/syncing.go b/backend/syncing/syncing.go index be6eb435..b9b5422d 100644 --- a/backend/syncing/syncing.go +++ b/backend/syncing/syncing.go @@ -20,8 +20,9 @@ import ( "container/list" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" + "github.com/ipfs/boxo/exchange" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p/core/event" diff --git a/backend/syncing/worker.go b/backend/syncing/worker.go index 7ddb225e..d23ff416 100644 --- a/backend/syncing/worker.go +++ b/backend/syncing/worker.go @@ -9,7 +9,8 @@ import ( "seed/backend/index" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" diff --git a/backend/util/dqb/dqb.go b/backend/util/dqb/dqb.go index b2d1dbd3..07a468ce 100644 --- a/backend/util/dqb/dqb.go +++ b/backend/util/dqb/dqb.go @@ -8,7 +8,7 @@ import ( "fmt" "sync" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" ) // GlobalQueries is a global storage of SQL queries. diff --git a/third_party/sqlite/.gitignore b/backend/util/sqlite/.gitignore similarity index 100% rename from third_party/sqlite/.gitignore rename to backend/util/sqlite/.gitignore diff --git a/third_party/sqlite/LICENSE b/backend/util/sqlite/LICENSE similarity index 100% rename from third_party/sqlite/LICENSE rename to backend/util/sqlite/LICENSE diff --git a/third_party/sqlite/Makefile b/backend/util/sqlite/Makefile similarity index 100% rename from third_party/sqlite/Makefile rename to backend/util/sqlite/Makefile diff --git a/backend/util/sqlite/NOTICE b/backend/util/sqlite/NOTICE new file mode 100644 index 00000000..93cdfd9c --- /dev/null +++ b/backend/util/sqlite/NOTICE @@ -0,0 +1,3 @@ +This package started as a copy of https://github.com/crawshaw/sqlite, which appears inactive and unmaintained. + +Modifications were made to this package to the point that it made sense to adopt it directly into our code base, breaking ties with the original. diff --git a/third_party/sqlite/auth.go b/backend/util/sqlite/auth.go similarity index 100% rename from third_party/sqlite/auth.go rename to backend/util/sqlite/auth.go diff --git a/third_party/sqlite/auth_test.go b/backend/util/sqlite/auth_test.go similarity index 97% rename from third_party/sqlite/auth_test.go rename to backend/util/sqlite/auth_test.go index b95c5569..fe892aca 100644 --- a/third_party/sqlite/auth_test.go +++ b/backend/util/sqlite/auth_test.go @@ -3,7 +3,7 @@ package sqlite_test import ( "testing" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) func TestSetAuthorizer(t *testing.T) { diff --git a/third_party/sqlite/backup.go b/backend/util/sqlite/backup.go similarity index 100% rename from third_party/sqlite/backup.go rename to backend/util/sqlite/backup.go diff --git a/third_party/sqlite/backup_test.go b/backend/util/sqlite/backup_test.go similarity index 96% rename from third_party/sqlite/backup_test.go rename to backend/util/sqlite/backup_test.go index b349d71b..4a2340fb 100644 --- a/third_party/sqlite/backup_test.go +++ b/backend/util/sqlite/backup_test.go @@ -17,8 +17,8 @@ package sqlite_test import ( "testing" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) func initSrc(t *testing.T) *sqlite.Conn { diff --git a/third_party/sqlite/blob.go b/backend/util/sqlite/blob.go similarity index 100% rename from third_party/sqlite/blob.go rename to backend/util/sqlite/blob.go diff --git a/third_party/sqlite/blob_test.go b/backend/util/sqlite/blob_test.go similarity index 99% rename from third_party/sqlite/blob_test.go rename to backend/util/sqlite/blob_test.go index 91438022..e45036e4 100644 --- a/third_party/sqlite/blob_test.go +++ b/backend/util/sqlite/blob_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) func TestBlob(t *testing.T) { diff --git a/third_party/sqlite/blocking_step.c b/backend/util/sqlite/blocking_step.c similarity index 100% rename from third_party/sqlite/blocking_step.c rename to backend/util/sqlite/blocking_step.c diff --git a/third_party/sqlite/blocking_step.h b/backend/util/sqlite/blocking_step.h similarity index 100% rename from third_party/sqlite/blocking_step.h rename to backend/util/sqlite/blocking_step.h diff --git a/third_party/sqlite/c/dummy.go b/backend/util/sqlite/c/dummy.go similarity index 100% rename from third_party/sqlite/c/dummy.go rename to backend/util/sqlite/c/dummy.go diff --git a/third_party/sqlite/c/sqlite3.c b/backend/util/sqlite/c/sqlite3.c similarity index 100% rename from third_party/sqlite/c/sqlite3.c rename to backend/util/sqlite/c/sqlite3.c diff --git a/third_party/sqlite/doc.go b/backend/util/sqlite/doc.go similarity index 96% rename from third_party/sqlite/doc.go rename to backend/util/sqlite/doc.go index 81be034d..76f087d3 100644 --- a/third_party/sqlite/doc.go +++ b/backend/util/sqlite/doc.go @@ -37,8 +37,7 @@ The optional SQLite3 compiled in are: FTS5, RTree, JSON1, Session, GeoPoly This is not a database/sql driver. - -Statement Caching +# Statement Caching Statements are prepared with the Prepare and PrepareTransient methods. When using Prepare, statements are keyed inside a connection by the @@ -51,8 +50,7 @@ After all the connections in a pool have been warmed up by passing through one of these Prepare calls, subsequent calls are simply a map lookup that returns an existing statement. - -Streaming Blobs +# Streaming Blobs The sqlite package supports the SQLite incremental I/O interface for streaming blob data into and out of the the database without loading @@ -70,8 +68,7 @@ Then you can open the blob with: b, err := conn.OpenBlob("", "blobs", "myblob", conn.LastInsertRowID(), true) - -Deadlines and Cancellation +# Deadlines and Cancellation Every connection can have a done channel associated with it using the SetInterrupt method. This is typically the channel returned by @@ -94,16 +91,14 @@ connection is: } defer dbpool.Put(c) - -Transactions +# Transactions SQLite transactions have to be managed manually with this package by directly calling BEGIN / COMMIT / ROLLBACK or SAVEPOINT / RELEASE/ ROLLBACK. The sqlitex has a Savepoint function that helps automate this. - -A typical HTTP Handler +# A typical HTTP Handler Using a Pool to execute SQL in a concurrent HTTP handler. @@ -141,4 +136,4 @@ Using a Pool to execute SQL in a concurrent HTTP handler. For helper functions that make some kinds of statements easier to write see the sqlitex package. */ -package sqlite // import "crawshaw.io/sqlite" +package sqlite // import "seed/backend/util/sqlite" diff --git a/third_party/sqlite/dummy.go b/backend/util/sqlite/dummy.go similarity index 91% rename from third_party/sqlite/dummy.go rename to backend/util/sqlite/dummy.go index 35d02039..0ba28d19 100644 --- a/third_party/sqlite/dummy.go +++ b/backend/util/sqlite/dummy.go @@ -1,3 +1,4 @@ +//go:build dummy // +build dummy // This file is part of a workaround for `go mod vendor` which won't vendor @@ -14,5 +15,5 @@ package sqlite import ( - _ "crawshaw.io/sqlite/c" + _ "seed/backend/util/sqlite/c" ) diff --git a/third_party/sqlite/error.go b/backend/util/sqlite/error.go similarity index 100% rename from third_party/sqlite/error.go rename to backend/util/sqlite/error.go diff --git a/third_party/sqlite/export_test.go b/backend/util/sqlite/export_test.go similarity index 100% rename from third_party/sqlite/export_test.go rename to backend/util/sqlite/export_test.go diff --git a/third_party/sqlite/extension.go b/backend/util/sqlite/extension.go similarity index 100% rename from third_party/sqlite/extension.go rename to backend/util/sqlite/extension.go diff --git a/third_party/sqlite/extension_test.go b/backend/util/sqlite/extension_test.go similarity index 99% rename from third_party/sqlite/extension_test.go rename to backend/util/sqlite/extension_test.go index 070284d9..753db5e6 100644 --- a/third_party/sqlite/extension_test.go +++ b/backend/util/sqlite/extension_test.go @@ -24,7 +24,7 @@ import ( "strings" "testing" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) const ( diff --git a/third_party/sqlite/func.go b/backend/util/sqlite/func.go similarity index 100% rename from third_party/sqlite/func.go rename to backend/util/sqlite/func.go diff --git a/third_party/sqlite/func_test.go b/backend/util/sqlite/func_test.go similarity index 99% rename from third_party/sqlite/func_test.go rename to backend/util/sqlite/func_test.go index 3a7fb20e..b5d50594 100644 --- a/third_party/sqlite/func_test.go +++ b/backend/util/sqlite/func_test.go @@ -17,7 +17,7 @@ package sqlite_test import ( "testing" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) func TestFunc(t *testing.T) { diff --git a/third_party/sqlite/incrementor.go b/backend/util/sqlite/incrementor.go similarity index 100% rename from third_party/sqlite/incrementor.go rename to backend/util/sqlite/incrementor.go diff --git a/third_party/sqlite/incrementor_test.go b/backend/util/sqlite/incrementor_test.go similarity index 100% rename from third_party/sqlite/incrementor_test.go rename to backend/util/sqlite/incrementor_test.go diff --git a/third_party/sqlite/link.go b/backend/util/sqlite/link.go similarity index 100% rename from third_party/sqlite/link.go rename to backend/util/sqlite/link.go diff --git a/third_party/sqlite/openflags.go b/backend/util/sqlite/openflags.go similarity index 100% rename from third_party/sqlite/openflags.go rename to backend/util/sqlite/openflags.go diff --git a/third_party/sqlite/session.go b/backend/util/sqlite/session.go similarity index 100% rename from third_party/sqlite/session.go rename to backend/util/sqlite/session.go diff --git a/third_party/sqlite/session_test.go b/backend/util/sqlite/session_test.go similarity index 99% rename from third_party/sqlite/session_test.go rename to backend/util/sqlite/session_test.go index f7f76131..63aea071 100644 --- a/third_party/sqlite/session_test.go +++ b/backend/util/sqlite/session_test.go @@ -19,8 +19,8 @@ import ( "reflect" "testing" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) func initT(t *testing.T, conn *sqlite.Conn) { diff --git a/third_party/sqlite/snapshot.go b/backend/util/sqlite/snapshot.go similarity index 100% rename from third_party/sqlite/snapshot.go rename to backend/util/sqlite/snapshot.go diff --git a/third_party/sqlite/snapshot_test.go b/backend/util/sqlite/snapshot_test.go similarity index 98% rename from third_party/sqlite/snapshot_test.go rename to backend/util/sqlite/snapshot_test.go index 5608be76..d8391578 100644 --- a/third_party/sqlite/snapshot_test.go +++ b/backend/util/sqlite/snapshot_test.go @@ -22,8 +22,8 @@ import ( "testing" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) var db = fmt.Sprintf("%v/snapshot_test_%v.sqlite3", diff --git a/third_party/sqlite/sqlite.go b/backend/util/sqlite/sqlite.go similarity index 100% rename from third_party/sqlite/sqlite.go rename to backend/util/sqlite/sqlite.go diff --git a/third_party/sqlite/sqlite3.h b/backend/util/sqlite/sqlite3.h similarity index 100% rename from third_party/sqlite/sqlite3.h rename to backend/util/sqlite/sqlite3.h diff --git a/third_party/sqlite/sqlite3ext.h b/backend/util/sqlite/sqlite3ext.h similarity index 100% rename from third_party/sqlite/sqlite3ext.h rename to backend/util/sqlite/sqlite3ext.h diff --git a/third_party/sqlite/sqlite_test.go b/backend/util/sqlite/sqlite_test.go similarity index 99% rename from third_party/sqlite/sqlite_test.go rename to backend/util/sqlite/sqlite_test.go index b2963f4a..956b1dac 100644 --- a/third_party/sqlite/sqlite_test.go +++ b/backend/util/sqlite/sqlite_test.go @@ -25,8 +25,8 @@ import ( "testing" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) func TestConn(t *testing.T) { diff --git a/third_party/sqlite/sqlitex/buffer.go b/backend/util/sqlite/sqlitex/buffer.go similarity index 99% rename from third_party/sqlite/sqlitex/buffer.go rename to backend/util/sqlite/sqlitex/buffer.go index 04cb18c5..a2925e8a 100644 --- a/third_party/sqlite/sqlitex/buffer.go +++ b/backend/util/sqlite/sqlitex/buffer.go @@ -18,7 +18,7 @@ import ( "errors" "io" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) // A Buffer is a variable-sized bytes buffer backed by SQLite blobs. diff --git a/third_party/sqlite/sqlitex/buffer_test.go b/backend/util/sqlite/sqlitex/buffer_test.go similarity index 99% rename from third_party/sqlite/sqlitex/buffer_test.go rename to backend/util/sqlite/sqlitex/buffer_test.go index 2b8689d7..11000a33 100644 --- a/third_party/sqlite/sqlitex/buffer_test.go +++ b/backend/util/sqlite/sqlitex/buffer_test.go @@ -20,7 +20,7 @@ import ( "testing" "crawshaw.io/iox/ioxtest" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) func TestBuffer(t *testing.T) { diff --git a/third_party/sqlite/sqlitex/exec.go b/backend/util/sqlite/sqlitex/exec.go similarity index 98% rename from third_party/sqlite/sqlitex/exec.go rename to backend/util/sqlite/sqlitex/exec.go index 7310dfac..db2cd1e9 100644 --- a/third_party/sqlite/sqlitex/exec.go +++ b/backend/util/sqlite/sqlitex/exec.go @@ -13,7 +13,7 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // Package sqlitex provides utilities for working with SQLite. -package sqlitex // import "crawshaw.io/sqlite/sqlitex" +package sqlitex // import "seed/backend/util/sqlite/sqlitex" import ( "errors" @@ -21,7 +21,7 @@ import ( "reflect" "strings" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) // Exec executes an SQLite query. diff --git a/third_party/sqlite/sqlitex/exec_test.go b/backend/util/sqlite/sqlitex/exec_test.go similarity index 98% rename from third_party/sqlite/sqlitex/exec_test.go rename to backend/util/sqlite/sqlitex/exec_test.go index dc81bd5a..1cabdb8a 100644 --- a/third_party/sqlite/sqlitex/exec_test.go +++ b/backend/util/sqlite/sqlitex/exec_test.go @@ -19,8 +19,8 @@ import ( "reflect" "testing" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) func TestExec(t *testing.T) { diff --git a/third_party/sqlite/sqlitex/file.go b/backend/util/sqlite/sqlitex/file.go similarity index 99% rename from third_party/sqlite/sqlitex/file.go rename to backend/util/sqlite/sqlitex/file.go index 76401086..8282bf6f 100644 --- a/third_party/sqlite/sqlitex/file.go +++ b/backend/util/sqlite/sqlitex/file.go @@ -18,7 +18,7 @@ import ( "fmt" "io" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) // File is a readable, writable, and seekable series of temporary SQLite blobs. diff --git a/third_party/sqlite/sqlitex/file_test.go b/backend/util/sqlite/sqlitex/file_test.go similarity index 97% rename from third_party/sqlite/sqlitex/file_test.go rename to backend/util/sqlite/sqlitex/file_test.go index 650eea20..40dd84d8 100644 --- a/third_party/sqlite/sqlitex/file_test.go +++ b/backend/util/sqlite/sqlitex/file_test.go @@ -18,8 +18,9 @@ import ( "io/ioutil" "testing" + "seed/backend/util/sqlite" + "crawshaw.io/iox/ioxtest" - "crawshaw.io/sqlite" ) func TestFileRand(t *testing.T) { diff --git a/third_party/sqlite/sqlitex/pool.go b/backend/util/sqlite/sqlitex/pool.go similarity index 99% rename from third_party/sqlite/sqlitex/pool.go rename to backend/util/sqlite/sqlitex/pool.go index af4918c7..bca865e5 100644 --- a/third_party/sqlite/sqlitex/pool.go +++ b/backend/util/sqlite/sqlitex/pool.go @@ -22,7 +22,7 @@ import ( "sync" "time" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) // Pool is a pool of SQLite connections. diff --git a/third_party/sqlite/sqlitex/pool_test.go b/backend/util/sqlite/sqlitex/pool_test.go similarity index 98% rename from third_party/sqlite/sqlitex/pool_test.go rename to backend/util/sqlite/sqlitex/pool_test.go index 4aec57e4..3a396785 100644 --- a/third_party/sqlite/sqlitex/pool_test.go +++ b/backend/util/sqlite/sqlitex/pool_test.go @@ -23,8 +23,8 @@ import ( "testing" "time" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) const poolSize = 20 diff --git a/third_party/sqlite/sqlitex/query.go b/backend/util/sqlite/sqlitex/query.go similarity index 98% rename from third_party/sqlite/sqlitex/query.go rename to backend/util/sqlite/sqlitex/query.go index d2133a2c..9d483fd6 100644 --- a/third_party/sqlite/sqlitex/query.go +++ b/backend/util/sqlite/sqlitex/query.go @@ -3,7 +3,7 @@ package sqlitex import ( "errors" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) var errNoResults = errors.New("sqlite: statement has no results") diff --git a/third_party/sqlite/sqlitex/rand_id.go b/backend/util/sqlite/sqlitex/rand_id.go similarity index 98% rename from third_party/sqlite/sqlitex/rand_id.go rename to backend/util/sqlite/sqlitex/rand_id.go index 0fefed4f..4cc030dc 100644 --- a/third_party/sqlite/sqlitex/rand_id.go +++ b/backend/util/sqlite/sqlitex/rand_id.go @@ -19,7 +19,7 @@ import ( "fmt" "math/big" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) // InsertRandID executes stmt with a random value in the range [min, max) for $param. diff --git a/third_party/sqlite/sqlitex/rand_id_test.go b/backend/util/sqlite/sqlitex/rand_id_test.go similarity index 96% rename from third_party/sqlite/sqlitex/rand_id_test.go rename to backend/util/sqlite/sqlitex/rand_id_test.go index a3d73a4b..450eda48 100644 --- a/third_party/sqlite/sqlitex/rand_id_test.go +++ b/backend/util/sqlite/sqlitex/rand_id_test.go @@ -17,8 +17,8 @@ package sqlitex_test import ( "testing" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) func TestRandID(t *testing.T) { diff --git a/third_party/sqlite/sqlitex/savepoint.go b/backend/util/sqlite/sqlitex/savepoint.go similarity index 99% rename from third_party/sqlite/sqlitex/savepoint.go rename to backend/util/sqlite/sqlitex/savepoint.go index b8f6f0ac..95d1ac01 100644 --- a/third_party/sqlite/sqlitex/savepoint.go +++ b/backend/util/sqlite/sqlitex/savepoint.go @@ -19,7 +19,7 @@ import ( "runtime" "strings" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) // Save creates a named SQLite transaction using SAVEPOINT. diff --git a/third_party/sqlite/sqlitex/savepoint_test.go b/backend/util/sqlite/sqlitex/savepoint_test.go similarity index 99% rename from third_party/sqlite/sqlitex/savepoint_test.go rename to backend/util/sqlite/sqlitex/savepoint_test.go index 7c215466..d8655538 100644 --- a/third_party/sqlite/sqlitex/savepoint_test.go +++ b/backend/util/sqlite/sqlitex/savepoint_test.go @@ -23,7 +23,7 @@ import ( "testing" "time" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) func TestExec(t *testing.T) { diff --git a/third_party/sqlite/sqlitex/snapshot.go b/backend/util/sqlite/sqlitex/snapshot.go similarity index 97% rename from third_party/sqlite/sqlitex/snapshot.go rename to backend/util/sqlite/sqlitex/snapshot.go index 98187f76..4dfaefd2 100644 --- a/third_party/sqlite/sqlitex/snapshot.go +++ b/backend/util/sqlite/sqlitex/snapshot.go @@ -4,7 +4,7 @@ import ( "context" "runtime" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) // GetSnapshot returns a Snapshot that should remain available for reads until diff --git a/third_party/sqlite/sqlitex/tx.go b/backend/util/sqlite/sqlitex/tx.go similarity index 97% rename from third_party/sqlite/sqlitex/tx.go rename to backend/util/sqlite/sqlitex/tx.go index 78db4df8..5c673a33 100644 --- a/third_party/sqlite/sqlitex/tx.go +++ b/backend/util/sqlite/sqlitex/tx.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) // WithTx executes fn within an immediate transaction, and commits diff --git a/third_party/sqlite/static.go b/backend/util/sqlite/static.go similarity index 100% rename from third_party/sqlite/static.go rename to backend/util/sqlite/static.go diff --git a/third_party/sqlite/wrappers.c b/backend/util/sqlite/wrappers.c similarity index 100% rename from third_party/sqlite/wrappers.c rename to backend/util/sqlite/wrappers.c diff --git a/third_party/sqlite/wrappers.h b/backend/util/sqlite/wrappers.h similarity index 100% rename from third_party/sqlite/wrappers.h rename to backend/util/sqlite/wrappers.h diff --git a/backend/util/sqlitedbg/sqlitedbg.go b/backend/util/sqlitedbg/sqlitedbg.go index 6054d5f3..2cb7b3ad 100644 --- a/backend/util/sqlitedbg/sqlitedbg.go +++ b/backend/util/sqlitedbg/sqlitedbg.go @@ -7,9 +7,9 @@ import ( "io" "os" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" "github.com/jedib0t/go-pretty/v6/table" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) // Exec a query and print the results into w. diff --git a/backend/util/sqlitedbg/sqlitedbg_test.go b/backend/util/sqlitedbg/sqlitedbg_test.go index 3dd547ec..a605fe90 100644 --- a/backend/util/sqlitedbg/sqlitedbg_test.go +++ b/backend/util/sqlitedbg/sqlitedbg_test.go @@ -4,7 +4,7 @@ import ( "os" "seed/backend/util/sqlitedbg" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) func ExampleExec() { diff --git a/backend/util/sqlitegen/example/queries.gen.go b/backend/util/sqlitegen/example/queries.gen.go index 70d121a5..039d3abd 100644 --- a/backend/util/sqlitegen/example/queries.gen.go +++ b/backend/util/sqlitegen/example/queries.gen.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" "seed/backend/util/sqlitegen" ) diff --git a/backend/util/sqlitegen/example/schema/schema.go b/backend/util/sqlitegen/example/schema/schema.go index 11d4f835..a6f34326 100644 --- a/backend/util/sqlitegen/example/schema/schema.go +++ b/backend/util/sqlitegen/example/schema/schema.go @@ -7,9 +7,9 @@ import ( "seed/backend/util/sqlitegen" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" "go.uber.org/multierr" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) var _ = generateSchema diff --git a/backend/util/sqlitegen/queries.go b/backend/util/sqlitegen/queries.go index 6ac808f4..2009f696 100644 --- a/backend/util/sqlitegen/queries.go +++ b/backend/util/sqlitegen/queries.go @@ -26,7 +26,7 @@ import ( "fmt" "errors" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" "seed/backend/util/sqlitegen" ) diff --git a/backend/util/sqlitegen/queries_test.golden b/backend/util/sqlitegen/queries_test.golden index 55ccc1c5..c6dfbff6 100644 --- a/backend/util/sqlitegen/queries_test.golden +++ b/backend/util/sqlitegen/queries_test.golden @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" "seed/backend/util/sqlitegen" ) diff --git a/backend/util/sqlitegen/schema.go b/backend/util/sqlitegen/schema.go index 3a1b142b..2d35131d 100644 --- a/backend/util/sqlitegen/schema.go +++ b/backend/util/sqlitegen/schema.go @@ -8,8 +8,8 @@ import ( "strings" "text/template" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) // Schema describes a SQL schema. diff --git a/backend/util/sqlitegen/schema_test.go b/backend/util/sqlitegen/schema_test.go index 0a22c7e9..a17816a9 100644 --- a/backend/util/sqlitegen/schema_test.go +++ b/backend/util/sqlitegen/schema_test.go @@ -7,9 +7,9 @@ import ( "path/filepath" "testing" - "crawshaw.io/sqlite" - "crawshaw.io/sqlite/sqlitex" "github.com/stretchr/testify/require" + "seed/backend/util/sqlite" + "seed/backend/util/sqlite/sqlitex" ) func TestColumnShortName(t *testing.T) { diff --git a/backend/util/sqlitegen/sqlitegen.go b/backend/util/sqlitegen/sqlitegen.go index b39aa0ef..f8eebf10 100644 --- a/backend/util/sqlitegen/sqlitegen.go +++ b/backend/util/sqlitegen/sqlitegen.go @@ -5,10 +5,10 @@ import ( "context" "strings" - "crawshaw.io/sqlite" "go.uber.org/multierr" "golang.org/x/text/cases" "golang.org/x/text/language" + "seed/backend/util/sqlite" ) var initialisms = map[string]string{ diff --git a/backend/wallet/wallet.go b/backend/wallet/wallet.go index a8a424ec..42de9667 100644 --- a/backend/wallet/wallet.go +++ b/backend/wallet/wallet.go @@ -16,7 +16,8 @@ import ( wallet "seed/backend/wallet/walletsql" "strings" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + "github.com/ipfs/go-cid" "go.uber.org/zap" ) diff --git a/backend/wallet/wallet_test.go b/backend/wallet/wallet_test.go index 98c52869..50f82045 100644 --- a/backend/wallet/wallet_test.go +++ b/backend/wallet/wallet_test.go @@ -18,7 +18,8 @@ import ( "testing" "time" - "crawshaw.io/sqlite/sqlitex" + "seed/backend/util/sqlite/sqlitex" + "github.com/stretchr/testify/require" "go.uber.org/zap" ) diff --git a/backend/wallet/walletsql/queries.gen.go b/backend/wallet/walletsql/queries.gen.go index d2b878e6..066f179a 100644 --- a/backend/wallet/walletsql/queries.gen.go +++ b/backend/wallet/walletsql/queries.gen.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" "seed/backend/util/sqlitegen" ) diff --git a/backend/wallet/walletsql/wallet.go b/backend/wallet/walletsql/wallet.go index 822e5767..8cb258e3 100644 --- a/backend/wallet/walletsql/wallet.go +++ b/backend/wallet/walletsql/wallet.go @@ -6,7 +6,7 @@ import ( "seed/backend/lndhub/lndhubsql" "strings" - "crawshaw.io/sqlite" + "seed/backend/util/sqlite" ) const ( diff --git a/go.mod b/go.mod index be920186..3c5f392f 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.23 toolchain go1.23.0 require ( - crawshaw.io/sqlite v0.3.2 + crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797 github.com/99designs/gqlgen v0.17.22 github.com/btcsuite/btcd v0.23.3 github.com/btcsuite/btcd/btcutil v1.1.2 @@ -233,8 +233,6 @@ require ( nhooyr.io/websocket v1.8.7 // indirect ) -replace crawshaw.io/sqlite => ./third_party/sqlite - replace roci.dev/fracdex => github.com/rocicorp/fracdex v0.0.0-20231009204907-ebc26eac9486 // LND imports etcd, which imports some very old version of OpenTelemetry, diff --git a/third_party/BUILD.plz b/third_party/BUILD.plz deleted file mode 100644 index 72ec5742..00000000 --- a/third_party/BUILD.plz +++ /dev/null @@ -1,15 +0,0 @@ -filegroup( - name = "sqlite", - srcs = glob( - [ - "sqlite/**/*.go", - "sqlite/**/*.c", - "sqlite/**/*.h", - ], - exclude = ["sqlite/**/*_test.go"], - ) + [ - "sqlite/go.mod", - "sqlite/go.sum", - ], - visibility = ["PUBLIC"], -) diff --git a/third_party/sqlite/.gitrepo b/third_party/sqlite/.gitrepo deleted file mode 100644 index 0aec377f..00000000 --- a/third_party/sqlite/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme -; -[subrepo] - remote = https://github.com/crawshaw/sqlite - branch = master - commit = 23d646f8ac00d9dd239003c121ca4fad16e2445f - parent = da529ea85abe0f4da4c0627212e834a57a4f117f - method = merge - cmdver = 0.4.3 diff --git a/third_party/sqlite/.travis.yml b/third_party/sqlite/.travis.yml deleted file mode 100644 index 60640697..00000000 --- a/third_party/sqlite/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: 'go' - -go: - - '1.13.x' - -os: - - 'linux' - - 'osx' - -script: - - make test diff --git a/third_party/sqlite/README.md b/third_party/sqlite/README.md deleted file mode 100644 index 3d78be9b..00000000 --- a/third_party/sqlite/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# Go interface to SQLite. - -[![GoDoc](https://godoc.org/crawshaw.io/sqlite?status.svg)](https://godoc.org/crawshaw.io/sqlite) -[![Build Status](https://travis-ci.org/crawshaw/sqlite.svg?branch=master)](https://travis-ci.org/crawshaw/sqlite) -(linux and macOS) -[![Build status](https://ci.appveyor.com/api/projects/status/jh9xx6cut73ufkl8?svg=true)](https://ci.appveyor.com/project/crawshaw/sqlite) -(windows) - -This package provides a low-level Go interface to SQLite 3. Connections are -[pooled](https://godoc.org/crawshaw.io/sqlite#Pool) and if the SQLite -[shared cache](https://www.sqlite.org/sharedcache.html) mode is enabled the -package takes advantage of the -[unlock-notify API](https://www.sqlite.org/unlock_notify.html) to minimize the -amount of handling user code needs for dealing with database lock contention. - -It has interfaces for some of SQLite's more interesting extensions, such as -[incremental BLOB I/O](https://www.sqlite.org/c3ref/blob_open.html) and the -[session extension](https://www.sqlite.org/sessionintro.html). - -A utility package, [sqlitex](https://godoc.org/crawshaw.io/sqlite/sqlitex), -provides some higher-level tools for making it easier to perform common tasks -with SQLite. In particular it provides support to make nested transactions easy -to use via [sqlitex.Save](https://godoc.org/crawshaw.io/sqlite/sqlitex#Save). - -This is not a database/sql driver. - -`go get -u crawshaw.io/sqlite` - -## Example - -A HTTP handler that uses a multi-threaded pool of SQLite connections via a -shared cache. - -```go -var dbpool *sqlitex.Pool - -func main() { - var err error - dbpool, err = sqlitex.Open("file:memory:?mode=memory", 0, 10) - if err != nil { - log.Fatal(err) - } - http.HandleFunc("/", handler) - log.Fatal(http.ListenAndServe(":8080", nil)) -} - -func handler(w http.ResponseWriter, r *http.Request) { - conn := dbpool.Get(r.Context()) - if conn == nil { - return - } - defer dbpool.Put(conn) - stmt := conn.Prep("SELECT foo FROM footable WHERE id = $id;") - stmt.SetText("$id", "_user_id_") - for { - if hasRow, err := stmt.Step(); err != nil { - // ... handle error - } else if !hasRow { - break - } - foo := stmt.GetText("foo") - // ... use foo - } -} -``` - -https://godoc.org/crawshaw.io/sqlite diff --git a/third_party/sqlite/appveyor.yml b/third_party/sqlite/appveyor.yml deleted file mode 100644 index a33bb3a7..00000000 --- a/third_party/sqlite/appveyor.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: '{build}' -platform: 'mingw' - -# Source Config - -clone_folder: C:\gopath\src\crawshaw.io\sqlite - -# Build host - -environment: - GOPATH: C:\gopath - -# Build - -install: - - set - PATH=C:\go\bin;C:\gopath\bin;C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH% - - go version - - go env - -build: false -deploy: false - -test_script: - - go get -v -t ./... - - go test -v ./... diff --git a/third_party/sqlite/go.mod b/third_party/sqlite/go.mod deleted file mode 100644 index d54264f4..00000000 --- a/third_party/sqlite/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module crawshaw.io/sqlite - -go 1.17 - -require crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797 diff --git a/third_party/sqlite/go.sum b/third_party/sqlite/go.sum deleted file mode 100644 index f21c814f..00000000 --- a/third_party/sqlite/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797 h1:yDf7ARQc637HoxDho7xjqdvO5ZA2Yb+xzv/fOnnvZzw= -crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797/go.mod h1:sXBiorCo8c46JlQV3oXPKINnZ8mcqnye1EkVkqsectk=