From b3759d3350ade6417e2588dd7b54023d3b029142 Mon Sep 17 00:00:00 2001 From: balasan Date: Wed, 4 Nov 2020 19:25:29 -0800 Subject: [PATCH] lint stuff --- deterministic/graph.go | 13 +++++++------ deterministic/pagerank.go | 2 +- deterministic/pagerank_test.go | 2 +- deterministic/processResults.go | 2 +- deterministic/test_utils.go | 2 +- non-deterministic/graph.go | 15 ++++++++------- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/deterministic/graph.go b/deterministic/graph.go index 7c7e7c6..e329df7 100644 --- a/deterministic/graph.go +++ b/deterministic/graph.go @@ -1,4 +1,4 @@ -// Package reputation is an implementation of the Relevant Reputaiton protocol: +// Package detrep is a deterministic implementation of the Relevant Reputaiton protocol: // a personalized pagerank algorithm that supports negative links // personalized version offers sybil resistance // can be used for voting, governance, ranking @@ -10,7 +10,7 @@ // TODO: edge case (only impacts display) - if a node has no inputs we should set its score to 0 to avoid // a stale score if all of nodes inputs are cancelled out // would need to keep track of node inputs... -package repDet +package detrep import ( "strconv" @@ -33,13 +33,14 @@ const ( // Default decimals used in computation const Decimals = 18 -// this is defines the cutoff for when a node will have it's outging links counted +// MAX_NEG_OFFSET defines the cutoff for when a node will have it's outging links counted // if previously NegativeRank / PositiveRank > MaxNegOffset / (MaxNegOffset + 1) we will not consider // any outgoing links // otherwise, we counter the outgoing lings with one 'heavy' link proportional to the MaxNegOffset ratio const MaxNegOffset = 10 -// Node input struct for creating nodes and edges +// NodeInput is struct passing data to the graph +// TODO does it make sense to just use the Node type? type NodeInput struct { Id string PRank sdk.Uint @@ -66,7 +67,7 @@ type Graph struct { MaxNegOffset sdk.Uint } -// Pagerank params +// RankParams is the pagerank parameters // α is the probably the person will not teleport // ε is the min global error between iterations // personalization is the personalization vector (can be nil for non-personalized pr) @@ -92,7 +93,7 @@ func NewGraph(α sdk.Uint, ε sdk.Uint, negConsumerRank sdk.Uint) *Graph { } } -// helper method to create a node input struct +// NewNodeInput is ahelper method to create a node input struct func NewNodeInput(id string, pRank sdk.Uint, nRank sdk.Uint) NodeInput { return NodeInput{Id: id, PRank: pRank, NRank: nRank} } diff --git a/deterministic/pagerank.go b/deterministic/pagerank.go index 806f680..a9d13ce 100644 --- a/deterministic/pagerank.go +++ b/deterministic/pagerank.go @@ -1,4 +1,4 @@ -package repDet +package detrep import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/deterministic/pagerank_test.go b/deterministic/pagerank_test.go index cbb8c3d..4e39512 100644 --- a/deterministic/pagerank_test.go +++ b/deterministic/pagerank_test.go @@ -1,4 +1,4 @@ -package repDet +package detrep import ( "reflect" diff --git a/deterministic/processResults.go b/deterministic/processResults.go index 5055388..26be091 100644 --- a/deterministic/processResults.go +++ b/deterministic/processResults.go @@ -1,4 +1,4 @@ -package repDet +package detrep import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/deterministic/test_utils.go b/deterministic/test_utils.go index c1b1ce4..13c00fb 100644 --- a/deterministic/test_utils.go +++ b/deterministic/test_utils.go @@ -1,4 +1,4 @@ -package repDet +package detrep import ( "math" diff --git a/non-deterministic/graph.go b/non-deterministic/graph.go index 3aef7ff..cca25be 100644 --- a/non-deterministic/graph.go +++ b/non-deterministic/graph.go @@ -1,4 +1,4 @@ -// Package reputation is an implementation of the Relevant Reputaiton protocol: +// Package rep is an implementation of the Relevant Reputaiton protocol: // a personalized pagerank algorithm that supports negative links // personalized version offers sybil resistance // can be used for voting, governance, ranking @@ -35,14 +35,15 @@ const ( Negative ) -// Node input struct for creating nodes and edges +// NodeInput is struct passing data to the graph +// TODO does it make sense to just use the Node type? type NodeInput struct { Id string PRank float64 NRank float64 } -// Internal node struct +// Node is an internal node struct type Node struct { id string rank float64 // pos page rank of the node @@ -60,7 +61,7 @@ type Graph struct { negConsumer NodeInput } -// Pagerank params +// RankParams is the pagerank parameters // α is the probably the person will not teleport // ε is the min global error between iterations // personalization is the personalization vector (can be nil for non-personalized pr) @@ -84,7 +85,7 @@ func NewGraph(α, ε, negConsumerRank float64) *Graph { } } -// helper method to create a node input struct +// NewNodeInput is ahelper method to create a node input struct func NewNodeInput(id string, pRank float64, nRank float64) NodeInput { return NodeInput{Id: id, PRank: pRank, NRank: nRank} } @@ -218,12 +219,12 @@ func (graph *Graph) cancelOpposites(sourceNode Node, target string, nodeType Nod } } -// InitPosNode initialized a positive node +// InitPosNode is a helper method that initializes a positive node func (graph *Graph) InitPosNode(inputNode NodeInput) *Node { return graph.initNode(inputNode.Id, inputNode, Positive) } -// initNode initialized a node +// initNode initializes a node func (graph *Graph) initNode(key string, inputNode NodeInput, nodeType NodeType) *Node { if _, ok := graph.nodes[key]; ok == false { graph.nodes[key] = &Node{