Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultPrefix protocol.ID = amino.ProtocolPrefix
DefaultPrefix 是默认情况下附加到所有DHT协议的应用程序特定前缀
Variables ¶
View Source
var Defaults = func(o *Config) error { o.Validator = record.NamespacedValidator{} o.Datastore = dssync.MutexWrap(ds.NewMapDatastore()) o.ProtocolPrefix = DefaultPrefix o.EnableProviders = true o.EnableValues = true o.QueryPeerFilter = EmptyQueryFilter o.MsgSenderBuilder = net.NewMessageSenderImpl o.RoutingTable.LatencyTolerance = 10 * time.Second o.RoutingTable.RefreshQueryTimeout = 10 * time.Second o.RoutingTable.RefreshInterval = 10 * time.Minute o.RoutingTable.AutoRefresh = true o.RoutingTable.PeerFilter = EmptyRTFilter o.MaxRecordAge = providers.ProvideValidity o.BucketSize = amino.DefaultBucketSize o.Concurrency = amino.DefaultConcurrency o.Resiliency = amino.DefaultResiliency o.LookupCheckConcurrency = 256 o.OptimisticProvideJobsPoolSize = 60 return nil }
Defaults 是默认的DHT选项。此选项将自动添加到传递给DHT构造函数的任何选项之前
Functions ¶
func EmptyQueryFilter ¶
EmptyQueryFilter 空的查询过滤器 参数:
- _: interface{} DHT实例(未使用)
- ai: peer.AddrInfo 对等点地址信息(未使用)
返回值:
- bool 总是返回true
func EmptyRTFilter ¶
EmptyRTFilter 空的路由表过滤器 参数:
- _: interface{} DHT实例(未使用)
- p: peer.ID 对等点ID(未使用)
返回值:
- bool 总是返回true
Types ¶
type Config ¶
type Config struct {
Datastore ds.Batching
Validator record.Validator
ValidatorChanged bool // 如果为true,表示验证器已更改,不应使用默认值
Mode ModeOpt
ProtocolPrefix protocol.ID
V1ProtocolOverride protocol.ID
BucketSize int
Concurrency int
Resiliency int
MaxRecordAge time.Duration
EnableProviders bool
EnableValues bool
ProviderStore providers.ProviderStore
QueryPeerFilter QueryFilterFunc
LookupCheckConcurrency int
MsgSenderBuilder func(h host.Host, protos []protocol.ID) pb.MessageSenderWithDisconnect
RoutingTable struct {
RefreshQueryTimeout time.Duration
RefreshInterval time.Duration
AutoRefresh bool
LatencyTolerance time.Duration
CheckInterval time.Duration
PeerFilter RouteTableFilterFunc
DiversityFilter peerdiversity.PeerIPGroupFilter
}
BootstrapPeers func() []peer.AddrInfo
AddressFilter func([]ma.Multiaddr) []ma.Multiaddr
// 测试特定的配置选项
DisableFixLowPeers bool
TestAddressUpdateProcessing bool
EnableOptimisticProvide bool
OptimisticProvideJobsPoolSize int
}
Config 是构造DHT时可以使用的所有选项的结构
func (*Config) ApplyFallbacks ¶
ApplyFallbacks 设置在配置创建期间无法应用的默认值,因为它们依赖于其他配置参数(例如optA默认为optB的2倍)和/或主机 参数:
- h: host.Host 主机实例
返回值:
- error 错误信息
type QueryFilterFunc ¶
QueryFilterFunc 是在查询时考虑要拨号的对等点时应用的过滤器 参数:
- dht: interface{} DHT实例
- ai: peer.AddrInfo 对等点地址信息
返回值:
- bool 是否允许该对等点
type QuorumOptionKey ¶
type QuorumOptionKey struct{}
type RouteTableFilterFunc ¶
RouteTableFilterFunc 是在考虑要保留在本地路由表中的连接时应用的过滤器 参数:
- dht: interface{} DHT实例
- p: peer.ID 对等点ID
返回值:
- bool 是否保留该连接
Click to show internal directories.
Click to hide internal directories.