-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
Updating node
Removed logs
@@ -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 == "" { |
There was a problem hiding this comment.
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 == "" { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 == "" { |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"` | ||
|
There was a problem hiding this comment.
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
)
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) | |||
} |
There was a problem hiding this comment.
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
)
} |
} | ||
|
There was a problem hiding this comment.
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
)
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 |
There was a problem hiding this comment.
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") | ||
} | ||
|
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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
)
…dating-node # Conflicts: # node/node.go # node/server.go
Updating node
} | ||
|
||
if err := n.db.SessionFindOneAndUpdate(updates, query, args...); err != nil { | ||
panic(err) | ||
signature, err := n.tx.SignSessionBandwidth(s.ID, s.Index, s.Bandwidth) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
)
} | ||
|
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
)
No description provided.