From 69b61716db234c47e217d538c083825c14bd9308 Mon Sep 17 00:00:00 2001 From: Gus Eggert Date: Mon, 18 Apr 2022 16:19:21 -0400 Subject: [PATCH] fix: decode peer IDs from limits.json (#19) --- p2p/host/resource-manager/limit_config.go | 2 +- p2p/host/resource-manager/limit_config_test.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/p2p/host/resource-manager/limit_config.go b/p2p/host/resource-manager/limit_config.go index 532f5a4d71..e02d9aae58 100644 --- a/p2p/host/resource-manager/limit_config.go +++ b/p2p/host/resource-manager/limit_config.go @@ -280,7 +280,7 @@ func NewLimiterFromJSON(in io.Reader, defaults DefaultLimitConfig) (*BasicLimite if len(cfg.Peer) > 0 { limiter.PeerLimits = make(map[peer.ID]Limit, len(cfg.Peer)) for p, cfgLimit := range cfg.Peer { - pid, err := peer.IDFromString(p) + pid, err := peer.Decode(p) if err != nil { return nil, fmt.Errorf("invalid peer ID %s: %w", p, err) } diff --git a/p2p/host/resource-manager/limit_config_test.json b/p2p/host/resource-manager/limit_config_test.json index b0571d86c1..a766a7f11a 100644 --- a/p2p/host/resource-manager/limit_config_test.json +++ b/p2p/host/resource-manager/limit_config_test.json @@ -51,5 +51,10 @@ }, "PeerDefault": { "Memory": 4096 + }, + "Peer": { + "12D3KooWPFH2Bx2tPfw6RLxN8k2wh47GRXgkt9yrAHU37zFwHWzS": { + "Memory": 4096 + } } }