diff --git a/go.mod b/go.mod index 33596a1fb..2bc475856 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/iotaledger/hive.go/kvstore v0.0.0-20240223142044-12ffcb37c413 github.com/iotaledger/hive.go/lo v0.0.0-20240223142044-12ffcb37c413 github.com/iotaledger/hive.go/log v0.0.0-20240223142044-12ffcb37c413 - github.com/iotaledger/hive.go/runtime v0.0.0-20240223142044-12ffcb37c413 + github.com/iotaledger/hive.go/runtime v0.0.0-20240301015124-eea9bb54a256 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240223142044-12ffcb37c413 github.com/iotaledger/hive.go/stringify v0.0.0-20240223142044-12ffcb37c413 github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240216141618-d7dfe94bdc1e diff --git a/go.sum b/go.sum index 3632f5de7..83dd05a45 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,8 @@ github.com/iotaledger/hive.go/log v0.0.0-20240223142044-12ffcb37c413 h1:4xKFtHoO github.com/iotaledger/hive.go/log v0.0.0-20240223142044-12ffcb37c413/go.mod h1:H5tmswUbT3o5+QiM6UPtBv7VnPf+lJtlantgpp2lzUI= github.com/iotaledger/hive.go/runtime v0.0.0-20240223142044-12ffcb37c413 h1:7O3oSoXlwV5L3/+kt/a1MN3Kwb5oXaaSZaa+aabh7BM= github.com/iotaledger/hive.go/runtime v0.0.0-20240223142044-12ffcb37c413/go.mod h1:pueoYXud+HmTY2x9j/S6+ZX3M5ZyENFKPDrx3EtcwWs= +github.com/iotaledger/hive.go/runtime v0.0.0-20240301015124-eea9bb54a256 h1:x5h3XFa3Iuy7Fy3JjWUsqZym6WI0X9edRVhEoDQ9JTc= +github.com/iotaledger/hive.go/runtime v0.0.0-20240301015124-eea9bb54a256/go.mod h1:pueoYXud+HmTY2x9j/S6+ZX3M5ZyENFKPDrx3EtcwWs= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240223142044-12ffcb37c413 h1:tQW0K9Ogyfgm3V0wYhRPChOYgrADGlRWF6P4gMY8Zbg= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240223142044-12ffcb37c413/go.mod h1:NK05G4PxwZF1m4jGANJWLhAQ2hP1Nt0L8mgCTFLsSCw= github.com/iotaledger/hive.go/stringify v0.0.0-20240223142044-12ffcb37c413 h1:QCidFFczZH9NEJTWm0ZzZKMaQ0XUxYyU00dpaH+skqs= diff --git a/pkg/protocol/inspection.go b/pkg/protocol/inspection.go new file mode 100644 index 000000000..c59e59df5 --- /dev/null +++ b/pkg/protocol/inspection.go @@ -0,0 +1,64 @@ +package protocol + +import ( + "github.com/iotaledger/hive.go/runtime/inspection" + "github.com/iotaledger/iota-core/pkg/core/promise" + iotago "github.com/iotaledger/iota.go/v4" +) + +// Inspect inspects the protocol and its subcomponents. +func (p *Protocol) Inspect(session ...inspection.Session) inspection.InspectedObject { + return inspection.NewInspectedObject(p, func(protocol inspection.InspectedObject) { + protocol.Add("Commitments", p.Commitments) + protocol.Add("Chains", p.Chains) + }, session...) +} + +// Inspect inspects the Commitments and its subcomponents. +func (c *Commitments) Inspect(session ...inspection.Session) inspection.InspectedObject { + return inspection.NewInspectedObject(c, func(commitments inspection.InspectedObject) { + commitments.Add("Root", c.Root.Get()) + commitments.Add("Set", c.Set, inspection.SetInspector[*Commitment](c.Set, func(inspectedSet inspection.InspectedObject, element *Commitment) { + inspectedSet.Add(element.LogName(), element) + })) + commitments.Add("cachedRequests", c.cachedRequests, inspection.MapInspector(c.cachedRequests, func(cachedRequests inspection.InspectedObject, commitmentID iotago.CommitmentID, cachedRequest *promise.Promise[*Commitment]) { + cachedRequests.Add(commitmentID.String(), cachedRequest.Result()) + })) + }, session...) +} + +// Inspect inspects the Commitment and its subcomponents. +func (c *Commitment) Inspect(session ...inspection.Session) inspection.InspectedObject { + return inspection.NewInspectedObject(c, func(commitment inspection.InspectedObject) { + commitment.Add("Parent", c.Parent.Get()) + commitment.Add("MainChild", c.MainChild.Get()) + commitment.Add("Chain", c.Chain.Get()) + commitment.Add("Children", c.Children, inspection.SetInspector[*Commitment](c.Children, func(children inspection.InspectedObject, child *Commitment) { + children.Add(child.LogName(), child) + })) + }, session...) +} + +// Inspect inspects the Chains and its subcomponents. +func (c *Chains) Inspect(session ...inspection.Session) inspection.InspectedObject { + return inspection.NewInspectedObject(c, func(chains inspection.InspectedObject) { + chains.Add("Main", c.Main.Get()) + chains.Add("HeaviestClaimedCandidate", c.HeaviestClaimedCandidate.Get()) + chains.Add("HeaviestAttestedCandidate", c.HeaviestAttestedCandidate.Get()) + chains.Add("HeaviestAttestedCandidate", c.HeaviestAttestedCandidate.Get()) + chains.Add("Set", c.Set, inspection.SetInspector[*Chain](c.Set, func(set inspection.InspectedObject, chain *Chain) { + set.Add(chain.LogName(), chain) + })) + }, session...) +} + +// Inspect inspects the Chain and its subcomponents. +func (c *Chain) Inspect(session ...inspection.Session) inspection.InspectedObject { + return inspection.NewInspectedObject(c, func(chain inspection.InspectedObject) { + chain.Add("ForkingPoint", c.ForkingPoint.Get()) + chain.Add("ParentChain", c.ParentChain.Get()) + chain.Add("ChildChains", c.ChildChains, inspection.SetInspector[*Chain](c.ChildChains, func(childChains inspection.InspectedObject, chain *Chain) { + childChains.Add(chain.LogName(), chain) + })) + }, session...) +} diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 8e0daa864..3e0d61055 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -66,7 +66,7 @@ require ( github.com/iotaledger/hive.go/kvstore v0.0.0-20240223142044-12ffcb37c413 // indirect github.com/iotaledger/hive.go/lo v0.0.0-20240223142044-12ffcb37c413 // indirect github.com/iotaledger/hive.go/log v0.0.0-20240223142044-12ffcb37c413 // indirect - github.com/iotaledger/hive.go/runtime v0.0.0-20240223142044-12ffcb37c413 // indirect + github.com/iotaledger/hive.go/runtime v0.0.0-20240301015124-eea9bb54a256 // indirect github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240223142044-12ffcb37c413 // indirect github.com/iotaledger/hive.go/stringify v0.0.0-20240223142044-12ffcb37c413 // indirect github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240216141618-d7dfe94bdc1e // indirect diff --git a/tools/gendoc/go.sum b/tools/gendoc/go.sum index 5e52a016d..f43082b79 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -305,6 +305,7 @@ github.com/iotaledger/hive.go/log v0.0.0-20240223142044-12ffcb37c413 h1:4xKFtHoO github.com/iotaledger/hive.go/log v0.0.0-20240223142044-12ffcb37c413/go.mod h1:H5tmswUbT3o5+QiM6UPtBv7VnPf+lJtlantgpp2lzUI= github.com/iotaledger/hive.go/runtime v0.0.0-20240223142044-12ffcb37c413 h1:7O3oSoXlwV5L3/+kt/a1MN3Kwb5oXaaSZaa+aabh7BM= github.com/iotaledger/hive.go/runtime v0.0.0-20240223142044-12ffcb37c413/go.mod h1:pueoYXud+HmTY2x9j/S6+ZX3M5ZyENFKPDrx3EtcwWs= +github.com/iotaledger/hive.go/runtime v0.0.0-20240301015124-eea9bb54a256/go.mod h1:pueoYXud+HmTY2x9j/S6+ZX3M5ZyENFKPDrx3EtcwWs= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240223142044-12ffcb37c413 h1:tQW0K9Ogyfgm3V0wYhRPChOYgrADGlRWF6P4gMY8Zbg= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240223142044-12ffcb37c413/go.mod h1:NK05G4PxwZF1m4jGANJWLhAQ2hP1Nt0L8mgCTFLsSCw= github.com/iotaledger/hive.go/stringify v0.0.0-20240223142044-12ffcb37c413 h1:QCidFFczZH9NEJTWm0ZzZKMaQ0XUxYyU00dpaH+skqs=