Skip to content

Commit

Permalink
Removed logs
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsnew committed Mar 20, 2013
1 parent 84e100c commit 9fb000d
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 30 deletions.
5 changes: 0 additions & 5 deletions kademlia/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func (b *Bucket) waitRefresh() {
case <-timeOut:
// refresh bucket
if b.contacts.Len() != 0 {
log.Println("Bucket", b.index, "timed out, refreshing contacts")
b.refresh()
}
}
Expand All @@ -55,7 +54,6 @@ func (b *Bucket) waitRefresh() {
func (b *Bucket) refresh() {
// selects a random number in the bucket's range and do an
// iterativeFindNode using that number as key
log.Println("Refreshing bucket", b.index)

c := b.contacts.Front().Value.(Contact)
idInBucket := c.NodeID
Expand All @@ -81,19 +79,16 @@ func (b *Bucket) updateContact(c Contact) {
b.refreshChan <- true
if !ok {
if b.contacts.Len() <= MAX_BUCKET_SIZE {
log.Print("Adding contact to bucket: ", c.NodeID.AsString())
b.contacts.PushBack(c)
} else {
// ping the least recently seen node
firstEl := b.contacts.Front()
first := firstEl.Value.(Contact)
_, err := SendPing(b.k, first.Address())
if err != nil {
log.Println("Old node responded, ignoring new contact")
// first is now most recently seen
b.contacts.MoveToBack(firstEl)
} else {
log.Println("Old node did not respond, evicting and adding new contact")
b.contacts.Remove(firstEl)
b.contacts.PushBack(c)
}
Expand Down
2 changes: 0 additions & 2 deletions kademlia/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kademlia

import (
"crypto/sha256"
"log"
)

func HashStore(k *Kademlia, value []byte) (hash []byte, err error) {
Expand All @@ -11,7 +10,6 @@ func HashStore(k *Kademlia, value []byte) (hash []byte, err error) {
if err != nil {
return
}
log.Println(key.AsString())
_, err = IterativeStore(k, key, value)
return
}
Expand Down
2 changes: 0 additions & 2 deletions kademlia/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ func insertUnseenSorted(inputList *list.List, items [](Contact), compare func(Co

// assumes the id is only in the list once
func removeFromSorted(l *list.List, id ID) {

log.Println("Removinng", id.AsString(), "from shortList")
for e := l.Front(); e != nil; e = e.Next() {
c := e.Value.(Contact)
if c.NodeID.Equals(id) {
Expand Down
13 changes: 0 additions & 13 deletions kademlia/rpc_find_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package kademlia
import (
"container/list"
"errors"
"log"
"net/rpc"
"time"
)
Expand Down Expand Up @@ -59,9 +58,6 @@ func SendFindNodeAddr(k *Kademlia, nodeID ID, address string) (foundNodes []Foun
}

func sendFindNodeAddr(k *Kademlia, nodeID ID, address string) ([]FoundNode, error) {
// TODO
// send a findNode rpc and return the k-closest nodes
log.Println("Sending FindNode rpc to ", address)
client, err := rpc.DialHTTP("tcp", address)
if err != nil {
return nil, err
Expand Down Expand Up @@ -91,7 +87,6 @@ func sendFindNodeAddr(k *Kademlia, nodeID ID, address string) ([]FoundNode, erro
}

func (k *Kademlia) FindNode(req FindNodeRequest, res *FindNodeResult) error {
log.Println("Handling FindNode request from", req.Sender.Address())
// Find the k closest nodes to FindNodeRequest.NodeID and pack
// them in FindNodeResult.Nodes
k.updateContact(req.Sender)
Expand Down Expand Up @@ -165,13 +160,6 @@ func IterativeFindNode(k *Kademlia, searchID ID) ([]Contact, error) {
// make sure they're there
allUnseen := getUnseen(shortList, alreadySeen, shortList.Len())

if len(allUnseen) != 0 {
log.Println("Didn't get closer, removing already seens")
}
for _, c := range allUnseen {
log.Println(c.NodeID.AsString())
}

unseenNodes := k.goFindNodes(allUnseen, searchID)

// send find_node rpcs to nextSearchNodes, add their nodes to shortList
Expand Down Expand Up @@ -205,7 +193,6 @@ func (k *Kademlia) goFindNodes(searchNodes []Contact, searchID ID) <-chan Signed

for _, curNode := range searchNodes {
node := curNode
log.Println("Going sendFindNode to", node.NodeID.AsString())
go func() {
foundNodes, err := SendFindNode(k, searchID, node.NodeID)
output := SignedFoundNodes{foundNodes, err, node}
Expand Down
2 changes: 0 additions & 2 deletions kademlia/rpc_find_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package kademlia
import (
"container/list"
"errors"
"log"
"net/rpc"
)

Expand Down Expand Up @@ -63,7 +62,6 @@ func (k *Kademlia) FindValue(req FindValueRequest, res *FindValueResult) error {
res.Err = nil
res.Nodes = nil
} else {
log.Println("No value for key:", req.Key.AsString())
// return closest nodes
res.MsgID = req.MsgID
res.Value = nil
Expand Down
2 changes: 0 additions & 2 deletions kademlia/rpc_ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kademlia

import (
"errors"
"log"
"net/rpc"
)

Expand Down Expand Up @@ -44,7 +43,6 @@ func SendPing(k *Kademlia, address string) (pong *Pong, err error) {
func (k *Kademlia) Ping(ping Ping, pong *Pong) error {
// This one's a freebie.
if !ping.Sender.NodeID.Equals(k.NodeID) {
log.Print("Adding contact: ", ping.Sender.NodeID.AsString())
k.updateContact(ping.Sender)
}
pong.MsgID = ping.MsgID
Expand Down
4 changes: 0 additions & 4 deletions kademlia/rpc_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package kademlia

import (
"errors"
"log"
"net/rpc"
)

Expand All @@ -20,7 +19,6 @@ type StoreResult struct {
}

func (k *Kademlia) Store(req StoreRequest, res *StoreResult) error {
log.Println("Handling store request from", req.Sender.Address())
k.updateContact(req.Sender)
res.MsgID = req.MsgID

Expand All @@ -40,7 +38,6 @@ func SendStore(k *Kademlia, key ID, value []byte, nodeID ID) error {
address := c.Address()

client, err := rpc.DialHTTP("tcp", address)
log.Println("Sending Store rpc to", address)
if err != nil {
k.removeContact(c.NodeID)
return nil
Expand Down Expand Up @@ -77,7 +74,6 @@ func IterativeStore(k *Kademlia, key ID, value []byte) (lastID ID, err error) {
SendStore(k, key, value, node.NodeID)
}

// log.Println("Found", len(nodes), nodes)
lastID = nodes[len(nodes)-1].NodeID

return
Expand Down

0 comments on commit 9fb000d

Please sign in to comment.