Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-peerstore
Commits
afca3552
Commit
afca3552
authored
May 17, 2019
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
index the peer ID strings directly to avoid copying the byte slice
parent
d340d298
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
12 deletions
+6
-12
pstoreds/protobook.go
pstoreds/protobook.go
+4
-8
pstoremem/addr_book.go
pstoremem/addr_book.go
+1
-2
pstoremem/protobook.go
pstoremem/protobook.go
+1
-2
No files found.
pstoreds/protobook.go
View file @
afca3552
...
...
@@ -21,23 +21,19 @@ func NewProtoBook(meta pstore.PeerMetadata) pstore.ProtoBook {
}
func
(
pb
*
dsProtoBook
)
Lock
(
p
peer
.
ID
)
{
b
:=
[]
byte
(
p
)
pb
.
lks
[
b
[
len
(
b
)
-
1
]]
.
Lock
()
pb
.
lks
[
byte
(
p
[
len
(
p
)
-
1
])]
.
Lock
()
}
func
(
pb
*
dsProtoBook
)
Unlock
(
p
peer
.
ID
)
{
b
:=
[]
byte
(
p
)
pb
.
lks
[
b
[
len
(
b
)
-
1
]]
.
Unlock
()
pb
.
lks
[
byte
(
p
[
len
(
p
)
-
1
])]
.
Unlock
()
}
func
(
pb
*
dsProtoBook
)
RLock
(
p
peer
.
ID
)
{
b
:=
[]
byte
(
p
)
pb
.
lks
[
b
[
len
(
b
)
-
1
]]
.
RLock
()
pb
.
lks
[
byte
(
p
[
len
(
p
)
-
1
])]
.
RLock
()
}
func
(
pb
*
dsProtoBook
)
RUnlock
(
p
peer
.
ID
)
{
b
:=
[]
byte
(
p
)
pb
.
lks
[
b
[
len
(
b
)
-
1
]]
.
RUnlock
()
pb
.
lks
[
byte
(
p
[
len
(
p
)
-
1
])]
.
RUnlock
()
}
func
(
pb
*
dsProtoBook
)
SetProtocols
(
p
peer
.
ID
,
protos
...
string
)
error
{
...
...
pstoremem/addr_book.go
View file @
afca3552
...
...
@@ -40,8 +40,7 @@ type addrSegment struct {
}
func
(
s
*
addrSegments
)
get
(
p
peer
.
ID
)
*
addrSegment
{
b
:=
[]
byte
(
p
)
return
s
[
b
[
len
(
b
)
-
1
]]
return
s
[
byte
(
p
[
len
(
p
)
-
1
])]
}
// memoryAddrBook manages addresses.
...
...
pstoremem/protobook.go
View file @
afca3552
...
...
@@ -21,8 +21,7 @@ type protoSegment struct {
type
protoSegments
[
256
]
*
protoSegment
func
(
s
*
protoSegments
)
get
(
p
peer
.
ID
)
*
protoSegment
{
b
:=
[]
byte
(
p
)
return
s
[
b
[
len
(
b
)
-
1
]]
return
s
[
byte
(
p
[
len
(
p
)
-
1
])]
}
type
memoryProtoBook
struct
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment