Skip to content

Commit 2f49e8f

Browse files
committed
Fixed incorrect hash formatting
1 parent d8c9365 commit 2f49e8f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

internal/d7024e/network.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net"
99
"time"
1010
"crypto/sha1"
11+
"regexp"
1112
)
1213

1314
type Network struct {
@@ -230,10 +231,18 @@ func (network *Network) AddToStore(message string) {
230231
}
231232

232233
func (network *Network) LookForData(hash string) (bool, string) {
234+
235+
//Corrects hash if it is formatted wrong
236+
if (string(hash[0]) == "\""){
237+
hash = hash[1:len(hash)-1]
238+
var re = regexp.MustCompile(`[ ]`)
239+
hash = re.ReplaceAllString(hash, `,`)
240+
}
241+
233242
for key, element := range network.routingTable.me.KeyValueStore {
234-
fmt.Println("LookForData loop")
235-
fmt.Println("Key: " + key)
236-
fmt.Println("Hash: " + hash)
243+
//fmt.Println("LookForData loop")
244+
//fmt.Println("Key: " + key)
245+
//fmt.Println("Hash: " + hash)
237246

238247
if key == hash {
239248
fmt.Println("LookForData found element: " + element)

0 commit comments

Comments
 (0)