1
1
import { DhtAddress , ListeningRpcCommunicator , toNodeId } from '@streamr/dht'
2
2
import { Handshaker } from './neighbor-discovery/Handshaker'
3
3
import { NeighborFinder } from './neighbor-discovery/NeighborFinder'
4
- import { NeighborUpdateManager } from './neighbor-discovery/NeighborUpdateManager'
5
- import { StrictContentDeliveryLayerNodeOptions , ContentDeliveryLayerNode } from './ContentDeliveryLayerNode'
4
+ import { DEFAULT_NEIGHBOR_UPDATE_INTERVAL , NeighborUpdateManager } from './neighbor-discovery/NeighborUpdateManager'
5
+ import {
6
+ StrictContentDeliveryLayerNodeOptions ,
7
+ ContentDeliveryLayerNode ,
8
+ DEFAULT_NODE_VIEW_SIZE ,
9
+ DEFAULT_ACCEPT_PROXY_CONNECTIONS ,
10
+ DEFAULT_NEIGHBOR_TARGET_COUNT
11
+ } from './ContentDeliveryLayerNode'
6
12
import { NodeList } from './NodeList'
7
- import { Propagation } from './propagation/Propagation'
13
+ import {
14
+ DEFAULT_MIN_PROPAGATION_TARGETS ,
15
+ DEFAULT_MAX_PROPAGATION_BUFFER_SIZE ,
16
+ DEFAULT_PROPAGATION_BUFFER_TTL ,
17
+ Propagation
18
+ } from './propagation/Propagation'
8
19
import { StreamMessage } from '../../generated/packages/trackerless-network/protos/NetworkRpc'
9
20
import type { MarkOptional } from 'ts-essentials'
10
21
import { ProxyConnectionRpcLocal } from './proxy/ProxyConnectionRpcLocal'
@@ -30,12 +41,12 @@ const createConfigWithDefaults = (options: ContentDeliveryLayerNodeOptions): Str
30
41
formStreamPartContentDeliveryServiceId ( options . streamPartId ) ,
31
42
options . transport
32
43
)
33
- const neighborTargetCount = options . neighborTargetCount ?? 4
34
- const maxContactCount = options . maxContactCount ?? 20
35
- const acceptProxyConnections = options . acceptProxyConnections ?? false
36
- const neighborUpdateInterval = options . neighborUpdateInterval ?? 10000
37
- const minPropagationTargets = options . minPropagationTargets
38
- const maxPropagationBufferSize = options . maxPropagationBufferSize
44
+ const neighborTargetCount = options . neighborTargetCount ?? DEFAULT_NEIGHBOR_TARGET_COUNT
45
+ const maxContactCount = options . maxContactCount ?? DEFAULT_NODE_VIEW_SIZE
46
+ const acceptProxyConnections = options . acceptProxyConnections ?? DEFAULT_ACCEPT_PROXY_CONNECTIONS
47
+ const neighborUpdateInterval = options . neighborUpdateInterval ?? DEFAULT_NEIGHBOR_UPDATE_INTERVAL
48
+ const minPropagationTargets = options . minPropagationTargets ?? DEFAULT_MIN_PROPAGATION_TARGETS
49
+ const maxPropagationBufferSize = options . maxPropagationBufferSize ?? DEFAULT_MAX_PROPAGATION_BUFFER_SIZE
39
50
const neighbors = options . neighbors ?? new NodeList ( ownNodeId , maxContactCount )
40
51
const leftNodeView = options . leftNodeView ?? new NodeList ( ownNodeId , maxContactCount )
41
52
const rightNodeView = options . rightNodeView ?? new NodeList ( ownNodeId , maxContactCount )
@@ -57,6 +68,7 @@ const createConfigWithDefaults = (options: ContentDeliveryLayerNodeOptions): Str
57
68
const propagation = options . propagation ?? new Propagation ( {
58
69
minPropagationTargets,
59
70
maxMessages : maxPropagationBufferSize ,
71
+ ttl : DEFAULT_PROPAGATION_BUFFER_TTL ,
60
72
sendToNeighbor : async ( neighborId : DhtAddress , msg : StreamMessage ) : Promise < void > => {
61
73
const remote = neighbors . get ( neighborId ) ?? temporaryConnectionRpcLocal . getNodes ( ) . get ( neighborId )
62
74
const proxyConnection = proxyConnectionRpcLocal ?. getConnection ( neighborId )
0 commit comments