From 1333352848aee109b7b72a6e259fc747779bd9d2 Mon Sep 17 00:00:00 2001 From: Halimao <1065621723@qq.com> Date: Mon, 1 Jul 2024 09:39:17 +0800 Subject: [PATCH] doc: add explanation doc for `fromExtWitness` --- core/stateless/encoding.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/stateless/encoding.go b/core/stateless/encoding.go index bf24ea513b..2b055466f6 100644 --- a/core/stateless/encoding.go +++ b/core/stateless/encoding.go @@ -51,6 +51,9 @@ func (w *Witness) toExtWitness() *extWitness { } // fromExtWitness converts the consensus witness format into our internal one. +// This function is only used in decoding an already-constructed witness object +// which will be received from a remote source in the future. Although this does +// modify `w.State`, the lock is unnecessary here. func (w *Witness) fromExtWitness(ext *extWitness) error { w.Block, w.Headers = ext.Block, ext.Headers @@ -58,8 +61,6 @@ func (w *Witness) fromExtWitness(ext *extWitness) error { for _, code := range ext.Codes { w.Codes[string(code)] = struct{}{} } - w.lock.Lock() - defer w.lock.Unlock() w.State = make(map[string]struct{}, len(ext.State)) for _, node := range ext.State { w.State[string(node)] = struct{}{}