1717package discv5
1818
1919import (
20- "fmt"
2120 "net"
2221 "testing"
2322 "time"
@@ -265,10 +264,6 @@ type preminedTestnet struct {
265264 net * Network
266265}
267266
268- func (tn * preminedTestnet ) sendFindnode (to * Node , target NodeID ) {
269- panic ("sendFindnode called" )
270- }
271-
272267func (tn * preminedTestnet ) sendFindnodeHash (to * Node , target common.Hash ) {
273268 // current log distance is encoded in port number
274269 // fmt.Println("findnode query at dist", toaddr.Port)
@@ -316,10 +311,6 @@ func (tn *preminedTestnet) sendNeighbours(to *Node, nodes []*Node) {
316311 panic ("sendNeighbours called" )
317312}
318313
319- func (tn * preminedTestnet ) sendTopicQuery (to * Node , topic Topic ) {
320- panic ("sendTopicQuery called" )
321- }
322-
323314func (tn * preminedTestnet ) sendTopicNodes (to * Node , queryHash common.Hash , nodes []* Node ) {
324315 panic ("sendTopicNodes called" )
325316}
@@ -334,41 +325,6 @@ func (*preminedTestnet) localAddr() *net.UDPAddr {
334325 return & net.UDPAddr {IP : net .ParseIP ("10.0.1.1" ), Port : 40000 }
335326}
336327
337- // mine generates a testnet struct literal with nodes at
338- // various distances to the given target.
339- func (tn * preminedTestnet ) mine (target NodeID ) {
340- tn .target = target
341- tn .targetSha = crypto .Keccak256Hash (tn .target [:])
342- found := 0
343- for found < bucketSize * 10 {
344- k := newkey ()
345- id := PubkeyID (& k .PublicKey )
346- sha := crypto .Keccak256Hash (id [:])
347- ld := logdist (tn .targetSha , sha )
348- if len (tn .dists [ld ]) < bucketSize {
349- tn .dists [ld ] = append (tn .dists [ld ], id )
350- fmt .Println ("found ID with ld" , ld )
351- found ++
352- }
353- }
354- fmt .Println ("&preminedTestnet{" )
355- fmt .Printf (" target: %#v,\n " , tn .target )
356- fmt .Printf (" targetSha: %#v,\n " , tn .targetSha )
357- fmt .Printf (" dists: [%d][]NodeID{\n " , len (tn .dists ))
358- for ld , ns := range & tn .dists {
359- if len (ns ) == 0 {
360- continue
361- }
362- fmt .Printf (" %d: []NodeID{\n " , ld )
363- for _ , n := range ns {
364- fmt .Printf (" MustHexID(\" %x\" ),\n " , n [:])
365- }
366- fmt .Println (" }," )
367- }
368- fmt .Println (" }," )
369- fmt .Println ("}" )
370- }
371-
372328func injectResponse (net * Network , from * Node , ev nodeEvent , packet interface {}) {
373329 go net .reqReadPacket (ingressPacket {remoteID : from .ID , remoteAddr : from .addr (), ev : ev , data : packet })
374330}
0 commit comments