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

Updated version #2

Closed

Conversation

bitsndbyts
Copy link
Contributor

No description provided.

@@ -124,8 +131,11 @@ func (a *AppConfig) Validate() error {
if a.RPCAddress == "" {
return errors.Errorf("Invalid rpc_address")
}
if a.ResolverAddress == "" {
return errors.Errorf("Invalid resolver_address")
if a.Resolver.ID == "" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statements should only be cuddled with assignments (from wsl)

if a.Resolver.ID == "" {
return errors.Errorf("Invalid resolver_id")
}
if a.Resolver.IP == "" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statements should only be cuddled with assignments (from wsl)

if err != nil {
return nil, err
}

log.Printf("Querying the transaction with hash `%s`", hash)
res, err := node.Tx(_hash, !m.CLIContext.TrustNode)
res, err := node.Tx(_hash, !m.CLI.TrustNode)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assignments should only be cuddled with other assignments (from wsl)

return common.QuerySubscription(t.Manager.CLIContext, t.Manager.CLIContext.Codec, id)
events := sdk.StringifyEvents(res.TxResult.Events)
id := events[1].Attributes[0].Value
return common.QuerySubscription(t.Manager.CLI.CLIContext, id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return statements should not be cuddled if block has more than two lines (from wsl)

if id == "" {
func ProcessNode(cfg *config.AppConfig, tx *_tx.Tx, _vpn types.BaseVPN) (*config.AppConfig, *vpn.Node, error) {
from := tx.Manager.CLI.FromAddress
if cfg.Node.ID == "" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statements should only be cuddled with assignments used in the if statement itself (from wsl)

node/server.go Outdated
if !n.pubKey.VerifyBytes(data, msg.NodeOwnerSignature) {
return NewMsgError(4, "Invalid node owner signature")
return NewMsgError(5, "Invalid node owner signature")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 5, in detected (from gomnd)

}
if !pubKey.VerifyBytes(data, msg.ClientSignature) {
return NewMsgError(5, "Invalid client signature")
}

sub, err := n.tx.QuerySubscription(msg.ID.String())
if err != nil {
return NewMsgError(5, "Invalid client signature")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 5, in detected (from gomnd)


if !msg.Bandwidth.AllLTE(sub.RemainingBandwidth) {
n.clients[msg.ID.String()].conn.Close()
return NewMsgError(5, "Invalid bandwidth")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 5, in detected (from gomnd)

@@ -27,12 +27,19 @@ type client struct {
var (
upgrader = &websocket.Upgrader{
HandshakeTimeout: 45 * time.Second,
WriteBufferSize: 1024,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 1024, in detected (from gomnd)


_msg := vpn.NewMsgRegisterVPNOnResolver(from, nodeID, resolverId)

data, err := tx.CompleteAndSubscribeTx(_msg)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shadow: declaration of "err" shadows declaration at line 70 (from govet)

types/node.go Outdated
ID string `json:"id" `
Address string `json:"address" `
Deposit Coin `json:"deposit"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not goimports-ed with -local github.com/sentinel-official/dvpn-node (from goimports)

Suggested change

config/app.go Outdated
@@ -38,24 +41,28 @@ prices_per_gb = "{{ .Node.PricesPerGB }}"
// nolint:gochecknoinits
func init() {
var err error

appConfigTemplate, err = template.New("appConfig").Parse(defaultAppConfigTemplate)
if err != nil {
panic(err)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not goimports-ed with -local github.com/sentinel-official/dvpn-node (from goimports)

Suggested change
}

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File is not goimports-ed with -local github.com/sentinel-official/dvpn-node (from goimports)

Suggested change

node/server.go Outdated
@@ -556,7 +581,7 @@ func (n *Node) readMessages(id string, index uint64) {
continue
}

if errMsg := n.handleIncomingMessage(client.pubKey, &msg); errMsg != nil {
if errMsg := n.handleIncomingMessage(client.pubKey, msg); errMsg != nil {
client.outMessages <- errMsg

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 2, in detected (from gomnd)

if err := msg.Validate(); err != nil {
return NewMsgError(3, "Invalid message")
return NewMsgError(2, "Invalid message")
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 5, in detected (from gomnd)

if !n.pubKey.VerifyBytes(data, msg.NodeOwnerSignature) {
return NewMsgError(4, "Invalid node owner signature")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 5, in detected (from gomnd)

}

if err := n.db.SessionFindOneAndUpdate(updates, query, args...); err != nil {
panic(err)
signature, err := n.tx.SignSessionBandwidth(s.ID, s.Index, s.Bandwidth)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ineffectual assignment to err (from ineffassign)


if client != nil {
if makeTx {
signature, err := n.tx.SignSessionBandwidth(_id, s.Index, s.Bandwidth) // nolint:govet

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whyNoLint: include an explanation for nolint directive (from gocritic)

@@ -120,16 +94,29 @@ func (n *Node) updateBandwidthInfos() error {
}

var messages []sdk.Msg
var ids []string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declarations should never be cuddled (from wsl)

@@ -120,16 +94,29 @@ func (n *Node) updateBandwidthInfos() error {
}

var messages []sdk.Msg
var ids []string
var wg sync.WaitGroup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declarations should never be cuddled (from wsl)

go func(id string, bandwidth hub.Bandwidth, makeTx bool) {
message, err := n.requestBandwidthSign(id, bandwidth, makeTx)
if err != nil {
panic(err)
}
if message != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if statements should only be cuddled with assignments (from wsl)

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary trailing newline (from whitespace)


var msg types.Msg
if err := json.Unmarshal(p, &msg); err != nil {
client.outMessages <- NewMsgError(1, "Error occurred while decoding the message")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 1, in detected (from gomnd)


_session = &types.Session{
ID: sub.ID,
Index: index + 1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mnd: Magic number: 1, in detected (from gomnd)

"_status": types.INACTIVE,
}

if err := n.db.SessionFindOneAndUpdate(updates, query, args...); err != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shadow: declaration of "err" shadows declaration at line 255 (from govet)

if err.Error() == "couldn't create db: Error initializing DB: resource temporarily unavailable" {
continue
} else {
err.Error()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unusedresult: result of (error).Error call not used (from govet)

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.

4 participants