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-kbucket
Commits
ba93cb36
Commit
ba93cb36
authored
Aug 01, 2019
by
Aarsh Shah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added a fnc to get all buckets
parent
ae212638
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
bucket.go
bucket.go
+1
-1
table.go
table.go
+6
-1
No files found.
bucket.go
View file @
ba93cb36
...
...
@@ -24,7 +24,7 @@ func newBucket() *Bucket {
return
b
}
func
(
b
*
Bucket
)
Get
LastQueriedAt
()
time
.
Time
{
func
(
b
*
Bucket
)
LastQueriedAt
()
time
.
Time
{
b
.
lastQueriedAtLk
.
RLock
()
defer
b
.
lastQueriedAtLk
.
RUnlock
()
...
...
table.go
View file @
ba93cb36
...
...
@@ -24,7 +24,6 @@ var ErrGenRandPeerIDFailed = errors.New("failed to generate random peerID in buc
// RoutingTable defines the routing table.
type
RoutingTable
struct
{
// ID of the local peer
local
ID
...
...
@@ -61,6 +60,12 @@ func NewRoutingTable(bucketsize int, localID ID, latency time.Duration, m peerst
return
rt
}
func
(
rt
*
RoutingTable
)
GetAllBuckets
()
[]
*
Bucket
{
rt
.
tabLock
.
RLock
()
defer
rt
.
tabLock
.
RUnlock
()
return
rt
.
Buckets
}
func
(
rt
*
RoutingTable
)
GenRandPeerID
(
bucketID
int
)
(
peer
.
ID
,
error
)
{
rt
.
tabLock
.
RLock
()
bucketLen
:=
len
(
rt
.
Buckets
)
...
...
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