forked from cruzbit/cruzbit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpeer_storage.go
31 lines (22 loc) · 1.11 KB
/
peer_storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2019 cruzbit developers
// Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
package cruzbit
// PeerStorage is an interface for storing peer addresses and information about their connectivity.
type PeerStorage interface {
// Store stores a peer address. Returns true if the peer was newly added to storage.
Store(addr string) (bool, error)
// Get returns some peers for us to attempt to connect to.
Get(count int) ([]string, error)
// GetSince returns some peers to tell others about last active less than "when" ago.
GetSince(count int, when int64) ([]string, error)
// Delete is called to explicitly remove a peer address from storage.
Delete(addr string) error
// OnConnectAttempt is called prior to attempting to connect to the peer.
OnConnectAttempt(addr string) error
// OnConnectSuccess is called upon successful handshake with the peer.
OnConnectSuccess(addr string) error
// OnConnectFailure is called upon connection failure.
OnConnectFailure(addr string) error
// OnDisconnect is called upon disconnection.
OnDisconnect(addr string) error
}