diff --git a/fetcher.go b/fetcher.go index 728fd37..b7b3c80 100644 --- a/fetcher.go +++ b/fetcher.go @@ -55,7 +55,11 @@ func (p *pool) fetchResource(ctx context.Context, from *Node, resource string, m return ce } - ctx, span := spanTrace(ctx, "Pool.FetchResource", trace.WithAttributes(attribute.String("from", from.URL), attribute.String("of", resource), attribute.String("mime", mime))) + p.ActiveNodes.lk.RLock() + isCore := p.ActiveNodes.IsCore(from) + p.ActiveNodes.lk.RUnlock() + + ctx, span := spanTrace(ctx, "Pool.FetchResource", trace.WithAttributes(attribute.String("from", from.URL), attribute.String("of", resource), attribute.String("mime", mime), attribute.Bool("core", isCore))) defer span.End() requestId := uuid.NewString() diff --git a/node.go b/node.go index 8936ec9..f21f1b2 100644 --- a/node.go +++ b/node.go @@ -17,6 +17,7 @@ const ( type Node struct { URL string ComplianceCid string + Core bool PredictedLatency float64 PredictedThroughput float64 @@ -31,6 +32,7 @@ func NewNode(info state.NodeInfo) *Node { return &Node{ URL: info.IP, ComplianceCid: info.ComplianceCid, + Core: info.Core, Samples: queue.New[NodeSample](), } } diff --git a/node_ring.go b/node_ring.go index dfe6b31..eafbbf3 100644 --- a/node_ring.go +++ b/node_ring.go @@ -137,6 +137,17 @@ func (nr *NodeRing) Contains(n *Node) bool { return ok } +func (nr *NodeRing) IsCore(n *Node) bool { + nr.lk.RLock() + defer nr.lk.RUnlock() + + nd, ok := nr.Nodes[n.URL] + if !ok { + return false + } + return nd.Core +} + func (nr *NodeRing) GetNodes(key string, number int) ([]*Node, error) { nr.lk.RLock() defer nr.lk.RUnlock()