Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiaddress not constructed on startup #524

Merged
merged 11 commits into from
Aug 24, 2024

Conversation

teslashibe
Copy link
Contributor

@teslashibe teslashibe commented Aug 22, 2024

Description

This PR fixes a critical bug where a nodes multiaddr is not correctly constructed/formed. It introduces several improvements to our network operations and worker selection process:

  1. Network Address Handling:

    • Refactored GetPriorityAddress to better handle public and private addresses
    • Added support for GCP external IP detection
    • Improved IP component replacement in multiaddresses
  2. DHT and Peer Discovery:

    • Updated WithDht function to use NodeData for more comprehensive peer information
    • Enhanced peer discovery process in the DHT
  3. Worker Selection:

    • Refactored GetEligibleWorkers to use DHT for finding peer information
    • Improved connection attempts to eligible workers with better error handling
    • Added shuffling of eligible nodes to avoid always selecting the same worker
  4. Error Handling and Logging:

    • Enhanced error handling in Twitter scraper and other network operations
    • Improved logging throughout the codebase for better debugging
  5. Code Structure:

    • Moved HTTP client operations to the network package for better organization
    • Updated imports and package references for consistency
  6. Performance:

    • Adjusted timeouts and retries for better network performance
    • Added performance logging for worker selection process
  7. Artifact Handling:

    • Updated artifact creation and handling process in the assistant

These changes aim to improve the robustness and efficiency of our network operations, especially in peer discovery and worker selection. The refactoring also enhances code organization and error handling across the project.

Testing:

  • Tested peer discovery and connection in various network conditions
  • Verified worker selection process with both local and remote workers
  • Ensured compatibility with existing network operations

Notes for Reviewers

Tested initially and handles current edge cases well even when remote worker node is behind a firewall with no open ports :)

Signed commits

  • Yes, I signed my commits.

restevens402 and others added 3 commits August 21, 2024 19:17
Restructure how multiaddresses and IP addresses are handled within the codebase to improve maintainability and efficiency. Added logic for obtaining GCP external IP addresses and restructured public address retrieval. Moved HTTP client functionality to a new package and updated references accordingly.
- Handle invalid multiaddresses gracefully
- Continue searching for eligible workers on errors
- Add more detailed logging for debugging
- Prevent potential nil pointer dereference
- Log warning if no workers found
Copy link

PR description is too short and seems to not fulfill PR template, please fill in

Copy link

⚠ golint failed (.)

Found 191 lint suggestions; failing.

Show Detail
cmd/masa-node-cli/handlers.go:159:10: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/handlers.go:185:9: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/types.go:10:6: exported type AppConfig should have comment or be unexported
cmd/masa-node-cli/types.go:22:6: exported type Gossip should have comment or be unexported
cmd/masa-node-cli/types.go:27:6: exported type SpeakRequest should have comment or be unexported
cmd/masa-node-cli/types.go:35:6: exported type SubscriptionHandler should have comment or be unexported
cmd/masa-node-cli/types.go:41:6: exported type RadioButtons should have comment or be unexported
cmd/masa-node-cli/types.go:48:6: exported type InputBox should have comment or be unexported
cmd/tagger/main.go:23:1: package comment is detached; there should be no blank lines between it and the package statement
cmd/tagger/main.go:100:1: exported function TagProject should have comment or be unexported
internal/versioning/version.go:4:2: exported var ApplicationVersion should have comment or be unexported
internal/versioning/version.go:6:2: comment on exported var ProtocolVersion should be of the form "ProtocolVersion ..."
pkg/oracle_node.go:42:6: exported type OracleNode should have comment or be unexported
pkg/oracle_node.go:336:6: exported type BlockData should have comment or be unexported
pkg/oracle_node.go:344:6: exported type Blocks should have comment or be unexported
pkg/oracle_node.go:348:6: exported type BlockEvents should have comment or be unexported
pkg/oracle_node.go:350:6: exported type BlockEventTracker should have comment or be unexported
pkg/oracle_node.go:463:1: exported function SubscribeToBlocks should have comment or be unexported
pkg/oracle_node_listener.go:77:6: exported type NodeDataPage should have comment or be unexported
pkg/oracle_node_listener.go:208:2: var remotePeerId should be remotePeerID
pkg/api/api.go:12:6: exported type API should have comment or be unexported
pkg/api/config.go:6:6: type name will be used as api.APIConfig by other packages, and that stutters; consider calling this Config
pkg/api/config.go:11:5: exported var DefaultConfig should have comment or be unexported
pkg/api/handlers_data.go:32:6: exported type LLMChat should have comment or be unexported
pkg/api/handlers_data.go:41:1: exported function IsBase64 should have comment or be unexported
pkg/api/handlers_data.go:366:4: struct field Url should be URL
pkg/api/handlers_data.go:826:4: struct field Url should be URL
pkg/api/handlers_data.go:912:1: exported method API.GetChannelMessagesHandler should have comment or be unexported
pkg/api/handlers_data.go:1058:3: var cfUrl should be cfURL
pkg/api/handlers_node.go:435:17: method GetNodeApiKey should be GetNodeAPIKey
pkg/chain/block.go:13:6: exported type Block should have comment or be unexported
pkg/chain/block.go:21:1: exported method Block.Build should have comment or be unexported
pkg/chain/block.go:30:1: exported method Block.Serialize should have comment or be unexported
pkg/chain/block.go:40:1: exported method Block.Deserialize should have comment or be unexported
pkg/chain/block.go:51:1: exported method Block.Print should have comment or be unexported
pkg/chain/chain.go:13:6: exported type Chain should have comment or be unexported
pkg/chain/chain.go:173:1: exported method Chain.GetBlock should have comment or be unexported
pkg/chain/persistance.go:9:2: exported const KeyLastHash should have comment (or a comment on this block) or be unexported
pkg/chain/persistance.go:12:6: exported type Persistance should have comment or be unexported
pkg/chain/persistance.go:16:6: exported type Serializable should have comment or be unexported
pkg/chain/persistance.go:21:1: exported method Persistance.Init should have comment or be unexported
pkg/chain/persistance.go:74:1: exported method Persistance.Get should have comment or be unexported
pkg/chain/persistance.go:96:1: exported method Persistance.GetLastHash should have comment or be unexported
pkg/chain/persistance.go:100:1: exported method Persistance.SaveBlock should have comment or be unexported
pkg/chain/persistance.go:122:1: exported method Persistance.Iterate should have comment or be unexported
pkg/chain/pos.go:16:6: exported type ProofOfStake should have comment or be unexported
pkg/chain/pos.go:44:1: exported method ProofOfStake.Run should have comment or be unexported
pkg/chain/pos.go:68:1: exported function IsValidPoS should have comment or be unexported
pkg/config/app.go:68:2: struct field RpcUrl should be RPCURL
pkg/config/app.go:70:2: struct field AllowedPeerId should be AllowedPeerID
pkg/config/app.go:85:2: struct field ClaudeApiKey should be ClaudeAPIKey
pkg/config/app.go:86:2: struct field ClaudeApiURL should be ClaudeAPIURL
pkg/config/app.go:87:2: struct field ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/app.go:94:2: struct field LLMChatUrl should be LLMChatURL
pkg/config/app.go:95:2: struct field LLMCfUrl should be LLMCfURL
pkg/config/constants.go:81:2: exported const PrivKeyFile should have comment (or a comment on this block) or be unexported
pkg/config/constants.go:84:2: const RpcUrl should be RPCURL
pkg/config/constants.go:116:2: const ClaudeApiKey should be ClaudeAPIKey
pkg/config/constants.go:117:2: const ClaudeApiURL should be ClaudeAPIURL
pkg/config/constants.go:118:2: const ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/constants.go:125:2: const LlmChatUrl should be LlmChatURL
pkg/config/constants.go:126:2: const LlmCfUrl should be LlmCfURL
pkg/config/constants.go:149:1: exported function GetCloudflareModels should have comment or be unexported
pkg/config/welcome.go:7:1: exported function DisplayWelcomeMessage should have comment or be unexported
pkg/consensus/pow.go:20:1: exported function GeneratePoW should have comment or be unexported
pkg/consensus/pow.go:20:18: func parameter peerId should be peerID
pkg/consensus/pow.go:42:1: exported function ComputeProofOfWork should have comment or be unexported
pkg/consensus/pow.go:42:25: func parameter peerId should be peerID
pkg/consensus/signer.go:20:1: exported function GenerateJWTToken should have comment or be unexported
pkg/consensus/signer.go:20:23: func parameter peerId should be peerID
pkg/db/operations.go:17:6: exported type WorkEvent should have comment or be unexported
pkg/db/operations.go:19:2: struct field PeerId should be PeerID
pkg/db/resolver_cache.go:26:6: exported type Record should have comment or be unexported
pkg/db/resolver_cache.go:74:9: if block ends with a return statement, so drop this else and outdent its block
pkg/db/resolver_cache.go:115:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/client.go:18:6: exported type ClaudeClient should have comment or be unexported
pkg/llmbridge/client.go:22:6: exported type GPTClient should have comment or be unexported
pkg/llmbridge/client.go:54:1: exported method GPTClient.SendRequest should have comment or be unexported
pkg/llmbridge/client.go:96:6: exported type Response should have comment or be unexported
pkg/llmbridge/client.go:107:6: exported type ResponseContent should have comment or be unexported
pkg/llmbridge/client.go:113:6: exported type ResponseError should have comment or be unexported
pkg/llmbridge/client.go:118:6: exported type Usage should have comment or be unexported
pkg/llmbridge/config.go:5:6: exported type ClaudeAPIConfig should have comment or be unexported
pkg/llmbridge/config.go:11:6: exported type GPTAPIConfig should have comment or be unexported
pkg/llmbridge/payload.go:7:6: exported type Payload should have comment or be unexported
pkg/llmbridge/payload.go:15:6: exported type Message should have comment or be unexported
pkg/llmbridge/payload.go:20:6: exported type Content should have comment or be unexported
pkg/llmbridge/sentiment.go:169:3: var cfUrl should be cfURL
pkg/llmbridge/sentiment.go:270:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/sentiment.go:354:9: if block ends with a return statement, so drop this else and outdent its block
pkg/masacrypto/keys.go:135:1: exported function Libp2pPubKeyToEthAddress should have comment or be unexported
pkg/network/events.go:7:6: exported type PeerEvent should have comment or be unexported
pkg/network/http_client.go:16:2: exported const GET should have comment (or a comment on this block) or be unexported
pkg/network/http_client.go:38:1: exported function Get should have comment or be unexported
pkg/network/http_client.go:42:1: exported function Post should have comment or be unexported
pkg/network/http_client.go:46:1: exported function Put should have comment or be unexported
pkg/network/http_client.go:50:1: exported function Patch should have comment or be unexported
pkg/network/http_client.go:88:10: if block ends with a return statement, so drop this else and outdent its block
pkg/network/kdht.go:24:2: exported const PeerAdded should have comment (or a comment on this block) or be unexported
pkg/network/kdht.go:33:1: exported function WithDht should have comment or be unexported
pkg/network/kdht.go:33:51: func parameter protocolId should be protocolID
pkg/network/mdns.go:9:7: exported const PeerFound should have comment or be unexported
pkg/network/mdns.go:27:1: exported function WithMDNS should have comment or be unexported
pkg/pubsub/manager.go:22:6: exported type Manager should have comment or be unexported
pkg/pubsub/node_data.go:20:2: exported const ActivityJoined should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_data.go:24:6: exported type JSONMultiaddr should have comment or be unexported
pkg/pubsub/node_data.go:47:6: exported type NodeData should have comment or be unexported
pkg/pubsub/node_data.go:50:2: struct field PeerId should be PeerID
pkg/pubsub/node_data.go:76:44: func parameter peerId should be peerID
pkg/pubsub/node_data.go:108:2: exported const CategoryDiscord should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_event_tracker.go:19:6: exported type NodeEventTracker should have comment or be unexported
pkg/pubsub/node_event_tracker.go:26:6: exported type ConnectBufferEntry should have comment or be unexported
pkg/pubsub/node_event_tracker.go:35:55: func parameter hostId should be hostID
pkg/pubsub/node_event_tracker.go:81:9: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:178:10: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:440:71: method parameter hostId should be hostID
pkg/pubsub/node_event_tracker.go:455:48: method parameter hostId should be hostID
pkg/pubsub/public_key_topic.go:23:6: exported type PublicKeyPublisher should have comment or be unexported
pkg/pubsub/public_key_topic.go:184:1: comment on exported method PublicKeyPublisher.GetPublishedMessages should be of the form "GetPublishedMessages ..."
pkg/pubsub/safe_map.go:11:6: exported type SafeMap should have comment or be unexported
pkg/pubsub/worker_tracker.go:11:6: exported type Workers should have comment or be unexported
pkg/scrapers/discord/exchangetoken.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getchannelmessages.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getguildchannels.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getuserguilds.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/reddit/reddit.go:5:1: exported function TestReddit should have comment or be unexported
pkg/scrapers/telegram/telegram_client.go:30:1: exported function GetClient should have comment or be unexported
pkg/scrapers/twitter/auth.go:41:1: exported function IsLoggedIn should have comment or be unexported
pkg/scrapers/twitter/auth.go:45:1: exported function Logout should have comment or be unexported
pkg/scrapers/twitter/cookies.go:12:1: exported function SaveCookies should have comment or be unexported
pkg/scrapers/twitter/cookies.go:25:1: exported function LoadCookies should have comment or be unexported
pkg/scrapers/twitter/followers.go:7:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:8:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:17:6: exported type TweetResult should have comment or be unexported
pkg/staking/abi.go:13:2: exported const MasaTokenABIPath should have comment (or a comment on this block) or be unexported
pkg/staking/abi.go:18:6: exported type ContractAddresses should have comment or be unexported
pkg/staking/contracts.go:13:5: exported var MasaTokenAddress should have comment or be unexported
pkg/staking/contracts.go:14:5: exported var ProtocolStakingContractAddress should have comment or be unexported
pkg/staking/contracts.go:16:6: exported type Client should have comment or be unexported
pkg/staking/faucet.go:11:1: exported method Client.RunFaucet should have comment or be unexported
pkg/workers/config.go:9:6: exported type WorkerConfig should have comment or be unexported
pkg/workers/config.go:19:5: exported var DefaultConfig should have comment or be unexported
pkg/workers/config.go:39:1: exported function LoadConfig should have comment or be unexported
pkg/workers/response_channel_map.go:9:6: exported type ResponseChannelMap should have comment or be unexported
pkg/workers/response_channel_map.go:64:1: exported method ResponseChannelMap.CreateChannel should have comment or be unexported
pkg/workers/worker_manager.go:27:1: exported function GetWorkHandlerManager should have comment or be unexported
pkg/workers/worker_manager.go:97:1: exported method WorkHandlerManager.DistributeWork should have comment or be unexported
pkg/workers/worker_manager.go:139:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/workers/worker_manager.go:238:1: exported method WorkHandlerManager.HandleWorkerStream should have comment or be unexported
pkg/workers/worker_manager.go:269:2: var peerId should be peerID
pkg/workers/handlers/discord.go:12:6: exported type DiscordProfileHandler should have comment or be unexported
pkg/workers/handlers/discord.go:13:6: exported type DiscordChannelHandler should have comment or be unexported
pkg/workers/handlers/discord.go:14:6: exported type DiscordSentimentHandler should have comment or be unexported
pkg/workers/handlers/discord.go:15:6: exported type DiscordGuildHandler should have comment or be unexported
pkg/workers/handlers/discord.go:16:6: exported type DiscoreUserGuildsHandler should have comment or be unexported
pkg/workers/handlers/discord.go:82:1: exported method DiscoreUserGuildsHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/helper.go:7:1: exported function JsonBytesToMap should have comment or be unexported
pkg/workers/handlers/helper.go:7:6: func JsonBytesToMap should be JSONBytesToMap
pkg/workers/handlers/llm.go:14:1: comment on exported type LLMChatBody should be of the form "LLMChatBody ..." (with optional leading article)
pkg/workers/handlers/llm.go:24:6: exported type LLMChatHandler should have comment or be unexported
pkg/workers/handlers/telegram.go:13:6: exported type TelegramSentimentHandler should have comment or be unexported
pkg/workers/handlers/telegram.go:14:6: exported type TelegramChannelHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:12:6: exported type TwitterQueryHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:13:6: exported type TwitterFollowersHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:14:6: exported type TwitterProfileHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:15:6: exported type TwitterSentimentHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:16:6: exported type TwitterTrendsHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:18:1: exported method TwitterQueryHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:33:1: exported method TwitterFollowersHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:48:1: exported method TwitterProfileHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:62:1: exported method TwitterSentimentHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:78:1: exported method TwitterTrendsHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/web.go:14:6: exported type WebSentimentHandler should have comment or be unexported
pkg/workers/handlers/web.go:16:1: exported method WebHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/web.go:31:1: exported method WebSentimentHandler.HandleWork should have comment or be unexported
pkg/workers/types/request_response.go:1:1: don't use an underscore in package name
pkg/workers/types/request_response.go:10:6: exported type Worker should have comment or be unexported
pkg/workers/types/request_response.go:18:6: exported type WorkRequest should have comment or be unexported
pkg/workers/types/request_response.go:20:2: struct field RequestId should be RequestID
pkg/workers/types/request_response.go:24:6: exported type WorkResponse should have comment or be unexported
pkg/workers/types/request_response.go:28:2: struct field WorkerPeerId should be WorkerPeerID
pkg/workers/types/work_types.go:1:1: don't use an underscore in package name
pkg/workers/types/work_types.go:9:6: exported type WorkerType should have comment or be unexported
pkg/workers/types/work_types.go:12:2: exported const Discord should have comment (or a comment on this block) or be unexported
tests/node_listener.go:28:6: exported type NodeListener should have comment or be unexported
tests/node_listener.go:31:2: struct field ServerId should be ServerID
tests/node_listener.go:36:1: exported function NewNodeListener should have comment or be unexported
tests/node_listener.go:54:1: exported method NodeListener.Start should have comment or be unexported
tools/abigen_helper.go:14:6: exported type Contract should have comment or be unexported
tools/abigen_helper.go:19:1: exported function AbiGen should have comment or be unexported
tools/abigen_helper.go:56:1: exported function AbiGenBindings should have comment or be unexported

Copy link

⚠ gosec failed (.)

2024/08/22 05:31:16 internal error: package "flag" without types was imported from "command-line-arguments"
Show Detail
2024/08/22 05:31:16 internal error: package "flag" without types was imported from "command-line-arguments"

Code Reference

Copy link

⚠ goimports failed (.)

pkg/api/handlers_data.go
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/discord"
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/telegram"
 	"github.com/masa-finance/masa-oracle/pkg/workers"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type LLMChat struct {
pkg/db/access_control.go
 
 import (
 	"encoding/hex"
+
 	libp2pCrypto "github.com/libp2p/go-libp2p/core/crypto"
 	"github.com/libp2p/go-libp2p/core/host"
 	"github.com/sirupsen/logrus"
pkg/workers/handlers/discord.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/discord"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type DiscordProfileHandler struct{}
pkg/workers/handlers/llm.go
 
 	"github.com/masa-finance/masa-oracle/pkg/config"
 	"github.com/masa-finance/masa-oracle/pkg/network"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 // TODO: LLMChatBody isn't used anywhere in the codebase. Remove after testing
pkg/workers/handlers/telegram.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/telegram"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type TelegramSentimentHandler struct{}
pkg/workers/handlers/twitter.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/twitter"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type TwitterQueryHandler struct{}
pkg/workers/handlers/web.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/web"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 // WebHandler - All the web handlers implement the WorkHandler interface.
pkg/workers/response_channel_map.go
 import (
 	"sync"
 
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type ResponseChannelMap struct {

Copy link

⚠ shadow failed (.)

# github.com/masa-finance/masa-oracle/pkg/chain
pkg/chain/persistance.go:35:9: declaration of "err" shadows declaration at line 24
pkg/chain/persistance.go:41:17: declaration of "err" shadows declaration at line 35
# github.com/masa-finance/masa-oracle/pkg/pubsub
pkg/pubsub/public_key_topic.go:62:16: declaration of "err" shadows declaration at line 50
# github.com/masa-finance/masa-oracle/pkg/network
pkg/network/address.go:187:3: declaration of "err" shadows declaration at line 173
pkg/network/discover.go:70:5: declaration of "err" shadows declaration at line 63
pkg/network/http_client.go:93:3: declaration of "err" shadows declaration at line 56
pkg/network/kdht.go:125:6: declaration of "err" shadows declaration at line 114
# github.com/masa-finance/masa-oracle/cmd/tagger
# [github.com/masa-finance/masa-oracle/cmd/tagger]
cmd/tagger/main.go:102:8: declaration of "err" shadows declaration at line 100
# github.com/masa-finance/masa-oracle/pkg/masacrypto
# [github.com/masa-finance/masa-oracle/pkg/masacrypto]
pkg/masacrypto/cert.go:61:5: declaration of "err" shadows declaration at line 23
pkg/masacrypto/cert_test.go:20:8: declaration of "err" shadows declaration at line 14
pkg/masacrypto/cert_test.go:25:8: declaration of "err" shadows declaration at line 14
# github.com/masa-finance/masa-oracle/tools
# [github.com/masa-finance/masa-oracle/tools]
tools/abigen_helper.go:34:5: declaration of "err" shadows declaration at line 27
tools/abigen_helper.go:76:5: declaration of "err" shadows declaration at line 70
# github.com/masa-finance/masa-oracle/pkg/scrapers/discord
pkg/scrapers/discord/getguildchannels.go:44:14: declaration of "err" shadows declaration at line 28
# github.com/masa-finance/masa-oracle/pkg/scrapers/telegram
pkg/scrapers/telegram/getchannelmessages.go:25:13: declaration of "err" shadows declaration at line 16
pkg/scrapers/telegram/telegram_client.go:84:13: declaration of "err" shadows declaration at line 73
pkg/scrapers/telegram/telegram_client.go:131:9: declaration of "err" shadows declaration at line 120
# github.com/masa-finance/masa-oracle/pkg/workers
pkg/workers/worker_manager.go:148:4: declaration of "err" shadows declaration at line 141
# github.com/masa-finance/masa-oracle/pkg/api
pkg/api/handlers_data.go:630:6: declaration of "err" shadows declaration at line 608
pkg/api/handlers_data.go:643:8: declaration of "err" shadows declaration at line 608
pkg/api/handlers_data.go:1079:4: declaration of "err" shadows declaration at line 1052
# github.com/masa-finance/masa-oracle/cmd/masa-node
# [github.com/masa-finance/masa-oracle/cmd/masa-node]
cmd/masa-node/main.go:121:3: declaration of "cfg" shadows declaration at line 31
cmd/masa-node/main.go:123:7: declaration of "err" shadows declaration at line 62

Copy link

⚠ errcheck failed (.)

error: failed to check packages: errors while loading package github.com/masa-finance/masa-oracle/cmd/masa-node: [-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.]

Copy link

⚠ staticcheck failed (.)

-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping. (compile)
pkg/api/handlers_data.go:92:6: func publishWorkRequest is unused (U1000)
pkg/oracle_node.go:80:6: func getOutboundIP is unused (U1000)
pkg/scrapers/telegram/telegram_client.go:24:2: var once is unused (U1000)
pkg/staking/abi.go:6:2: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details.  (SA1019)
tests/node_listener.go:136:2: this value of err is never used (SA4006)

Checks Document

@teslashibe teslashibe changed the title Fix multiaddress not constructed on startup fix multiaddress not constructed on startup Aug 22, 2024
@teslashibe teslashibe changed the title fix multiaddress not constructed on startup fix: multiaddress not constructed on startup Aug 22, 2024
Copy link

PR description is too short and seems to not fulfill PR template, please fill in

1 similar comment
Copy link

PR description is too short and seems to not fulfill PR template, please fill in

This commit simplifies the worker eligibility criteria in the CanDoWork method
of the NodeData struct. The following changes were made:

- Removed the check for node active status (IsActive)
- Removed the worker timeout check
- Retained the check for staked status (IsStaked)

The method now only considers if a node is staked and configured for the
specific worker type when determining eligibility. This change allows for
more inclusive worker participation, as nodes are no longer excluded based
on active status or timeout conditions.
Copy link

PR description is too short and seems to not fulfill PR template, please fill in

Copy link

⚠ golint failed (.)

Found 191 lint suggestions; failing.

Show Detail
cmd/masa-node-cli/handlers.go:159:10: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/handlers.go:185:9: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/types.go:10:6: exported type AppConfig should have comment or be unexported
cmd/masa-node-cli/types.go:22:6: exported type Gossip should have comment or be unexported
cmd/masa-node-cli/types.go:27:6: exported type SpeakRequest should have comment or be unexported
cmd/masa-node-cli/types.go:35:6: exported type SubscriptionHandler should have comment or be unexported
cmd/masa-node-cli/types.go:41:6: exported type RadioButtons should have comment or be unexported
cmd/masa-node-cli/types.go:48:6: exported type InputBox should have comment or be unexported
cmd/tagger/main.go:23:1: package comment is detached; there should be no blank lines between it and the package statement
cmd/tagger/main.go:100:1: exported function TagProject should have comment or be unexported
internal/versioning/version.go:4:2: exported var ApplicationVersion should have comment or be unexported
internal/versioning/version.go:6:2: comment on exported var ProtocolVersion should be of the form "ProtocolVersion ..."
pkg/oracle_node.go:42:6: exported type OracleNode should have comment or be unexported
pkg/oracle_node.go:336:6: exported type BlockData should have comment or be unexported
pkg/oracle_node.go:344:6: exported type Blocks should have comment or be unexported
pkg/oracle_node.go:348:6: exported type BlockEvents should have comment or be unexported
pkg/oracle_node.go:350:6: exported type BlockEventTracker should have comment or be unexported
pkg/oracle_node.go:463:1: exported function SubscribeToBlocks should have comment or be unexported
pkg/oracle_node_listener.go:77:6: exported type NodeDataPage should have comment or be unexported
pkg/oracle_node_listener.go:208:2: var remotePeerId should be remotePeerID
pkg/api/api.go:12:6: exported type API should have comment or be unexported
pkg/api/config.go:6:6: type name will be used as api.APIConfig by other packages, and that stutters; consider calling this Config
pkg/api/config.go:11:5: exported var DefaultConfig should have comment or be unexported
pkg/api/handlers_data.go:32:6: exported type LLMChat should have comment or be unexported
pkg/api/handlers_data.go:41:1: exported function IsBase64 should have comment or be unexported
pkg/api/handlers_data.go:366:4: struct field Url should be URL
pkg/api/handlers_data.go:826:4: struct field Url should be URL
pkg/api/handlers_data.go:912:1: exported method API.GetChannelMessagesHandler should have comment or be unexported
pkg/api/handlers_data.go:1058:3: var cfUrl should be cfURL
pkg/api/handlers_node.go:435:17: method GetNodeApiKey should be GetNodeAPIKey
pkg/chain/block.go:13:6: exported type Block should have comment or be unexported
pkg/chain/block.go:21:1: exported method Block.Build should have comment or be unexported
pkg/chain/block.go:30:1: exported method Block.Serialize should have comment or be unexported
pkg/chain/block.go:40:1: exported method Block.Deserialize should have comment or be unexported
pkg/chain/block.go:51:1: exported method Block.Print should have comment or be unexported
pkg/chain/chain.go:13:6: exported type Chain should have comment or be unexported
pkg/chain/chain.go:173:1: exported method Chain.GetBlock should have comment or be unexported
pkg/chain/persistance.go:9:2: exported const KeyLastHash should have comment (or a comment on this block) or be unexported
pkg/chain/persistance.go:12:6: exported type Persistance should have comment or be unexported
pkg/chain/persistance.go:16:6: exported type Serializable should have comment or be unexported
pkg/chain/persistance.go:21:1: exported method Persistance.Init should have comment or be unexported
pkg/chain/persistance.go:74:1: exported method Persistance.Get should have comment or be unexported
pkg/chain/persistance.go:96:1: exported method Persistance.GetLastHash should have comment or be unexported
pkg/chain/persistance.go:100:1: exported method Persistance.SaveBlock should have comment or be unexported
pkg/chain/persistance.go:122:1: exported method Persistance.Iterate should have comment or be unexported
pkg/chain/pos.go:16:6: exported type ProofOfStake should have comment or be unexported
pkg/chain/pos.go:44:1: exported method ProofOfStake.Run should have comment or be unexported
pkg/chain/pos.go:68:1: exported function IsValidPoS should have comment or be unexported
pkg/config/app.go:68:2: struct field RpcUrl should be RPCURL
pkg/config/app.go:70:2: struct field AllowedPeerId should be AllowedPeerID
pkg/config/app.go:85:2: struct field ClaudeApiKey should be ClaudeAPIKey
pkg/config/app.go:86:2: struct field ClaudeApiURL should be ClaudeAPIURL
pkg/config/app.go:87:2: struct field ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/app.go:94:2: struct field LLMChatUrl should be LLMChatURL
pkg/config/app.go:95:2: struct field LLMCfUrl should be LLMCfURL
pkg/config/constants.go:81:2: exported const PrivKeyFile should have comment (or a comment on this block) or be unexported
pkg/config/constants.go:84:2: const RpcUrl should be RPCURL
pkg/config/constants.go:116:2: const ClaudeApiKey should be ClaudeAPIKey
pkg/config/constants.go:117:2: const ClaudeApiURL should be ClaudeAPIURL
pkg/config/constants.go:118:2: const ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/constants.go:125:2: const LlmChatUrl should be LlmChatURL
pkg/config/constants.go:126:2: const LlmCfUrl should be LlmCfURL
pkg/config/constants.go:149:1: exported function GetCloudflareModels should have comment or be unexported
pkg/config/welcome.go:7:1: exported function DisplayWelcomeMessage should have comment or be unexported
pkg/consensus/pow.go:20:1: exported function GeneratePoW should have comment or be unexported
pkg/consensus/pow.go:20:18: func parameter peerId should be peerID
pkg/consensus/pow.go:42:1: exported function ComputeProofOfWork should have comment or be unexported
pkg/consensus/pow.go:42:25: func parameter peerId should be peerID
pkg/consensus/signer.go:20:1: exported function GenerateJWTToken should have comment or be unexported
pkg/consensus/signer.go:20:23: func parameter peerId should be peerID
pkg/db/operations.go:17:6: exported type WorkEvent should have comment or be unexported
pkg/db/operations.go:19:2: struct field PeerId should be PeerID
pkg/db/resolver_cache.go:26:6: exported type Record should have comment or be unexported
pkg/db/resolver_cache.go:74:9: if block ends with a return statement, so drop this else and outdent its block
pkg/db/resolver_cache.go:115:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/client.go:18:6: exported type ClaudeClient should have comment or be unexported
pkg/llmbridge/client.go:22:6: exported type GPTClient should have comment or be unexported
pkg/llmbridge/client.go:54:1: exported method GPTClient.SendRequest should have comment or be unexported
pkg/llmbridge/client.go:96:6: exported type Response should have comment or be unexported
pkg/llmbridge/client.go:107:6: exported type ResponseContent should have comment or be unexported
pkg/llmbridge/client.go:113:6: exported type ResponseError should have comment or be unexported
pkg/llmbridge/client.go:118:6: exported type Usage should have comment or be unexported
pkg/llmbridge/config.go:5:6: exported type ClaudeAPIConfig should have comment or be unexported
pkg/llmbridge/config.go:11:6: exported type GPTAPIConfig should have comment or be unexported
pkg/llmbridge/payload.go:7:6: exported type Payload should have comment or be unexported
pkg/llmbridge/payload.go:15:6: exported type Message should have comment or be unexported
pkg/llmbridge/payload.go:20:6: exported type Content should have comment or be unexported
pkg/llmbridge/sentiment.go:169:3: var cfUrl should be cfURL
pkg/llmbridge/sentiment.go:270:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/sentiment.go:354:9: if block ends with a return statement, so drop this else and outdent its block
pkg/masacrypto/keys.go:135:1: exported function Libp2pPubKeyToEthAddress should have comment or be unexported
pkg/network/events.go:7:6: exported type PeerEvent should have comment or be unexported
pkg/network/http_client.go:16:2: exported const GET should have comment (or a comment on this block) or be unexported
pkg/network/http_client.go:38:1: exported function Get should have comment or be unexported
pkg/network/http_client.go:42:1: exported function Post should have comment or be unexported
pkg/network/http_client.go:46:1: exported function Put should have comment or be unexported
pkg/network/http_client.go:50:1: exported function Patch should have comment or be unexported
pkg/network/http_client.go:88:10: if block ends with a return statement, so drop this else and outdent its block
pkg/network/kdht.go:24:2: exported const PeerAdded should have comment (or a comment on this block) or be unexported
pkg/network/kdht.go:33:1: exported function WithDht should have comment or be unexported
pkg/network/kdht.go:33:51: func parameter protocolId should be protocolID
pkg/network/mdns.go:9:7: exported const PeerFound should have comment or be unexported
pkg/network/mdns.go:27:1: exported function WithMDNS should have comment or be unexported
pkg/pubsub/manager.go:22:6: exported type Manager should have comment or be unexported
pkg/pubsub/node_data.go:20:2: exported const ActivityJoined should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_data.go:24:6: exported type JSONMultiaddr should have comment or be unexported
pkg/pubsub/node_data.go:47:6: exported type NodeData should have comment or be unexported
pkg/pubsub/node_data.go:50:2: struct field PeerId should be PeerID
pkg/pubsub/node_data.go:76:44: func parameter peerId should be peerID
pkg/pubsub/node_data.go:108:2: exported const CategoryDiscord should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_event_tracker.go:19:6: exported type NodeEventTracker should have comment or be unexported
pkg/pubsub/node_event_tracker.go:26:6: exported type ConnectBufferEntry should have comment or be unexported
pkg/pubsub/node_event_tracker.go:35:55: func parameter hostId should be hostID
pkg/pubsub/node_event_tracker.go:81:9: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:178:10: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:440:71: method parameter hostId should be hostID
pkg/pubsub/node_event_tracker.go:455:48: method parameter hostId should be hostID
pkg/pubsub/public_key_topic.go:23:6: exported type PublicKeyPublisher should have comment or be unexported
pkg/pubsub/public_key_topic.go:184:1: comment on exported method PublicKeyPublisher.GetPublishedMessages should be of the form "GetPublishedMessages ..."
pkg/pubsub/safe_map.go:11:6: exported type SafeMap should have comment or be unexported
pkg/pubsub/worker_tracker.go:11:6: exported type Workers should have comment or be unexported
pkg/scrapers/discord/exchangetoken.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getchannelmessages.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getguildchannels.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getuserguilds.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/reddit/reddit.go:5:1: exported function TestReddit should have comment or be unexported
pkg/scrapers/telegram/telegram_client.go:30:1: exported function GetClient should have comment or be unexported
pkg/scrapers/twitter/auth.go:41:1: exported function IsLoggedIn should have comment or be unexported
pkg/scrapers/twitter/auth.go:45:1: exported function Logout should have comment or be unexported
pkg/scrapers/twitter/cookies.go:12:1: exported function SaveCookies should have comment or be unexported
pkg/scrapers/twitter/cookies.go:25:1: exported function LoadCookies should have comment or be unexported
pkg/scrapers/twitter/followers.go:7:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:8:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:17:6: exported type TweetResult should have comment or be unexported
pkg/staking/abi.go:13:2: exported const MasaTokenABIPath should have comment (or a comment on this block) or be unexported
pkg/staking/abi.go:18:6: exported type ContractAddresses should have comment or be unexported
pkg/staking/contracts.go:13:5: exported var MasaTokenAddress should have comment or be unexported
pkg/staking/contracts.go:14:5: exported var ProtocolStakingContractAddress should have comment or be unexported
pkg/staking/contracts.go:16:6: exported type Client should have comment or be unexported
pkg/staking/faucet.go:11:1: exported method Client.RunFaucet should have comment or be unexported
pkg/workers/config.go:9:6: exported type WorkerConfig should have comment or be unexported
pkg/workers/config.go:19:5: exported var DefaultConfig should have comment or be unexported
pkg/workers/config.go:39:1: exported function LoadConfig should have comment or be unexported
pkg/workers/response_channel_map.go:9:6: exported type ResponseChannelMap should have comment or be unexported
pkg/workers/response_channel_map.go:64:1: exported method ResponseChannelMap.CreateChannel should have comment or be unexported
pkg/workers/worker_manager.go:27:1: exported function GetWorkHandlerManager should have comment or be unexported
pkg/workers/worker_manager.go:97:1: exported method WorkHandlerManager.DistributeWork should have comment or be unexported
pkg/workers/worker_manager.go:139:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/workers/worker_manager.go:238:1: exported method WorkHandlerManager.HandleWorkerStream should have comment or be unexported
pkg/workers/worker_manager.go:269:2: var peerId should be peerID
pkg/workers/handlers/discord.go:12:6: exported type DiscordProfileHandler should have comment or be unexported
pkg/workers/handlers/discord.go:13:6: exported type DiscordChannelHandler should have comment or be unexported
pkg/workers/handlers/discord.go:14:6: exported type DiscordSentimentHandler should have comment or be unexported
pkg/workers/handlers/discord.go:15:6: exported type DiscordGuildHandler should have comment or be unexported
pkg/workers/handlers/discord.go:16:6: exported type DiscoreUserGuildsHandler should have comment or be unexported
pkg/workers/handlers/discord.go:82:1: exported method DiscoreUserGuildsHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/helper.go:7:1: exported function JsonBytesToMap should have comment or be unexported
pkg/workers/handlers/helper.go:7:6: func JsonBytesToMap should be JSONBytesToMap
pkg/workers/handlers/llm.go:14:1: comment on exported type LLMChatBody should be of the form "LLMChatBody ..." (with optional leading article)
pkg/workers/handlers/llm.go:24:6: exported type LLMChatHandler should have comment or be unexported
pkg/workers/handlers/telegram.go:13:6: exported type TelegramSentimentHandler should have comment or be unexported
pkg/workers/handlers/telegram.go:14:6: exported type TelegramChannelHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:12:6: exported type TwitterQueryHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:13:6: exported type TwitterFollowersHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:14:6: exported type TwitterProfileHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:15:6: exported type TwitterSentimentHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:16:6: exported type TwitterTrendsHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:18:1: exported method TwitterQueryHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:33:1: exported method TwitterFollowersHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:48:1: exported method TwitterProfileHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:62:1: exported method TwitterSentimentHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:78:1: exported method TwitterTrendsHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/web.go:14:6: exported type WebSentimentHandler should have comment or be unexported
pkg/workers/handlers/web.go:16:1: exported method WebHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/web.go:31:1: exported method WebSentimentHandler.HandleWork should have comment or be unexported
pkg/workers/types/request_response.go:1:1: don't use an underscore in package name
pkg/workers/types/request_response.go:10:6: exported type Worker should have comment or be unexported
pkg/workers/types/request_response.go:18:6: exported type WorkRequest should have comment or be unexported
pkg/workers/types/request_response.go:20:2: struct field RequestId should be RequestID
pkg/workers/types/request_response.go:24:6: exported type WorkResponse should have comment or be unexported
pkg/workers/types/request_response.go:28:2: struct field WorkerPeerId should be WorkerPeerID
pkg/workers/types/work_types.go:1:1: don't use an underscore in package name
pkg/workers/types/work_types.go:9:6: exported type WorkerType should have comment or be unexported
pkg/workers/types/work_types.go:12:2: exported const Discord should have comment (or a comment on this block) or be unexported
tests/node_listener.go:28:6: exported type NodeListener should have comment or be unexported
tests/node_listener.go:31:2: struct field ServerId should be ServerID
tests/node_listener.go:36:1: exported function NewNodeListener should have comment or be unexported
tests/node_listener.go:54:1: exported method NodeListener.Start should have comment or be unexported
tools/abigen_helper.go:14:6: exported type Contract should have comment or be unexported
tools/abigen_helper.go:19:1: exported function AbiGen should have comment or be unexported
tools/abigen_helper.go:56:1: exported function AbiGenBindings should have comment or be unexported

Copy link

⚠ goimports failed (.)

pkg/api/handlers_data.go
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/discord"
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/telegram"
 	"github.com/masa-finance/masa-oracle/pkg/workers"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type LLMChat struct {
pkg/db/access_control.go
 
 import (
 	"encoding/hex"
+
 	libp2pCrypto "github.com/libp2p/go-libp2p/core/crypto"
 	"github.com/libp2p/go-libp2p/core/host"
 	"github.com/sirupsen/logrus"
pkg/workers/handlers/discord.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/discord"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type DiscordProfileHandler struct{}
pkg/workers/handlers/llm.go
 
 	"github.com/masa-finance/masa-oracle/pkg/config"
 	"github.com/masa-finance/masa-oracle/pkg/network"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 // TODO: LLMChatBody isn't used anywhere in the codebase. Remove after testing
pkg/workers/handlers/telegram.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/telegram"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type TelegramSentimentHandler struct{}
pkg/workers/handlers/twitter.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/twitter"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type TwitterQueryHandler struct{}
pkg/workers/handlers/web.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/web"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 // WebHandler - All the web handlers implement the WorkHandler interface.
pkg/workers/response_channel_map.go
 import (
 	"sync"
 
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type ResponseChannelMap struct {

Copy link

⚠ gosec failed (.)

2024/08/22 05:56:07 internal error: package "log" without types was imported from "command-line-arguments"
Show Detail
2024/08/22 05:56:07 internal error: package "log" without types was imported from "command-line-arguments"

Code Reference

Copy link

⚠ errcheck failed (.)

error: failed to check packages: errors while loading package github.com/masa-finance/masa-oracle/cmd/masa-node: [-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.]

Copy link

⚠ staticcheck failed (.)

-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping. (compile)
pkg/api/handlers_data.go:92:6: func publishWorkRequest is unused (U1000)
pkg/oracle_node.go:80:6: func getOutboundIP is unused (U1000)
pkg/scrapers/telegram/telegram_client.go:24:2: var once is unused (U1000)
pkg/staking/abi.go:6:2: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details.  (SA1019)
tests/node_listener.go:136:2: this value of err is never used (SA4006)

Checks Document

Copy link

PR description is too short and seems to not fulfill PR template, please fill in

Copy link

⚠ goimports failed (.)

pkg/api/handlers_data.go
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/discord"
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/telegram"
 	"github.com/masa-finance/masa-oracle/pkg/workers"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type LLMChat struct {
pkg/db/access_control.go
 
 import (
 	"encoding/hex"
+
 	libp2pCrypto "github.com/libp2p/go-libp2p/core/crypto"
 	"github.com/libp2p/go-libp2p/core/host"
 	"github.com/sirupsen/logrus"
pkg/workers/handlers/discord.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/discord"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type DiscordProfileHandler struct{}
pkg/workers/handlers/llm.go
 
 	"github.com/masa-finance/masa-oracle/pkg/config"
 	"github.com/masa-finance/masa-oracle/pkg/network"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 // TODO: LLMChatBody isn't used anywhere in the codebase. Remove after testing
pkg/workers/handlers/telegram.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/telegram"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type TelegramSentimentHandler struct{}
pkg/workers/handlers/twitter.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/twitter"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type TwitterQueryHandler struct{}
pkg/workers/handlers/web.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/web"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 // WebHandler - All the web handlers implement the WorkHandler interface.
pkg/workers/response_channel_map.go
 import (
 	"sync"
 
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type ResponseChannelMap struct {

Copy link

⚠ golint failed (.)

Found 191 lint suggestions; failing.

Show Detail
cmd/masa-node-cli/handlers.go:159:10: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/handlers.go:185:9: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/types.go:10:6: exported type AppConfig should have comment or be unexported
cmd/masa-node-cli/types.go:22:6: exported type Gossip should have comment or be unexported
cmd/masa-node-cli/types.go:27:6: exported type SpeakRequest should have comment or be unexported
cmd/masa-node-cli/types.go:35:6: exported type SubscriptionHandler should have comment or be unexported
cmd/masa-node-cli/types.go:41:6: exported type RadioButtons should have comment or be unexported
cmd/masa-node-cli/types.go:48:6: exported type InputBox should have comment or be unexported
cmd/tagger/main.go:23:1: package comment is detached; there should be no blank lines between it and the package statement
cmd/tagger/main.go:100:1: exported function TagProject should have comment or be unexported
internal/versioning/version.go:4:2: exported var ApplicationVersion should have comment or be unexported
internal/versioning/version.go:6:2: comment on exported var ProtocolVersion should be of the form "ProtocolVersion ..."
pkg/oracle_node.go:42:6: exported type OracleNode should have comment or be unexported
pkg/oracle_node.go:336:6: exported type BlockData should have comment or be unexported
pkg/oracle_node.go:344:6: exported type Blocks should have comment or be unexported
pkg/oracle_node.go:348:6: exported type BlockEvents should have comment or be unexported
pkg/oracle_node.go:350:6: exported type BlockEventTracker should have comment or be unexported
pkg/oracle_node.go:463:1: exported function SubscribeToBlocks should have comment or be unexported
pkg/oracle_node_listener.go:77:6: exported type NodeDataPage should have comment or be unexported
pkg/oracle_node_listener.go:208:2: var remotePeerId should be remotePeerID
pkg/api/api.go:12:6: exported type API should have comment or be unexported
pkg/api/config.go:6:6: type name will be used as api.APIConfig by other packages, and that stutters; consider calling this Config
pkg/api/config.go:11:5: exported var DefaultConfig should have comment or be unexported
pkg/api/handlers_data.go:32:6: exported type LLMChat should have comment or be unexported
pkg/api/handlers_data.go:41:1: exported function IsBase64 should have comment or be unexported
pkg/api/handlers_data.go:366:4: struct field Url should be URL
pkg/api/handlers_data.go:826:4: struct field Url should be URL
pkg/api/handlers_data.go:912:1: exported method API.GetChannelMessagesHandler should have comment or be unexported
pkg/api/handlers_data.go:1058:3: var cfUrl should be cfURL
pkg/api/handlers_node.go:435:17: method GetNodeApiKey should be GetNodeAPIKey
pkg/chain/block.go:13:6: exported type Block should have comment or be unexported
pkg/chain/block.go:21:1: exported method Block.Build should have comment or be unexported
pkg/chain/block.go:30:1: exported method Block.Serialize should have comment or be unexported
pkg/chain/block.go:40:1: exported method Block.Deserialize should have comment or be unexported
pkg/chain/block.go:51:1: exported method Block.Print should have comment or be unexported
pkg/chain/chain.go:13:6: exported type Chain should have comment or be unexported
pkg/chain/chain.go:173:1: exported method Chain.GetBlock should have comment or be unexported
pkg/chain/persistance.go:9:2: exported const KeyLastHash should have comment (or a comment on this block) or be unexported
pkg/chain/persistance.go:12:6: exported type Persistance should have comment or be unexported
pkg/chain/persistance.go:16:6: exported type Serializable should have comment or be unexported
pkg/chain/persistance.go:21:1: exported method Persistance.Init should have comment or be unexported
pkg/chain/persistance.go:74:1: exported method Persistance.Get should have comment or be unexported
pkg/chain/persistance.go:96:1: exported method Persistance.GetLastHash should have comment or be unexported
pkg/chain/persistance.go:100:1: exported method Persistance.SaveBlock should have comment or be unexported
pkg/chain/persistance.go:122:1: exported method Persistance.Iterate should have comment or be unexported
pkg/chain/pos.go:16:6: exported type ProofOfStake should have comment or be unexported
pkg/chain/pos.go:44:1: exported method ProofOfStake.Run should have comment or be unexported
pkg/chain/pos.go:68:1: exported function IsValidPoS should have comment or be unexported
pkg/config/app.go:68:2: struct field RpcUrl should be RPCURL
pkg/config/app.go:70:2: struct field AllowedPeerId should be AllowedPeerID
pkg/config/app.go:85:2: struct field ClaudeApiKey should be ClaudeAPIKey
pkg/config/app.go:86:2: struct field ClaudeApiURL should be ClaudeAPIURL
pkg/config/app.go:87:2: struct field ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/app.go:94:2: struct field LLMChatUrl should be LLMChatURL
pkg/config/app.go:95:2: struct field LLMCfUrl should be LLMCfURL
pkg/config/constants.go:81:2: exported const PrivKeyFile should have comment (or a comment on this block) or be unexported
pkg/config/constants.go:84:2: const RpcUrl should be RPCURL
pkg/config/constants.go:116:2: const ClaudeApiKey should be ClaudeAPIKey
pkg/config/constants.go:117:2: const ClaudeApiURL should be ClaudeAPIURL
pkg/config/constants.go:118:2: const ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/constants.go:125:2: const LlmChatUrl should be LlmChatURL
pkg/config/constants.go:126:2: const LlmCfUrl should be LlmCfURL
pkg/config/constants.go:149:1: exported function GetCloudflareModels should have comment or be unexported
pkg/config/welcome.go:7:1: exported function DisplayWelcomeMessage should have comment or be unexported
pkg/consensus/pow.go:20:1: exported function GeneratePoW should have comment or be unexported
pkg/consensus/pow.go:20:18: func parameter peerId should be peerID
pkg/consensus/pow.go:42:1: exported function ComputeProofOfWork should have comment or be unexported
pkg/consensus/pow.go:42:25: func parameter peerId should be peerID
pkg/consensus/signer.go:20:1: exported function GenerateJWTToken should have comment or be unexported
pkg/consensus/signer.go:20:23: func parameter peerId should be peerID
pkg/db/operations.go:17:6: exported type WorkEvent should have comment or be unexported
pkg/db/operations.go:19:2: struct field PeerId should be PeerID
pkg/db/resolver_cache.go:26:6: exported type Record should have comment or be unexported
pkg/db/resolver_cache.go:74:9: if block ends with a return statement, so drop this else and outdent its block
pkg/db/resolver_cache.go:115:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/client.go:18:6: exported type ClaudeClient should have comment or be unexported
pkg/llmbridge/client.go:22:6: exported type GPTClient should have comment or be unexported
pkg/llmbridge/client.go:54:1: exported method GPTClient.SendRequest should have comment or be unexported
pkg/llmbridge/client.go:96:6: exported type Response should have comment or be unexported
pkg/llmbridge/client.go:107:6: exported type ResponseContent should have comment or be unexported
pkg/llmbridge/client.go:113:6: exported type ResponseError should have comment or be unexported
pkg/llmbridge/client.go:118:6: exported type Usage should have comment or be unexported
pkg/llmbridge/config.go:5:6: exported type ClaudeAPIConfig should have comment or be unexported
pkg/llmbridge/config.go:11:6: exported type GPTAPIConfig should have comment or be unexported
pkg/llmbridge/payload.go:7:6: exported type Payload should have comment or be unexported
pkg/llmbridge/payload.go:15:6: exported type Message should have comment or be unexported
pkg/llmbridge/payload.go:20:6: exported type Content should have comment or be unexported
pkg/llmbridge/sentiment.go:169:3: var cfUrl should be cfURL
pkg/llmbridge/sentiment.go:270:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/sentiment.go:354:9: if block ends with a return statement, so drop this else and outdent its block
pkg/masacrypto/keys.go:135:1: exported function Libp2pPubKeyToEthAddress should have comment or be unexported
pkg/network/events.go:7:6: exported type PeerEvent should have comment or be unexported
pkg/network/http_client.go:16:2: exported const GET should have comment (or a comment on this block) or be unexported
pkg/network/http_client.go:38:1: exported function Get should have comment or be unexported
pkg/network/http_client.go:42:1: exported function Post should have comment or be unexported
pkg/network/http_client.go:46:1: exported function Put should have comment or be unexported
pkg/network/http_client.go:50:1: exported function Patch should have comment or be unexported
pkg/network/http_client.go:88:10: if block ends with a return statement, so drop this else and outdent its block
pkg/network/kdht.go:24:2: exported const PeerAdded should have comment (or a comment on this block) or be unexported
pkg/network/kdht.go:33:1: exported function WithDht should have comment or be unexported
pkg/network/kdht.go:33:51: func parameter protocolId should be protocolID
pkg/network/mdns.go:9:7: exported const PeerFound should have comment or be unexported
pkg/network/mdns.go:27:1: exported function WithMDNS should have comment or be unexported
pkg/pubsub/manager.go:22:6: exported type Manager should have comment or be unexported
pkg/pubsub/node_data.go:20:2: exported const ActivityJoined should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_data.go:24:6: exported type JSONMultiaddr should have comment or be unexported
pkg/pubsub/node_data.go:47:6: exported type NodeData should have comment or be unexported
pkg/pubsub/node_data.go:50:2: struct field PeerId should be PeerID
pkg/pubsub/node_data.go:76:44: func parameter peerId should be peerID
pkg/pubsub/node_data.go:108:2: exported const CategoryDiscord should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_event_tracker.go:19:6: exported type NodeEventTracker should have comment or be unexported
pkg/pubsub/node_event_tracker.go:26:6: exported type ConnectBufferEntry should have comment or be unexported
pkg/pubsub/node_event_tracker.go:35:55: func parameter hostId should be hostID
pkg/pubsub/node_event_tracker.go:81:9: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:178:10: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:440:71: method parameter hostId should be hostID
pkg/pubsub/node_event_tracker.go:455:48: method parameter hostId should be hostID
pkg/pubsub/public_key_topic.go:23:6: exported type PublicKeyPublisher should have comment or be unexported
pkg/pubsub/public_key_topic.go:184:1: comment on exported method PublicKeyPublisher.GetPublishedMessages should be of the form "GetPublishedMessages ..."
pkg/pubsub/safe_map.go:11:6: exported type SafeMap should have comment or be unexported
pkg/pubsub/worker_tracker.go:11:6: exported type Workers should have comment or be unexported
pkg/scrapers/discord/exchangetoken.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getchannelmessages.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getguildchannels.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getuserguilds.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/reddit/reddit.go:5:1: exported function TestReddit should have comment or be unexported
pkg/scrapers/telegram/telegram_client.go:30:1: exported function GetClient should have comment or be unexported
pkg/scrapers/twitter/auth.go:41:1: exported function IsLoggedIn should have comment or be unexported
pkg/scrapers/twitter/auth.go:45:1: exported function Logout should have comment or be unexported
pkg/scrapers/twitter/cookies.go:12:1: exported function SaveCookies should have comment or be unexported
pkg/scrapers/twitter/cookies.go:25:1: exported function LoadCookies should have comment or be unexported
pkg/scrapers/twitter/followers.go:7:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:8:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:17:6: exported type TweetResult should have comment or be unexported
pkg/staking/abi.go:13:2: exported const MasaTokenABIPath should have comment (or a comment on this block) or be unexported
pkg/staking/abi.go:18:6: exported type ContractAddresses should have comment or be unexported
pkg/staking/contracts.go:13:5: exported var MasaTokenAddress should have comment or be unexported
pkg/staking/contracts.go:14:5: exported var ProtocolStakingContractAddress should have comment or be unexported
pkg/staking/contracts.go:16:6: exported type Client should have comment or be unexported
pkg/staking/faucet.go:11:1: exported method Client.RunFaucet should have comment or be unexported
pkg/workers/config.go:9:6: exported type WorkerConfig should have comment or be unexported
pkg/workers/config.go:19:5: exported var DefaultConfig should have comment or be unexported
pkg/workers/config.go:39:1: exported function LoadConfig should have comment or be unexported
pkg/workers/response_channel_map.go:9:6: exported type ResponseChannelMap should have comment or be unexported
pkg/workers/response_channel_map.go:64:1: exported method ResponseChannelMap.CreateChannel should have comment or be unexported
pkg/workers/worker_manager.go:27:1: exported function GetWorkHandlerManager should have comment or be unexported
pkg/workers/worker_manager.go:97:1: exported method WorkHandlerManager.DistributeWork should have comment or be unexported
pkg/workers/worker_manager.go:139:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/workers/worker_manager.go:238:1: exported method WorkHandlerManager.HandleWorkerStream should have comment or be unexported
pkg/workers/worker_manager.go:269:2: var peerId should be peerID
pkg/workers/handlers/discord.go:12:6: exported type DiscordProfileHandler should have comment or be unexported
pkg/workers/handlers/discord.go:13:6: exported type DiscordChannelHandler should have comment or be unexported
pkg/workers/handlers/discord.go:14:6: exported type DiscordSentimentHandler should have comment or be unexported
pkg/workers/handlers/discord.go:15:6: exported type DiscordGuildHandler should have comment or be unexported
pkg/workers/handlers/discord.go:16:6: exported type DiscoreUserGuildsHandler should have comment or be unexported
pkg/workers/handlers/discord.go:82:1: exported method DiscoreUserGuildsHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/helper.go:7:1: exported function JsonBytesToMap should have comment or be unexported
pkg/workers/handlers/helper.go:7:6: func JsonBytesToMap should be JSONBytesToMap
pkg/workers/handlers/llm.go:14:1: comment on exported type LLMChatBody should be of the form "LLMChatBody ..." (with optional leading article)
pkg/workers/handlers/llm.go:24:6: exported type LLMChatHandler should have comment or be unexported
pkg/workers/handlers/telegram.go:13:6: exported type TelegramSentimentHandler should have comment or be unexported
pkg/workers/handlers/telegram.go:14:6: exported type TelegramChannelHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:12:6: exported type TwitterQueryHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:13:6: exported type TwitterFollowersHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:14:6: exported type TwitterProfileHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:15:6: exported type TwitterSentimentHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:16:6: exported type TwitterTrendsHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:18:1: exported method TwitterQueryHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:33:1: exported method TwitterFollowersHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:48:1: exported method TwitterProfileHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:62:1: exported method TwitterSentimentHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:78:1: exported method TwitterTrendsHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/web.go:14:6: exported type WebSentimentHandler should have comment or be unexported
pkg/workers/handlers/web.go:16:1: exported method WebHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/web.go:31:1: exported method WebSentimentHandler.HandleWork should have comment or be unexported
pkg/workers/types/request_response.go:1:1: don't use an underscore in package name
pkg/workers/types/request_response.go:10:6: exported type Worker should have comment or be unexported
pkg/workers/types/request_response.go:18:6: exported type WorkRequest should have comment or be unexported
pkg/workers/types/request_response.go:20:2: struct field RequestId should be RequestID
pkg/workers/types/request_response.go:24:6: exported type WorkResponse should have comment or be unexported
pkg/workers/types/request_response.go:28:2: struct field WorkerPeerId should be WorkerPeerID
pkg/workers/types/work_types.go:1:1: don't use an underscore in package name
pkg/workers/types/work_types.go:9:6: exported type WorkerType should have comment or be unexported
pkg/workers/types/work_types.go:12:2: exported const Discord should have comment (or a comment on this block) or be unexported
tests/node_listener.go:28:6: exported type NodeListener should have comment or be unexported
tests/node_listener.go:31:2: struct field ServerId should be ServerID
tests/node_listener.go:36:1: exported function NewNodeListener should have comment or be unexported
tests/node_listener.go:54:1: exported method NodeListener.Start should have comment or be unexported
tools/abigen_helper.go:14:6: exported type Contract should have comment or be unexported
tools/abigen_helper.go:19:1: exported function AbiGen should have comment or be unexported
tools/abigen_helper.go:56:1: exported function AbiGenBindings should have comment or be unexported

Copy link

⚠ errcheck failed (.)

error: failed to check packages: errors while loading package github.com/masa-finance/masa-oracle/cmd/masa-node: [-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.]

Copy link

⚠ shadow failed (.)

# github.com/masa-finance/masa-oracle/pkg/chain
pkg/chain/persistance.go:35:9: declaration of "err" shadows declaration at line 24
pkg/chain/persistance.go:41:17: declaration of "err" shadows declaration at line 35
# github.com/masa-finance/masa-oracle/pkg/pubsub
pkg/pubsub/public_key_topic.go:62:16: declaration of "err" shadows declaration at line 50
# github.com/masa-finance/masa-oracle/pkg/network
pkg/network/address.go:187:3: declaration of "err" shadows declaration at line 173
pkg/network/discover.go:70:5: declaration of "err" shadows declaration at line 63
pkg/network/http_client.go:93:3: declaration of "err" shadows declaration at line 56
pkg/network/kdht.go:125:6: declaration of "err" shadows declaration at line 114
# github.com/masa-finance/masa-oracle/cmd/tagger
# [github.com/masa-finance/masa-oracle/cmd/tagger]
cmd/tagger/main.go:102:8: declaration of "err" shadows declaration at line 100
# github.com/masa-finance/masa-oracle/pkg/masacrypto
# [github.com/masa-finance/masa-oracle/pkg/masacrypto]
pkg/masacrypto/cert.go:61:5: declaration of "err" shadows declaration at line 23
pkg/masacrypto/cert_test.go:20:8: declaration of "err" shadows declaration at line 14
pkg/masacrypto/cert_test.go:25:8: declaration of "err" shadows declaration at line 14
# github.com/masa-finance/masa-oracle/tools
# [github.com/masa-finance/masa-oracle/tools]
tools/abigen_helper.go:34:5: declaration of "err" shadows declaration at line 27
tools/abigen_helper.go:76:5: declaration of "err" shadows declaration at line 70
# github.com/masa-finance/masa-oracle/pkg/scrapers/discord
pkg/scrapers/discord/getguildchannels.go:44:14: declaration of "err" shadows declaration at line 28
# github.com/masa-finance/masa-oracle/pkg/scrapers/telegram
pkg/scrapers/telegram/getchannelmessages.go:25:13: declaration of "err" shadows declaration at line 16
pkg/scrapers/telegram/telegram_client.go:84:13: declaration of "err" shadows declaration at line 73
pkg/scrapers/telegram/telegram_client.go:131:9: declaration of "err" shadows declaration at line 120
# github.com/masa-finance/masa-oracle/pkg/workers
pkg/workers/worker_manager.go:148:4: declaration of "err" shadows declaration at line 141
# github.com/masa-finance/masa-oracle/pkg/api
pkg/api/handlers_data.go:630:6: declaration of "err" shadows declaration at line 608
pkg/api/handlers_data.go:643:8: declaration of "err" shadows declaration at line 608
pkg/api/handlers_data.go:1079:4: declaration of "err" shadows declaration at line 1052
# github.com/masa-finance/masa-oracle/cmd/masa-node
# [github.com/masa-finance/masa-oracle/cmd/masa-node]
cmd/masa-node/main.go:121:3: declaration of "cfg" shadows declaration at line 31
cmd/masa-node/main.go:123:7: declaration of "err" shadows declaration at line 62

Copy link

⚠ gosec failed (.)

2024/08/22 06:48:21 internal error: package "context" without types was imported from "command-line-arguments"
Show Detail
2024/08/22 06:48:21 internal error: package "context" without types was imported from "command-line-arguments"

Code Reference

Copy link

⚠ shadow failed (.)

# github.com/masa-finance/masa-oracle/pkg/chain
pkg/chain/persistance.go:35:9: declaration of "err" shadows declaration at line 24
pkg/chain/persistance.go:41:17: declaration of "err" shadows declaration at line 35
# github.com/masa-finance/masa-oracle/pkg/pubsub
pkg/pubsub/public_key_topic.go:62:16: declaration of "err" shadows declaration at line 50
# github.com/masa-finance/masa-oracle/pkg/network
pkg/network/address.go:187:3: declaration of "err" shadows declaration at line 173
pkg/network/discover.go:70:5: declaration of "err" shadows declaration at line 63
pkg/network/http_client.go:93:3: declaration of "err" shadows declaration at line 56
pkg/network/kdht.go:125:6: declaration of "err" shadows declaration at line 114
# github.com/masa-finance/masa-oracle/cmd/tagger
# [github.com/masa-finance/masa-oracle/cmd/tagger]
cmd/tagger/main.go:102:8: declaration of "err" shadows declaration at line 100
# github.com/masa-finance/masa-oracle/pkg/masacrypto
# [github.com/masa-finance/masa-oracle/pkg/masacrypto]
pkg/masacrypto/cert.go:61:5: declaration of "err" shadows declaration at line 23
pkg/masacrypto/cert_test.go:20:8: declaration of "err" shadows declaration at line 14
pkg/masacrypto/cert_test.go:25:8: declaration of "err" shadows declaration at line 14
# github.com/masa-finance/masa-oracle/tools
# [github.com/masa-finance/masa-oracle/tools]
tools/abigen_helper.go:34:5: declaration of "err" shadows declaration at line 27
tools/abigen_helper.go:76:5: declaration of "err" shadows declaration at line 70
# github.com/masa-finance/masa-oracle/pkg/scrapers/discord
pkg/scrapers/discord/getguildchannels.go:44:14: declaration of "err" shadows declaration at line 28
# github.com/masa-finance/masa-oracle/pkg/scrapers/telegram
pkg/scrapers/telegram/getchannelmessages.go:25:13: declaration of "err" shadows declaration at line 16
pkg/scrapers/telegram/telegram_client.go:84:13: declaration of "err" shadows declaration at line 73
pkg/scrapers/telegram/telegram_client.go:131:9: declaration of "err" shadows declaration at line 120
# github.com/masa-finance/masa-oracle/pkg/workers
pkg/workers/worker_manager.go:148:4: declaration of "err" shadows declaration at line 141
# github.com/masa-finance/masa-oracle/pkg/api
pkg/api/handlers_data.go:630:6: declaration of "err" shadows declaration at line 608
pkg/api/handlers_data.go:643:8: declaration of "err" shadows declaration at line 608
pkg/api/handlers_data.go:1079:4: declaration of "err" shadows declaration at line 1052
# github.com/masa-finance/masa-oracle/cmd/masa-node
# [github.com/masa-finance/masa-oracle/cmd/masa-node]
cmd/masa-node/main.go:121:3: declaration of "cfg" shadows declaration at line 31
cmd/masa-node/main.go:123:7: declaration of "err" shadows declaration at line 62

Copy link

⚠ staticcheck failed (.)

-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping. (compile)
pkg/api/handlers_data.go:92:6: func publishWorkRequest is unused (U1000)
pkg/oracle_node.go:80:6: func getOutboundIP is unused (U1000)
pkg/scrapers/telegram/telegram_client.go:24:2: var once is unused (U1000)
pkg/staking/abi.go:6:2: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details.  (SA1019)
tests/node_listener.go:136:2: this value of err is never used (SA4006)

Checks Document

Replaced the multiaddress-based peer information retrieval with a DHT lookup to simplify the process. Removed unnecessary imports and optimized the code for finding and connecting to peers in the Distributed Hash Table (DHT).
Copy link

PR description is too short and seems to not fulfill PR template, please fill in

Copy link

⚠ golint failed (.)

Found 193 lint suggestions; failing.

Show Detail
cmd/masa-node-cli/handlers.go:159:10: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/handlers.go:185:9: if block ends with a return statement, so drop this else and outdent its block
cmd/masa-node-cli/types.go:10:6: exported type AppConfig should have comment or be unexported
cmd/masa-node-cli/types.go:22:6: exported type Gossip should have comment or be unexported
cmd/masa-node-cli/types.go:27:6: exported type SpeakRequest should have comment or be unexported
cmd/masa-node-cli/types.go:35:6: exported type SubscriptionHandler should have comment or be unexported
cmd/masa-node-cli/types.go:41:6: exported type RadioButtons should have comment or be unexported
cmd/masa-node-cli/types.go:48:6: exported type InputBox should have comment or be unexported
cmd/tagger/main.go:23:1: package comment is detached; there should be no blank lines between it and the package statement
cmd/tagger/main.go:100:1: exported function TagProject should have comment or be unexported
internal/versioning/version.go:4:2: exported var ApplicationVersion should have comment or be unexported
internal/versioning/version.go:6:2: comment on exported var ProtocolVersion should be of the form "ProtocolVersion ..."
pkg/oracle_node.go:42:6: exported type OracleNode should have comment or be unexported
pkg/oracle_node.go:332:6: exported type BlockData should have comment or be unexported
pkg/oracle_node.go:340:6: exported type Blocks should have comment or be unexported
pkg/oracle_node.go:344:6: exported type BlockEvents should have comment or be unexported
pkg/oracle_node.go:346:6: exported type BlockEventTracker should have comment or be unexported
pkg/oracle_node.go:459:1: exported function SubscribeToBlocks should have comment or be unexported
pkg/oracle_node_listener.go:77:6: exported type NodeDataPage should have comment or be unexported
pkg/oracle_node_listener.go:208:2: var remotePeerId should be remotePeerID
pkg/api/api.go:12:6: exported type API should have comment or be unexported
pkg/api/config.go:6:6: type name will be used as api.APIConfig by other packages, and that stutters; consider calling this Config
pkg/api/config.go:11:5: exported var DefaultConfig should have comment or be unexported
pkg/api/handlers_data.go:32:6: exported type LLMChat should have comment or be unexported
pkg/api/handlers_data.go:41:1: exported function IsBase64 should have comment or be unexported
pkg/api/handlers_data.go:366:4: struct field Url should be URL
pkg/api/handlers_data.go:826:4: struct field Url should be URL
pkg/api/handlers_data.go:912:1: exported method API.GetChannelMessagesHandler should have comment or be unexported
pkg/api/handlers_data.go:1058:3: var cfUrl should be cfURL
pkg/api/handlers_node.go:435:17: method GetNodeApiKey should be GetNodeAPIKey
pkg/chain/block.go:13:6: exported type Block should have comment or be unexported
pkg/chain/block.go:21:1: exported method Block.Build should have comment or be unexported
pkg/chain/block.go:30:1: exported method Block.Serialize should have comment or be unexported
pkg/chain/block.go:40:1: exported method Block.Deserialize should have comment or be unexported
pkg/chain/block.go:51:1: exported method Block.Print should have comment or be unexported
pkg/chain/chain.go:13:6: exported type Chain should have comment or be unexported
pkg/chain/chain.go:173:1: exported method Chain.GetBlock should have comment or be unexported
pkg/chain/persistance.go:9:2: exported const KeyLastHash should have comment (or a comment on this block) or be unexported
pkg/chain/persistance.go:12:6: exported type Persistance should have comment or be unexported
pkg/chain/persistance.go:16:6: exported type Serializable should have comment or be unexported
pkg/chain/persistance.go:21:1: exported method Persistance.Init should have comment or be unexported
pkg/chain/persistance.go:74:1: exported method Persistance.Get should have comment or be unexported
pkg/chain/persistance.go:96:1: exported method Persistance.GetLastHash should have comment or be unexported
pkg/chain/persistance.go:100:1: exported method Persistance.SaveBlock should have comment or be unexported
pkg/chain/persistance.go:122:1: exported method Persistance.Iterate should have comment or be unexported
pkg/chain/pos.go:16:6: exported type ProofOfStake should have comment or be unexported
pkg/chain/pos.go:44:1: exported method ProofOfStake.Run should have comment or be unexported
pkg/chain/pos.go:68:1: exported function IsValidPoS should have comment or be unexported
pkg/config/app.go:68:2: struct field RpcUrl should be RPCURL
pkg/config/app.go:70:2: struct field AllowedPeerId should be AllowedPeerID
pkg/config/app.go:85:2: struct field ClaudeApiKey should be ClaudeAPIKey
pkg/config/app.go:86:2: struct field ClaudeApiURL should be ClaudeAPIURL
pkg/config/app.go:87:2: struct field ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/app.go:94:2: struct field LLMChatUrl should be LLMChatURL
pkg/config/app.go:95:2: struct field LLMCfUrl should be LLMCfURL
pkg/config/constants.go:81:2: exported const PrivKeyFile should have comment (or a comment on this block) or be unexported
pkg/config/constants.go:84:2: const RpcUrl should be RPCURL
pkg/config/constants.go:116:2: const ClaudeApiKey should be ClaudeAPIKey
pkg/config/constants.go:117:2: const ClaudeApiURL should be ClaudeAPIURL
pkg/config/constants.go:118:2: const ClaudeApiVersion should be ClaudeAPIVersion
pkg/config/constants.go:125:2: const LlmChatUrl should be LlmChatURL
pkg/config/constants.go:126:2: const LlmCfUrl should be LlmCfURL
pkg/config/constants.go:149:1: exported function GetCloudflareModels should have comment or be unexported
pkg/config/welcome.go:7:1: exported function DisplayWelcomeMessage should have comment or be unexported
pkg/consensus/pow.go:20:1: exported function GeneratePoW should have comment or be unexported
pkg/consensus/pow.go:20:18: func parameter peerId should be peerID
pkg/consensus/pow.go:42:1: exported function ComputeProofOfWork should have comment or be unexported
pkg/consensus/pow.go:42:25: func parameter peerId should be peerID
pkg/consensus/signer.go:20:1: exported function GenerateJWTToken should have comment or be unexported
pkg/consensus/signer.go:20:23: func parameter peerId should be peerID
pkg/db/operations.go:17:6: exported type WorkEvent should have comment or be unexported
pkg/db/operations.go:19:2: struct field PeerId should be PeerID
pkg/db/resolver_cache.go:26:6: exported type Record should have comment or be unexported
pkg/db/resolver_cache.go:74:9: if block ends with a return statement, so drop this else and outdent its block
pkg/db/resolver_cache.go:115:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/client.go:18:6: exported type ClaudeClient should have comment or be unexported
pkg/llmbridge/client.go:22:6: exported type GPTClient should have comment or be unexported
pkg/llmbridge/client.go:54:1: exported method GPTClient.SendRequest should have comment or be unexported
pkg/llmbridge/client.go:96:6: exported type Response should have comment or be unexported
pkg/llmbridge/client.go:107:6: exported type ResponseContent should have comment or be unexported
pkg/llmbridge/client.go:113:6: exported type ResponseError should have comment or be unexported
pkg/llmbridge/client.go:118:6: exported type Usage should have comment or be unexported
pkg/llmbridge/config.go:5:6: exported type ClaudeAPIConfig should have comment or be unexported
pkg/llmbridge/config.go:11:6: exported type GPTAPIConfig should have comment or be unexported
pkg/llmbridge/payload.go:7:6: exported type Payload should have comment or be unexported
pkg/llmbridge/payload.go:15:6: exported type Message should have comment or be unexported
pkg/llmbridge/payload.go:20:6: exported type Content should have comment or be unexported
pkg/llmbridge/sentiment.go:169:3: var cfUrl should be cfURL
pkg/llmbridge/sentiment.go:270:9: if block ends with a return statement, so drop this else and outdent its block
pkg/llmbridge/sentiment.go:354:9: if block ends with a return statement, so drop this else and outdent its block
pkg/masacrypto/keys.go:135:1: exported function Libp2pPubKeyToEthAddress should have comment or be unexported
pkg/network/events.go:7:6: exported type PeerEvent should have comment or be unexported
pkg/network/http_client.go:16:2: exported const GET should have comment (or a comment on this block) or be unexported
pkg/network/http_client.go:38:1: exported function Get should have comment or be unexported
pkg/network/http_client.go:42:1: exported function Post should have comment or be unexported
pkg/network/http_client.go:46:1: exported function Put should have comment or be unexported
pkg/network/http_client.go:50:1: exported function Patch should have comment or be unexported
pkg/network/http_client.go:88:10: if block ends with a return statement, so drop this else and outdent its block
pkg/network/kdht.go:24:2: exported const PeerAdded should have comment (or a comment on this block) or be unexported
pkg/network/kdht.go:33:1: exported function WithDht should have comment or be unexported
pkg/network/kdht.go:33:51: func parameter protocolId should be protocolID
pkg/network/mdns.go:9:7: exported const PeerFound should have comment or be unexported
pkg/network/mdns.go:27:1: exported function WithMDNS should have comment or be unexported
pkg/pubsub/manager.go:22:6: exported type Manager should have comment or be unexported
pkg/pubsub/node_data.go:20:2: exported const ActivityJoined should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_data.go:24:6: exported type JSONMultiaddr should have comment or be unexported
pkg/pubsub/node_data.go:47:6: exported type NodeData should have comment or be unexported
pkg/pubsub/node_data.go:50:2: struct field PeerId should be PeerID
pkg/pubsub/node_data.go:76:44: func parameter peerId should be peerID
pkg/pubsub/node_data.go:108:2: exported const CategoryDiscord should have comment (or a comment on this block) or be unexported
pkg/pubsub/node_data.go:273:1: exported method NodeData.MergeMultiaddresses should have comment or be unexported
pkg/pubsub/node_event_tracker.go:19:6: exported type NodeEventTracker should have comment or be unexported
pkg/pubsub/node_event_tracker.go:26:6: exported type ConnectBufferEntry should have comment or be unexported
pkg/pubsub/node_event_tracker.go:35:55: func parameter hostId should be hostID
pkg/pubsub/node_event_tracker.go:81:9: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:178:10: if block ends with a return statement, so drop this else and outdent its block
pkg/pubsub/node_event_tracker.go:440:71: method parameter hostId should be hostID
pkg/pubsub/node_event_tracker.go:455:48: method parameter hostId should be hostID
pkg/pubsub/public_key_topic.go:23:6: exported type PublicKeyPublisher should have comment or be unexported
pkg/pubsub/public_key_topic.go:184:1: comment on exported method PublicKeyPublisher.GetPublishedMessages should be of the form "GetPublishedMessages ..."
pkg/pubsub/safe_map.go:11:6: exported type SafeMap should have comment or be unexported
pkg/pubsub/worker_tracker.go:11:6: exported type Workers should have comment or be unexported
pkg/scrapers/discord/exchangetoken.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getchannelmessages.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getguildchannels.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/discord/getuserguilds.go:1:1: package comment should be of the form "Package discord ..."
pkg/scrapers/reddit/reddit.go:5:1: exported function TestReddit should have comment or be unexported
pkg/scrapers/telegram/telegram_client.go:30:1: exported function GetClient should have comment or be unexported
pkg/scrapers/twitter/auth.go:41:1: exported function IsLoggedIn should have comment or be unexported
pkg/scrapers/twitter/auth.go:45:1: exported function Logout should have comment or be unexported
pkg/scrapers/twitter/cookies.go:12:1: exported function SaveCookies should have comment or be unexported
pkg/scrapers/twitter/cookies.go:25:1: exported function LoadCookies should have comment or be unexported
pkg/scrapers/twitter/followers.go:7:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:8:2: a blank import should be only in a main or test package, or have a comment justifying it
pkg/scrapers/twitter/tweets.go:17:6: exported type TweetResult should have comment or be unexported
pkg/staking/abi.go:13:2: exported const MasaTokenABIPath should have comment (or a comment on this block) or be unexported
pkg/staking/abi.go:18:6: exported type ContractAddresses should have comment or be unexported
pkg/staking/contracts.go:13:5: exported var MasaTokenAddress should have comment or be unexported
pkg/staking/contracts.go:14:5: exported var ProtocolStakingContractAddress should have comment or be unexported
pkg/staking/contracts.go:16:6: exported type Client should have comment or be unexported
pkg/staking/faucet.go:11:1: exported method Client.RunFaucet should have comment or be unexported
pkg/workers/config.go:9:6: exported type WorkerConfig should have comment or be unexported
pkg/workers/config.go:19:5: exported var DefaultConfig should have comment or be unexported
pkg/workers/config.go:39:1: exported function LoadConfig should have comment or be unexported
pkg/workers/response_channel_map.go:9:6: exported type ResponseChannelMap should have comment or be unexported
pkg/workers/response_channel_map.go:64:1: exported method ResponseChannelMap.CreateChannel should have comment or be unexported
pkg/workers/worker_manager.go:27:1: exported function GetWorkHandlerManager should have comment or be unexported
pkg/workers/worker_manager.go:97:1: exported method WorkHandlerManager.DistributeWork should have comment or be unexported
pkg/workers/worker_manager.go:139:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
pkg/workers/worker_manager.go:238:1: exported method WorkHandlerManager.HandleWorkerStream should have comment or be unexported
pkg/workers/worker_manager.go:269:2: var peerId should be peerID
pkg/workers/handlers/discord.go:12:6: exported type DiscordProfileHandler should have comment or be unexported
pkg/workers/handlers/discord.go:13:6: exported type DiscordChannelHandler should have comment or be unexported
pkg/workers/handlers/discord.go:14:6: exported type DiscordSentimentHandler should have comment or be unexported
pkg/workers/handlers/discord.go:15:6: exported type DiscordGuildHandler should have comment or be unexported
pkg/workers/handlers/discord.go:16:6: exported type DiscoreUserGuildsHandler should have comment or be unexported
pkg/workers/handlers/discord.go:82:1: exported method DiscoreUserGuildsHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/helper.go:7:1: exported function JsonBytesToMap should have comment or be unexported
pkg/workers/handlers/helper.go:7:6: func JsonBytesToMap should be JSONBytesToMap
pkg/workers/handlers/llm.go:14:1: comment on exported type LLMChatBody should be of the form "LLMChatBody ..." (with optional leading article)
pkg/workers/handlers/llm.go:24:6: exported type LLMChatHandler should have comment or be unexported
pkg/workers/handlers/telegram.go:13:6: exported type TelegramSentimentHandler should have comment or be unexported
pkg/workers/handlers/telegram.go:14:6: exported type TelegramChannelHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:12:6: exported type TwitterQueryHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:13:6: exported type TwitterFollowersHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:14:6: exported type TwitterProfileHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:15:6: exported type TwitterSentimentHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:16:6: exported type TwitterTrendsHandler should have comment or be unexported
pkg/workers/handlers/twitter.go:18:1: exported method TwitterQueryHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:33:1: exported method TwitterFollowersHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:48:1: exported method TwitterProfileHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:62:1: exported method TwitterSentimentHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/twitter.go:78:1: exported method TwitterTrendsHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/web.go:14:6: exported type WebSentimentHandler should have comment or be unexported
pkg/workers/handlers/web.go:16:1: exported method WebHandler.HandleWork should have comment or be unexported
pkg/workers/handlers/web.go:31:1: exported method WebSentimentHandler.HandleWork should have comment or be unexported
pkg/workers/types/request_response.go:1:1: don't use an underscore in package name
pkg/workers/types/request_response.go:12:6: exported type Worker should have comment or be unexported
pkg/workers/types/request_response.go:20:1: exported function NewWorker should have comment or be unexported
pkg/workers/types/request_response.go:45:6: exported type WorkRequest should have comment or be unexported
pkg/workers/types/request_response.go:47:2: struct field RequestId should be RequestID
pkg/workers/types/request_response.go:51:6: exported type WorkResponse should have comment or be unexported
pkg/workers/types/request_response.go:55:2: struct field WorkerPeerId should be WorkerPeerID
pkg/workers/types/work_types.go:1:1: don't use an underscore in package name
pkg/workers/types/work_types.go:9:6: exported type WorkerType should have comment or be unexported
pkg/workers/types/work_types.go:12:2: exported const Discord should have comment (or a comment on this block) or be unexported
tests/node_listener.go:28:6: exported type NodeListener should have comment or be unexported
tests/node_listener.go:31:2: struct field ServerId should be ServerID
tests/node_listener.go:36:1: exported function NewNodeListener should have comment or be unexported
tests/node_listener.go:54:1: exported method NodeListener.Start should have comment or be unexported
tools/abigen_helper.go:14:6: exported type Contract should have comment or be unexported
tools/abigen_helper.go:19:1: exported function AbiGen should have comment or be unexported
tools/abigen_helper.go:56:1: exported function AbiGenBindings should have comment or be unexported

Copy link

⚠ goimports failed (.)

pkg/api/handlers_data.go
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/discord"
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/telegram"
 	"github.com/masa-finance/masa-oracle/pkg/workers"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type LLMChat struct {
pkg/db/access_control.go
 
 import (
 	"encoding/hex"
+
 	libp2pCrypto "github.com/libp2p/go-libp2p/core/crypto"
 	"github.com/libp2p/go-libp2p/core/host"
 	"github.com/sirupsen/logrus"
pkg/workers/handlers/discord.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/discord"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type DiscordProfileHandler struct{}
pkg/workers/handlers/llm.go
 
 	"github.com/masa-finance/masa-oracle/pkg/config"
 	"github.com/masa-finance/masa-oracle/pkg/network"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 // TODO: LLMChatBody isn't used anywhere in the codebase. Remove after testing
pkg/workers/handlers/telegram.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/telegram"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type TelegramSentimentHandler struct{}
pkg/workers/handlers/twitter.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/twitter"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type TwitterQueryHandler struct{}
pkg/workers/handlers/web.go
 	"github.com/sirupsen/logrus"
 
 	"github.com/masa-finance/masa-oracle/pkg/scrapers/web"
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 // WebHandler - All the web handlers implement the WorkHandler interface.
pkg/workers/response_channel_map.go
 import (
 	"sync"
 
-	"github.com/masa-finance/masa-oracle/pkg/workers/types"
+	data_types "github.com/masa-finance/masa-oracle/pkg/workers/types"
 )
 
 type ResponseChannelMap struct {

Copy link

⚠ gosec failed (.)

2024/08/23 11:52:12 internal error: package "log" without types was imported from "command-line-arguments"
Show Detail
2024/08/23 11:52:12 internal error: package "log" without types was imported from "command-line-arguments"

Code Reference

Copy link

⚠ errcheck failed (.)

error: failed to check packages: errors while loading package github.com/masa-finance/masa-oracle/cmd/masa-node: [-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.]

Copy link

⚠ shadow failed (.)

# github.com/masa-finance/masa-oracle/pkg/chain
pkg/chain/persistance.go:35:9: declaration of "err" shadows declaration at line 24
pkg/chain/persistance.go:41:17: declaration of "err" shadows declaration at line 35
# github.com/masa-finance/masa-oracle/pkg/pubsub
pkg/pubsub/public_key_topic.go:62:16: declaration of "err" shadows declaration at line 50
# github.com/masa-finance/masa-oracle/pkg/network
pkg/network/address.go:187:3: declaration of "err" shadows declaration at line 173
pkg/network/discover.go:70:5: declaration of "err" shadows declaration at line 63
pkg/network/http_client.go:93:3: declaration of "err" shadows declaration at line 56
pkg/network/kdht.go:125:6: declaration of "err" shadows declaration at line 114
# github.com/masa-finance/masa-oracle/cmd/tagger
# [github.com/masa-finance/masa-oracle/cmd/tagger]
cmd/tagger/main.go:102:8: declaration of "err" shadows declaration at line 100
# github.com/masa-finance/masa-oracle/pkg/masacrypto
# [github.com/masa-finance/masa-oracle/pkg/masacrypto]
pkg/masacrypto/cert.go:61:5: declaration of "err" shadows declaration at line 23
pkg/masacrypto/cert_test.go:20:8: declaration of "err" shadows declaration at line 14
pkg/masacrypto/cert_test.go:25:8: declaration of "err" shadows declaration at line 14
# github.com/masa-finance/masa-oracle/tools
# [github.com/masa-finance/masa-oracle/tools]
tools/abigen_helper.go:34:5: declaration of "err" shadows declaration at line 27
tools/abigen_helper.go:76:5: declaration of "err" shadows declaration at line 70
# github.com/masa-finance/masa-oracle/pkg/scrapers/discord
pkg/scrapers/discord/getguildchannels.go:44:14: declaration of "err" shadows declaration at line 28
# github.com/masa-finance/masa-oracle/pkg/scrapers/telegram
pkg/scrapers/telegram/getchannelmessages.go:25:13: declaration of "err" shadows declaration at line 16
pkg/scrapers/telegram/telegram_client.go:84:13: declaration of "err" shadows declaration at line 73
pkg/scrapers/telegram/telegram_client.go:131:9: declaration of "err" shadows declaration at line 120
# github.com/masa-finance/masa-oracle/pkg/workers
pkg/workers/worker_manager.go:148:4: declaration of "err" shadows declaration at line 141
# github.com/masa-finance/masa-oracle/pkg/api
pkg/api/handlers_data.go:630:6: declaration of "err" shadows declaration at line 608
pkg/api/handlers_data.go:643:8: declaration of "err" shadows declaration at line 608
pkg/api/handlers_data.go:1079:4: declaration of "err" shadows declaration at line 1052
# github.com/masa-finance/masa-oracle/cmd/masa-node
# [github.com/masa-finance/masa-oracle/cmd/masa-node]
cmd/masa-node/main.go:121:3: declaration of "cfg" shadows declaration at line 31
cmd/masa-node/main.go:123:7: declaration of "err" shadows declaration at line 62

Copy link

⚠ staticcheck failed (.)

-: error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping. (compile)
pkg/api/handlers_data.go:92:6: func publishWorkRequest is unused (U1000)
pkg/oracle_node.go:80:6: func getOutboundIP is unused (U1000)
pkg/scrapers/telegram/telegram_client.go:24:2: var once is unused (U1000)
pkg/staking/abi.go:6:2: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details.  (SA1019)
tests/node_listener.go:136:2: this value of err is never used (SA4006)

Checks Document

Copy link

PR description is too short and seems to not fulfill PR template, please fill in

- Modified ScrapeTweetsByQuery to immediately return rate limit errors
- Updated TwitterQueryHandler to properly propagate scraper errors
- Adjusted handleWorkResponse to correctly handle and return errors to the client
- Ensured rate limit errors are logged and returned with appropriate HTTP status codes
- Improved error message clarity for better debugging and user feedback

This commit enhances the system's ability to detect, log, and respond to Twitter API rate limit errors, providing clearer feedback to both developers and end-users when such limits are encountered.
Copy link

PR description is too short and seems to not fulfill PR template, please fill in

- Deleted the publishWorkRequest function from pkg/api/handlers_data.go
- This function was not being used in the current codebase
- Removing it simplifies the code and reduces maintenance overhead
Copy link

PR description is too short and seems to not fulfill PR template, please fill in

- Decompose handleWorkResponse into smaller, focused functions
- Introduce higher-order function for error response handling
- Separate concerns for improved modularity and testability
- Reduce mutable state and side effects where possible
- Maintain idiomatic Go while incorporating functional principles
- Improve error handling granularity and response structure
Copy link

PR description is too short and seems to not fulfill PR template, please fill in

@teslashibe
Copy link
Contributor Author

@restevens402 @mudler this is huge! I am sending this to main it works really well. Latency is higher but the stability is rock solid. We can optimize latency next. So stoked to get this out 🚀

@teslashibe teslashibe merged commit 00c3918 into main Aug 24, 2024
10 of 13 checks passed
@teslashibe teslashibe deleted the fix-multiaddress-not-constructed-on-startup branch August 24, 2024 06:50
mudler added a commit that referenced this pull request Aug 26, 2024
Regression in tests introduced in
#524

Signed-off-by: mudler <[email protected]>
mudler added a commit that referenced this pull request Aug 26, 2024
Regression in tests introduced in
#524

Signed-off-by: mudler <[email protected]>
mudler pushed a commit that referenced this pull request Sep 17, 2024
* Refactor network address handling and improve IP retrieval

Restructure how multiaddresses and IP addresses are handled within the codebase to improve maintainability and efficiency. Added logic for obtaining GCP external IP addresses and restructured public address retrieval. Moved HTTP client functionality to a new package and updated references accordingly.

* Update max remote workers

* Improve worker selection resilience

- Handle invalid multiaddresses gracefully
- Continue searching for eligible workers on errors
- Add more detailed logging for debugging
- Prevent potential nil pointer dereference
- Log warning if no workers found

* Remove IsActive and timeout checks from CanDoWork method

This commit simplifies the worker eligibility criteria in the CanDoWork method
of the NodeData struct. The following changes were made:

- Removed the check for node active status (IsActive)
- Removed the worker timeout check
- Retained the check for staked status (IsStaked)

The method now only considers if a node is staked and configured for the
specific worker type when determining eligibility. This change allows for
more inclusive worker participation, as nodes are no longer excluded based
on active status or timeout conditions.

* extend context deadline timeout for a connection attempt

* Add `MergeMultiaddresses` method and update nodes management

Introduce a `MergeMultiaddresses` method to `NodeData` to handle multiaddress management more efficiently. Update the oracle node logic to use this method for merging incoming multiaddresses instead of replacing them, and add a new `NewWorker` function to initialize workers, enhancing logging and error handling for multiaddress processing.

* Switch to DHT for peer address lookup

Replaced the multiaddress-based peer information retrieval with a DHT lookup to simplify the process. Removed unnecessary imports and optimized the code for finding and connecting to peers in the Distributed Hash Table (DHT).

* Improve Twitter API rate limit error handling and propagation

- Modified ScrapeTweetsByQuery to immediately return rate limit errors
- Updated TwitterQueryHandler to properly propagate scraper errors
- Adjusted handleWorkResponse to correctly handle and return errors to the client
- Ensured rate limit errors are logged and returned with appropriate HTTP status codes
- Improved error message clarity for better debugging and user feedback

This commit enhances the system's ability to detect, log, and respond to Twitter API rate limit errors, providing clearer feedback to both developers and end-users when such limits are encountered.

* chore: remove unused publishWorkRequest function

- Deleted the publishWorkRequest function from pkg/api/handlers_data.go
- This function was not being used in the current codebase
- Removing it simplifies the code and reduces maintenance overhead

* refactor: handleWorkResponse with functional programming concepts

- Decompose handleWorkResponse into smaller, focused functions
- Introduce higher-order function for error response handling
- Separate concerns for improved modularity and testability
- Reduce mutable state and side effects where possible
- Maintain idiomatic Go while incorporating functional principles
- Improve error handling granularity and response structure

---------

Co-authored-by: Bob Stevens <[email protected]>
mudler added a commit that referenced this pull request Sep 17, 2024
Regression in tests introduced in
#524

Signed-off-by: mudler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants