Skip to content

Commit

Permalink
fix: add go task, rename bus message type
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Jul 12, 2024
1 parent b4fe038 commit d9470bd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion node/pkg/admin/host/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func getPeerCount(c *fiber.Ctx) error {
}

func sync(c *fiber.Ctx) error {
msg, err := utils.SendMessage(c, bus.LIBP2P, bus.SYNC, nil)
msg, err := utils.SendMessage(c, bus.LIBP2P, bus.LIBP2P_SYNC, nil)
if err != nil {
log.Error().Err(err).Str("Player", "Admin").Msg("failed to send message to libp2p helper")
return c.Status(fiber.StatusInternalServerError).SendString("failed to sync libp2p host: " + err.Error())
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/admin/tests/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestSync(t *testing.T) {
defer cleanup()

channel := testItems.mb.Subscribe(bus.LIBP2P)
waitForMessage(t, channel, bus.ADMIN, bus.LIBP2P, bus.SYNC)
waitForMessage(t, channel, bus.ADMIN, bus.LIBP2P, bus.LIBP2P_SYNC)

result, err := RawPostRequest(testItems.app, "/api/v1/host/sync", nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/bus/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ const (
REFRESH_REPORTER = "refresh_reporter"

GET_PEER_COUNT = "get_peer_count"
SYNC = "sync"
LIBP2P_SYNC = "libp2p_sync"
)
2 changes: 1 addition & 1 deletion node/pkg/libp2p/helper/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (a *App) handleMessage(ctx context.Context, msg bus.Message) {
log.Debug().Str("Player", "Libp2pHelper").Msg("get peer count msg received")
peerCount := len(a.Host.Network().Peers())
msg.Response <- bus.MessageResponse{Success: true, Args: map[string]any{"Count": peerCount}}
case bus.SYNC:
case bus.LIBP2P_SYNC:
log.Debug().Str("Player", "Libp2pHelper").Msg("libp2p sync msg received")
err := setup.ConnectThroughBootApi(ctx, a.Host)
if err != nil {
Expand Down
10 changes: 9 additions & 1 deletion node/taskfiles/taskfile.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ tasks:
renew-signer:
dotenv: [".env"]
cmds:
- curl -X POST "http://localhost:$APP_PORT/api/v1/aggregator/renew-signer" | jq
- curl -X POST "http://localhost:$APP_PORT/api/v1/aggregator/renew-signer"
add-json-rpc:
dotenv: [".env"]
cmds:
Expand All @@ -201,6 +201,14 @@ tasks:
dotenv: [".env"]
cmds:
- curl -X GET "http://localhost:$APP_PORT/api/v1/provider-url" | jq
get-peer-count:
dotenv: [".env"]
cmds:
- curl -X GET "http://localhost:$APP_PORT/api/v1/host/peercount" | jq
sync-libp2p:
dotenv: [".env"]
cmds:
- curl -X POST "http://localhost:$APP_PORT/api/v1/host/sync"
test:
cmds:
- task: test-db
Expand Down

0 comments on commit d9470bd

Please sign in to comment.