mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
swarm/pss: WIP amend PR comments by @zelig
This commit is contained in:
parent
bc2a4b866f
commit
92bafbf4a0
2 changed files with 13 additions and 10 deletions
|
|
@ -91,15 +91,15 @@ func NewKadParams() *KadParams {
|
||||||
// Kademlia is a table of live peers and a db of known peers (node records)
|
// Kademlia is a table of live peers and a db of known peers (node records)
|
||||||
type Kademlia struct {
|
type Kademlia struct {
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
*KadParams // Kademlia configuration parameters
|
*KadParams // Kademlia configuration parameters
|
||||||
base []byte // immutable baseaddress of the table
|
base []byte // immutable baseaddress of the table
|
||||||
addrs *pot.Pot // pots container for known peer addresses
|
addrs *pot.Pot // pots container for known peer addresses
|
||||||
conns *pot.Pot // pots container for live peer connections
|
conns *pot.Pot // pots container for live peer connections
|
||||||
depth uint8 // stores the last current depth of saturation
|
depth uint8 // stores the last current depth of saturation
|
||||||
nDepth int // stores the last neighbourhood depth
|
nDepth int // stores the last neighbourhood depth
|
||||||
nDepthC chan int // returned by DepthC function to signal neighbourhood depth change
|
nDepthC chan int // returned by DepthC function to signal neighbourhood depth change
|
||||||
addrCountC chan int // returned by AddrCountC function to signal peer count change
|
addrCountC chan int // returned by AddrCountC function to signal peer count change
|
||||||
Pof func(pot.Val, pot.Val, int) (int, bool)
|
Pof func(pot.Val, pot.Val, int) (int, bool) // function for calculating kademlia routing distance between two addresses
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewKademlia creates a Kademlia table for base address addr
|
// NewKademlia creates a Kademlia table for base address addr
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ func NewAPI(ps *Pss) *API {
|
||||||
//
|
//
|
||||||
// All incoming messages to the node matching this topic will be encapsulated in the APIMsg
|
// All incoming messages to the node matching this topic will be encapsulated in the APIMsg
|
||||||
// struct and sent to the subscriber
|
// struct and sent to the subscriber
|
||||||
func (pssapi *API) Receive(ctx context.Context, topic Topic, raw bool) (*rpc.Subscription, error) {
|
func (pssapi *API) Receive(ctx context.Context, topic Topic, raw bool, prox bool) (*rpc.Subscription, error) {
|
||||||
notifier, supported := rpc.NotifierFromContext(ctx)
|
notifier, supported := rpc.NotifierFromContext(ctx)
|
||||||
if !supported {
|
if !supported {
|
||||||
return nil, fmt.Errorf("Subscribe not supported")
|
return nil, fmt.Errorf("Subscribe not supported")
|
||||||
|
|
@ -75,6 +75,9 @@ func (pssapi *API) Receive(ctx context.Context, topic Topic, raw bool) (*rpc.Sub
|
||||||
if raw {
|
if raw {
|
||||||
hndlr.caps |= handlerCapRaw
|
hndlr.caps |= handlerCapRaw
|
||||||
}
|
}
|
||||||
|
if prox {
|
||||||
|
hndlr.caps |= handlerCapProx
|
||||||
|
}
|
||||||
|
|
||||||
deregf := pssapi.Register(&topic, hndlr)
|
deregf := pssapi.Register(&topic, hndlr)
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue