From 7c5ecb3a924cc72656e0a62728a87c6200adadc0 Mon Sep 17 00:00:00 2001 From: free will <2647778488@qq.com> Date: Wed, 6 Jul 2022 15:14:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=89=8D=E7=BC=80=E8=A1=A8?= =?UTF-8?q?=E5=8F=8ARTPE=E4=B8=AD=E7=9A=84map=E5=BF=85=E9=A1=BB=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E5=88=86=E9=85=8D=E5=86=85=E5=AD=98=E5=90=8E?= =?UTF-8?q?=E6=89=8D=E8=83=BD=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 22 +++++++++++++++++++--- go.sum | 1 - route/NamePrefixTable.go | 2 ++ route/RoutingTablePoolEntry.go | 6 ++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 85c3c2e..e53019b 100644 --- a/go.mod +++ b/go.mod @@ -6,12 +6,28 @@ require ( //github.com/rakanalh/scheduler v0.1 github.com/go-co-op/gocron v1.13.0 github.com/liyue201/gostl v1.0.1 - github.com/smartystreets/goconvey v1.7.2 // indirect - github.com/tidwall/btree v1.2.1 // indirect github.com/tidwall/buntdb v1.2.9 - github.com/tidwall/gjson v1.14.0 // indirect gopkg.in/ini.v1 v1.62.0 minlib v0.0.0 ) +require ( + github.com/klauspost/cpuid/v2 v2.0.9 // indirect + github.com/mutecomm/go-sqlcipher/v4 v4.4.2 // indirect + github.com/robfig/cron/v3 v3.0.1 // indirect + github.com/sirupsen/logrus v1.8.1 // indirect + github.com/smartystreets/goconvey v1.7.2 // indirect + github.com/tidwall/btree v1.2.1 // indirect + github.com/tidwall/gjson v1.14.0 // indirect + github.com/tidwall/grect v0.1.4 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/tidwall/rtred v0.1.2 // indirect + github.com/tidwall/tinyqueue v0.1.1 // indirect + github.com/tylertreat/BoomFilters v0.0.0-20210315201527-1a82519a3e43 // indirect + github.com/zeebo/xxh3 v1.0.1 // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect +) + replace minlib v0.0.0 => ../minlib diff --git a/go.sum b/go.sum index 4583ce7..d68ad99 100644 --- a/go.sum +++ b/go.sum @@ -78,4 +78,3 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/route/NamePrefixTable.go b/route/NamePrefixTable.go index e639fb0..fbcb221 100644 --- a/route/NamePrefixTable.go +++ b/route/NamePrefixTable.go @@ -50,6 +50,8 @@ type NamePrefixTable struct { func (t *NamePrefixTable) Init(ownRouterName *component.Identifier, routingTable *RoutingTable, afterRoutingChangeSignal *utils.Signal, afterLsdbModifiedSignal *utils.Signal) { + // 初始化数据结构 + t.m_rtpool = make(map[string]*RoutingTablePoolEntry) // 赋值变量 t.m_ownRouterName = ownRouterName t.m_routingTable = routingTable diff --git a/route/RoutingTablePoolEntry.go b/route/RoutingTablePoolEntry.go index 371aaf0..50734b2 100644 --- a/route/RoutingTablePoolEntry.go +++ b/route/RoutingTablePoolEntry.go @@ -53,6 +53,8 @@ func (pe *RoutingTablePoolEntry) ToString() string { func (pe *RoutingTablePoolEntry) Init(dest *component.Identifier) { pe.m_destination = dest pe.m_useCount = 1 + // map 初始化 + pe.NamePrefixTableEntries = make(map[string]*NamePrefixTableEntry) } // @@ -66,6 +68,8 @@ func (pe *RoutingTablePoolEntry) InitRTE(rte *RoutingTableEntry, useCount uint64 pe.m_destination = rte.m_destination pe.nextHops = rte.GetNextHops() pe.m_useCount = useCount + // map 初始化 + pe.NamePrefixTableEntries = make(map[string]*NamePrefixTableEntry) } // @@ -78,6 +82,8 @@ func (pe *RoutingTablePoolEntry) InitRTE(rte *RoutingTableEntry, useCount uint64 func (pe *RoutingTablePoolEntry) InitDest(dest *component.Identifier, useCount uint64) { pe.m_destination = dest pe.m_useCount = useCount + // map 初始化 + pe.NamePrefixTableEntries = make(map[string]*NamePrefixTableEntry) } //