From 3d947f585e6be54e256b6a4eeed6719c443438f0 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 5 Apr 2024 19:21:04 +0300 Subject: [PATCH] core: unexport generic native contract methods and events External users should use HF-specific methods and events. Signed-off-by: Anna Shaleva --- pkg/core/interop/context.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/core/interop/context.go b/pkg/core/interop/context.go index 47ce9c02c5..972b801c6a 100644 --- a/pkg/core/interop/context.go +++ b/pkg/core/interop/context.go @@ -193,12 +193,12 @@ type ContractMD struct { Hash util.Uint160 Name string // TODO: remove Methods and Events at all, build HF-specific MD in-place for every hardfork and cache them. - // Methods is a generic set of contract methods with activation hardforks. Any HF-dependent part of included methods + // methods is a generic set of contract methods with activation hardforks. Any HF-dependent part of included methods // (offsets, in particular) must not be used, there's a mdCache field for that. - Methods []MethodAndPrice - // Events is a generic set of contract events with activation hardforks. Any HF-dependent part of events must not be + methods []MethodAndPrice + // events is a generic set of contract events with activation hardforks. Any HF-dependent part of events must not be // used, there's a mdCache field for that. - Events []Event + events []Event // ActiveHFs is a map of hardforks that contract should react to. Contract update or deploy should be called for // active hardforks. This map is being initialized on contract creation and used as a read-only, hens, not protected // by mutex. @@ -264,14 +264,14 @@ func (c *ContractMD) buildHFSpecificMD(hf *config.Hardfork) *HFSpecificContractM // If not, then value from the previous hardfork may safely be reused. var ( - abiMethods = make([]manifest.Method, 0, len(c.Methods)) - methods = make([]HFSpecificMethodAndPrice, 0, len(c.Methods)) - abiEvents = make([]manifest.Event, 0, len(c.Events)) - events = make([]HFSpecificEvent, 0, len(c.Events)) + abiMethods = make([]manifest.Method, 0, len(c.methods)) + methods = make([]HFSpecificMethodAndPrice, 0, len(c.methods)) + abiEvents = make([]manifest.Event, 0, len(c.events)) + events = make([]HFSpecificEvent, 0, len(c.events)) ) w := io.NewBufBinWriter() - for i := range c.Methods { - m := c.Methods[i] + for i := range c.methods { + m := c.methods[i] if !(m.ActiveFrom == nil || (hf != nil && (*m.ActiveFrom).Cmp(*hf) <= 0)) { continue } @@ -292,8 +292,8 @@ func (c *ContractMD) buildHFSpecificMD(hf *config.Hardfork) *HFSpecificContractM if w.Err != nil { panic(fmt.Errorf("can't create native contract script: %w", w.Err)) } - for i := range c.Events { - e := c.Events[i] + for i := range c.events { + e := c.events[i] if !(e.ActiveFrom == nil || (hf != nil && (*e.ActiveFrom).Cmp(*hf) <= 0)) { continue } @@ -345,16 +345,16 @@ func (c *ContractMD) AddMethod(md *MethodAndPrice, desc *manifest.Method) { md.MD = desc desc.Safe = md.RequiredFlags&(callflag.All^callflag.ReadOnly) == 0 - index := sort.Search(len(c.Methods), func(i int) bool { - md := c.Methods[i].MD + index := sort.Search(len(c.methods), func(i int) bool { + md := c.methods[i].MD if md.Name != desc.Name { return md.Name >= desc.Name } return len(md.Parameters) > len(desc.Parameters) }) - c.Methods = append(c.Methods, MethodAndPrice{}) - copy(c.Methods[index+1:], c.Methods[index:]) - c.Methods[index] = *md + c.methods = append(c.methods, MethodAndPrice{}) + copy(c.methods[index+1:], c.methods[index:]) + c.methods[index] = *md if md.ActiveFrom != nil { c.ActiveHFs[*md.ActiveFrom] = struct{}{} @@ -395,7 +395,7 @@ func (c *HFSpecificContractMD) GetMethod(name string, paramCount int) (HFSpecifi // AddEvent adds a new event to the native contract. func (c *ContractMD) AddEvent(md Event) { - c.Events = append(c.Events, md) + c.events = append(c.events, md) if md.ActiveFrom != nil { c.ActiveHFs[*md.ActiveFrom] = struct{}{}