Skip to content

Commit

Permalink
refactor: Move message queue to pkg folder
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Jan 29, 2025
1 parent ce32473 commit eccacc0
Show file tree
Hide file tree
Showing 52 changed files with 360 additions and 241 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ gen:
--go-grpc_opt=paths=source_relative \
internal/callbacker/callbacker_api/callbacker_api.proto

protoc \
--proto_path=. \
--go_out=. \
--go_opt=paths=source_relative \
--go-grpc_out=. \
--go-grpc_opt=paths=source_relative \
pkg/message_queue/nats/client/test_api/test_api.proto

.PHONY: clean_gen
clean_gen:
rm -f ./internal/metamorph/metamorph_api/*.pb.go
Expand Down
10 changes: 5 additions & 5 deletions cmd/arc/services/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
"github.com/bitcoin-sv/arc/internal/blocktx"
"github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api"
arc_logger "github.com/bitcoin-sv/arc/internal/logger"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_core"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_jetstream"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/nats_connection"
"github.com/bitcoin-sv/arc/internal/metamorph"
"github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api"
"github.com/bitcoin-sv/arc/internal/node_client"
"github.com/bitcoin-sv/arc/internal/tracing"
tx_finder "github.com/bitcoin-sv/arc/internal/tx_finder"
"github.com/bitcoin-sv/arc/pkg/api"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_core"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_jetstream"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/nats_connection"
"github.com/bitcoin-sv/arc/pkg/tracing"
"github.com/bitcoin-sv/arc/pkg/woc_client"
)

Expand Down Expand Up @@ -66,7 +66,7 @@ func StartAPIServer(logger *slog.Logger, arcConfig *config.ArcConfig) (func(), e
shutdownFns := make([]func(), 0)

if arcConfig.IsTracingEnabled() {
cleanup, err := tracing.Enable(logger, "api", arcConfig.Tracing)
cleanup, err := tracing.Enable(logger, "api", arcConfig.Tracing.DialAddr, arcConfig.Tracing.Sample)
if err != nil {
logger.Error("failed to enable tracing", slog.String("err", err.Error()))
} else {
Expand Down
10 changes: 5 additions & 5 deletions cmd/arc/services/blocktx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
"github.com/bitcoin-sv/arc/internal/blocktx/store"
"github.com/bitcoin-sv/arc/internal/blocktx/store/postgresql"
"github.com/bitcoin-sv/arc/internal/grpc_opts"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_core"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_jetstream"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/nats_connection"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/internal/version"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_core"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_jetstream"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/nats_connection"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

const (
Expand Down Expand Up @@ -49,7 +49,7 @@ func StartBlockTx(logger *slog.Logger, arcConfig *config.ArcConfig) (func(), err
processorOpts := make([]func(handler *blocktx.Processor), 0)

if arcConfig.IsTracingEnabled() {
cleanup, err := tracing.Enable(logger, "blocktx", arcConfig.Tracing)
cleanup, err := tracing.Enable(logger, "blocktx", arcConfig.Tracing.DialAddr, arcConfig.Tracing.Sample)
if err != nil {
logger.Error("failed to enable tracing", slog.String("err", err.Error()))
} else {
Expand Down
4 changes: 2 additions & 2 deletions cmd/arc/services/callbacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (
"github.com/bitcoin-sv/arc/internal/callbacker/store"
"github.com/bitcoin-sv/arc/internal/callbacker/store/postgresql"
"github.com/bitcoin-sv/arc/internal/grpc_opts"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_jetstream"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/nats_connection"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_jetstream"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/nats_connection"
)

func StartCallbacker(logger *slog.Logger, arcConfig *config.ArcConfig) (func(), error) {
Expand Down
10 changes: 5 additions & 5 deletions cmd/arc/services/metamorph.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import (
"google.golang.org/grpc"

"github.com/bitcoin-sv/arc/internal/cache"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_core"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_jetstream"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/nats_connection"
"github.com/bitcoin-sv/arc/pkg/tracing"

"github.com/bitcoin-sv/arc/config"
"github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api"
"github.com/bitcoin-sv/arc/internal/callbacker"
"github.com/bitcoin-sv/arc/internal/callbacker/callbacker_api"
"github.com/bitcoin-sv/arc/internal/grpc_opts"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_core"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_jetstream"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/nats_connection"
"github.com/bitcoin-sv/arc/internal/metamorph"
"github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api"
"github.com/bitcoin-sv/arc/internal/metamorph/store"
Expand Down Expand Up @@ -61,7 +61,7 @@ func StartMetamorph(logger *slog.Logger, arcConfig *config.ArcConfig, cacheStore
callbackerOpts := make([]callbacker.Option, 0)

if arcConfig.IsTracingEnabled() {
cleanup, err := tracing.Enable(logger, "metamorph", arcConfig.Tracing)
cleanup, err := tracing.Enable(logger, "metamorph", arcConfig.Tracing.DialAddr, arcConfig.Tracing.Sample)
if err != nil {
logger.Error("failed to enable tracing", slog.String("err", err.Error()))
} else {
Expand Down
2 changes: 1 addition & 1 deletion internal/api/handler/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/bitcoin-sv/arc/internal/api/handler/internal/merkle_verifier"
"github.com/bitcoin-sv/arc/internal/metamorph"
"github.com/bitcoin-sv/arc/pkg/tracing"

sdkTx "github.com/bitcoin-sv/go-sdk/transaction"
"github.com/labstack/echo/v4"
Expand All @@ -22,7 +23,6 @@ import (
"github.com/bitcoin-sv/arc/internal/beef"
"github.com/bitcoin-sv/arc/internal/blocktx"
"github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/internal/validator"
beefValidator "github.com/bitcoin-sv/arc/internal/validator/beef"
defaultValidator "github.com/bitcoin-sv/arc/internal/validator/default"
Expand Down
2 changes: 1 addition & 1 deletion internal/blocktx/blocktx_api/blocktx_api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/blocktx/blocktx_api/blocktx_api_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/blocktx/integration_test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"github.com/bitcoin-sv/arc/internal/blocktx"
"github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api"
"github.com/bitcoin-sv/arc/internal/blocktx/store/postgresql"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_core"
nats_mock "github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_core/mocks"
testutils "github.com/bitcoin-sv/arc/internal/test_utils"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_core"
nats_mock "github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_core/mocks"
"github.com/bitcoin-sv/arc/pkg/test_utils"
)

func setupSut(t *testing.T, dbInfo string) (*blocktx.Processor, *blocktx.PeerHandler, *postgresql.PostgreSQL, chan []byte, chan *blocktx_api.TransactionBlock) {
Expand Down
2 changes: 1 addition & 1 deletion internal/blocktx/integration_test/merkle_paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/stretchr/testify/require"

testutils "github.com/bitcoin-sv/arc/internal/test_utils"
"github.com/bitcoin-sv/arc/pkg/test_utils"
)

func TestMerklePaths(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions internal/blocktx/integration_test/reorg_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"time"

"github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api"
"github.com/bitcoin-sv/arc/pkg/test_utils"

_ "github.com/golang-migrate/migrate/v4/source/file"
_ "github.com/lib/pq"
Expand All @@ -41,8 +42,6 @@ import (
"github.com/libsv/go-p2p/chaincfg/chainhash"
"github.com/libsv/go-p2p/wire"
"github.com/stretchr/testify/require"

testutils "github.com/bitcoin-sv/arc/internal/test_utils"
)

func TestReorg(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/blocktx/integration_test/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"os"
"testing"

testutils "github.com/bitcoin-sv/arc/internal/test_utils"
_ "github.com/golang-migrate/migrate/v4/source/file"
_ "github.com/lib/pq"
"github.com/ory/dockertest/v3"

"github.com/bitcoin-sv/arc/pkg/test_utils"
)

const migrationsPath = "file://../store/postgresql/migrations"
Expand Down
2 changes: 1 addition & 1 deletion internal/blocktx/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api"
"github.com/bitcoin-sv/arc/internal/blocktx/store"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/libsv/go-p2p/chaincfg/chainhash"

"github.com/bitcoin-sv/arc/internal/blocktx/store"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

func (p *PostgreSQL) GetBlockTransactionsHashes(ctx context.Context, blockHash []byte) (txHashes []*chainhash.Hash, err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/blocktx/store/postgresql/get_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api"
"github.com/bitcoin-sv/arc/internal/blocktx/store"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

func (p *PostgreSQL) GetMinedTransactions(ctx context.Context, hashes [][]byte, onlyLongestChain bool) (minedTransactions []store.BlockTransaction, err error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/jackc/pgx/v5/stdlib"

"github.com/bitcoin-sv/arc/internal/blocktx/store"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

// InsertBlockTransactions inserts the transaction hashes for a given block hash
Expand Down
2 changes: 1 addition & 1 deletion internal/blocktx/store/postgresql/mark_block_as_done.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/libsv/go-p2p/chaincfg/chainhash"

"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

func (p *PostgreSQL) MarkBlockAsDone(ctx context.Context, hash *chainhash.Hash, size uint64, txCount uint64) (err error) {
Expand Down
3 changes: 1 addition & 2 deletions internal/blocktx/store/postgresql/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/lib/pq"

"github.com/bitcoin-sv/arc/internal/testdata"
testutils "github.com/bitcoin-sv/arc/pkg/test_utils"

_ "github.com/golang-migrate/migrate/v4/source/file"
"github.com/jmoiron/sqlx"
Expand All @@ -22,8 +23,6 @@ import (

"github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api"
"github.com/bitcoin-sv/arc/internal/blocktx/store"

testutils "github.com/bitcoin-sv/arc/internal/test_utils"
)

type Block struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/blocktx/store/postgresql/upsert_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api"
"github.com/bitcoin-sv/arc/internal/blocktx/store"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

func (p *PostgreSQL) UpsertBlock(ctx context.Context, block *blocktx_api.Block) (blockID uint64, err error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cache/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/ory/dockertest/v3"
"github.com/stretchr/testify/require"

testutils "github.com/bitcoin-sv/arc/internal/test_utils"
"github.com/bitcoin-sv/arc/pkg/test_utils"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/callbacker/callbacker_api/callbacker_api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/callbacker/grpc_callbacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/bitcoin-sv/arc/internal/callbacker/callbacker_api"
"github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api"
"github.com/bitcoin-sv/arc/internal/metamorph/store"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

var minedDoubleSpendMsg = "previously double spend attempted"
Expand Down
2 changes: 1 addition & 1 deletion internal/callbacker/store/postgresql/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (

"github.com/bitcoin-sv/arc/internal/callbacker/store"
tutils "github.com/bitcoin-sv/arc/internal/callbacker/store/postgresql/internal/tests"
testutils "github.com/bitcoin-sv/arc/internal/test_utils"
"github.com/bitcoin-sv/arc/internal/testdata"
testutils "github.com/bitcoin-sv/arc/pkg/test_utils"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/metamorph/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/bitcoin-sv/arc/config"
"github.com/bitcoin-sv/arc/internal/grpc_opts"
"github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api"
"github.com/bitcoin-sv/arc/internal/metamorph/mocks"
"github.com/bitcoin-sv/arc/internal/metamorph/store/postgresql"
testutils "github.com/bitcoin-sv/arc/internal/test_utils"
"github.com/bitcoin-sv/arc/pkg/test_utils"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/metamorph/integration_test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"database/sql"
"testing"

testutils "github.com/bitcoin-sv/arc/internal/test_utils"
"github.com/bitcoin-sv/arc/pkg/test_utils"
)

func pruneTables(t *testing.T, db *sql.DB) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"time"

"github.com/bitcoin-sv/arc/internal/cache"
"github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_core"
nats_mocks "github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_core/mocks"
"github.com/bitcoin-sv/arc/internal/metamorph"
"github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api"
"github.com/bitcoin-sv/arc/internal/metamorph/mocks"
"github.com/bitcoin-sv/arc/internal/metamorph/store"
"github.com/bitcoin-sv/arc/internal/metamorph/store/postgresql"
testutils "github.com/bitcoin-sv/arc/internal/test_utils"
"github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_core"
nats_mocks "github.com/bitcoin-sv/arc/pkg/message_queue/nats/client/nats_core/mocks"
"github.com/bitcoin-sv/arc/pkg/test_utils"

"github.com/libsv/go-p2p"
"github.com/libsv/go-p2p/chaincfg/chainhash"
"github.com/stretchr/testify/require"
Expand Down
3 changes: 2 additions & 1 deletion internal/metamorph/integration_test/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"os"
"testing"

testutils "github.com/bitcoin-sv/arc/internal/test_utils"
"github.com/go-redis/redis/v8"
"github.com/ory/dockertest/v3"

"github.com/bitcoin-sv/arc/pkg/test_utils"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/metamorph/metamorph_api/metamorph_api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/metamorph/metamorph_api/metamorph_api_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/metamorph/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/bitcoin-sv/arc/internal/cache"
"github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api"
"github.com/bitcoin-sv/arc/internal/metamorph/store"
"github.com/bitcoin-sv/arc/internal/tracing"
"github.com/bitcoin-sv/arc/pkg/tracing"
)

const (
Expand Down
Loading

0 comments on commit eccacc0

Please sign in to comment.