aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discv5
diff options
context:
space:
mode:
authorkiel barry <kiel.j.barry@gmail.com>2018-05-08 19:08:43 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-05-08 19:08:43 +0800
commit864e80a48fd18fda89b80b11f9116c4e11cb835d (patch)
tree1eb9aa6bbae718b9505e67f4464c6750c08e51eb /p2p/discv5
parenta42be3b78dcb70ea3c44ba46c277cf41ef0bba23 (diff)
downloadgo-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.gz
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.bz2
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.lz
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.xz
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.tar.zst
go-tangerine-864e80a48fd18fda89b80b11f9116c4e11cb835d.zip
p2p: fix some golint warnings (#16577)
Diffstat (limited to 'p2p/discv5')
-rw-r--r--p2p/discv5/net_test.go20
-rw-r--r--p2p/discv5/node.go8
-rw-r--r--p2p/discv5/ticket.go4
-rw-r--r--p2p/discv5/topic.go16
4 files changed, 24 insertions, 24 deletions
diff --git a/p2p/discv5/net_test.go b/p2p/discv5/net_test.go
index 369282ca9..001d193cc 100644
--- a/p2p/discv5/net_test.go
+++ b/p2p/discv5/net_test.go
@@ -336,26 +336,26 @@ func (*preminedTestnet) localAddr() *net.UDPAddr {
// mine generates a testnet struct literal with nodes at
// various distances to the given target.
-func (n *preminedTestnet) mine(target NodeID) {
- n.target = target
- n.targetSha = crypto.Keccak256Hash(n.target[:])
+func (tn *preminedTestnet) mine(target NodeID) {
+ tn.target = target
+ tn.targetSha = crypto.Keccak256Hash(tn.target[:])
found := 0
for found < bucketSize*10 {
k := newkey()
id := PubkeyID(&k.PublicKey)
sha := crypto.Keccak256Hash(id[:])
- ld := logdist(n.targetSha, sha)
- if len(n.dists[ld]) < bucketSize {
- n.dists[ld] = append(n.dists[ld], id)
+ ld := logdist(tn.targetSha, sha)
+ if len(tn.dists[ld]) < bucketSize {
+ tn.dists[ld] = append(tn.dists[ld], id)
fmt.Println("found ID with ld", ld)
found++
}
}
fmt.Println("&preminedTestnet{")
- fmt.Printf(" target: %#v,\n", n.target)
- fmt.Printf(" targetSha: %#v,\n", n.targetSha)
- fmt.Printf(" dists: [%d][]NodeID{\n", len(n.dists))
- for ld, ns := range n.dists {
+ fmt.Printf(" target: %#v,\n", tn.target)
+ fmt.Printf(" targetSha: %#v,\n", tn.targetSha)
+ fmt.Printf(" dists: [%d][]NodeID{\n", len(tn.dists))
+ for ld, ns := range tn.dists {
if len(ns) == 0 {
continue
}
diff --git a/p2p/discv5/node.go b/p2p/discv5/node.go
index fd88a55b1..3d4748512 100644
--- a/p2p/discv5/node.go
+++ b/p2p/discv5/node.go
@@ -315,11 +315,11 @@ func PubkeyID(pub *ecdsa.PublicKey) NodeID {
// Pubkey returns the public key represented by the node ID.
// It returns an error if the ID is not a point on the curve.
-func (id NodeID) Pubkey() (*ecdsa.PublicKey, error) {
+func (n NodeID) Pubkey() (*ecdsa.PublicKey, error) {
p := &ecdsa.PublicKey{Curve: crypto.S256(), X: new(big.Int), Y: new(big.Int)}
- half := len(id) / 2
- p.X.SetBytes(id[:half])
- p.Y.SetBytes(id[half:])
+ half := len(n) / 2
+ p.X.SetBytes(n[:half])
+ p.Y.SetBytes(n[half:])
if !p.Curve.IsOnCurve(p.X, p.Y) {
return nil, errors.New("id is invalid secp256k1 curve point")
}
diff --git a/p2p/discv5/ticket.go b/p2p/discv5/ticket.go
index b3d1ac4ba..ae4b18e7c 100644
--- a/p2p/discv5/ticket.go
+++ b/p2p/discv5/ticket.go
@@ -304,8 +304,8 @@ func (s ticketRefByWaitTime) Len() int {
return len(s)
}
-func (r ticketRef) waitTime() mclock.AbsTime {
- return r.t.regTime[r.idx] - r.t.issueTime
+func (ref ticketRef) waitTime() mclock.AbsTime {
+ return ref.t.regTime[ref.idx] - ref.t.issueTime
}
// Less reports whether the element with
diff --git a/p2p/discv5/topic.go b/p2p/discv5/topic.go
index e7a7f8e02..609a41297 100644
--- a/p2p/discv5/topic.go
+++ b/p2p/discv5/topic.go
@@ -271,15 +271,15 @@ func (t *topicTable) useTicket(node *Node, serialNo uint32, topics []Topic, idx
return false
}
-func (topictab *topicTable) getTicket(node *Node, topics []Topic) *ticket {
- topictab.collectGarbage()
+func (t *topicTable) getTicket(node *Node, topics []Topic) *ticket {
+ t.collectGarbage()
now := mclock.Now()
- n := topictab.getOrNewNode(node)
+ n := t.getOrNewNode(node)
n.lastIssuedTicket++
- topictab.storeTicketCounters(node)
+ t.storeTicketCounters(node)
- t := &ticket{
+ tic := &ticket{
issueTime: now,
topics: topics,
serial: n.lastIssuedTicket,
@@ -287,15 +287,15 @@ func (topictab *topicTable) getTicket(node *Node, topics []Topic) *ticket {
}
for i, topic := range topics {
var waitPeriod time.Duration
- if topic := topictab.topics[topic]; topic != nil {
+ if topic := t.topics[topic]; topic != nil {
waitPeriod = topic.wcl.waitPeriod
} else {
waitPeriod = minWaitPeriod
}
- t.regTime[i] = now + mclock.AbsTime(waitPeriod)
+ tic.regTime[i] = now + mclock.AbsTime(waitPeriod)
}
- return t
+ return tic
}
const gcInterval = time.Minute