-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpcadapters.go
59 lines (50 loc) · 1.69 KB
/
rpcadapters.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"sync/atomic"
"github.com/MonteCarloClub/acbc/peer"
)
// rpcPeer provides a peer for use with the RPC server and implements the
// rpcserverPeer interface.
// 类型定义,虽然rpcPeer底层是serverPeer,但是他们依然是两个类型
type rpcPeer serverPeer
// Ensure rpcPeer implements the rpcserverPeer interface.
var _ rpcserverPeer = (*rpcPeer)(nil)
// ToPeer returns the underlying peer instance.
//
// This function is safe for concurrent access and is part of the rpcserverPeer
// interface implementation.
func (p *rpcPeer) ToPeer() *peer.Peer {
if p == nil {
return nil
}
return (*serverPeer)(p).Peer
}
// IsTxRelayDisabled returns whether or not the peer has disabled transaction
// relay.
//
// This function is safe for concurrent access and is part of the rpcserverPeer
// interface implementation.
func (p *rpcPeer) IsTxRelayDisabled() bool {
return (*serverPeer)(p).disableRelayTx
}
// BanScore returns the current integer value that represents how close the peer
// is to being banned.
//
// This function is safe for concurrent access and is part of the rpcserverPeer
// interface implementation.
func (p *rpcPeer) BanScore() uint32 {
return (*serverPeer)(p).banScore.Int()
}
// FeeFilter returns the requested current minimum fee rate for which
// transactions should be announced.
//
// This function is safe for concurrent access and is part of the rpcserverPeer
// interface implementation.
func (p *rpcPeer) FeeFilter() int64 {
return atomic.LoadInt64(&(*serverPeer)(p).feeFilter)
}
// rpcConnManager provides a connection manager for use with the RPC server and
// implements the rpcserverConnManager interface.
type rpcConnManager struct {
server *server
}