mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
doc: add explanation doc for fromExtWitness
This commit is contained in:
parent
dac70fe3a4
commit
1333352848
1 changed files with 3 additions and 2 deletions
|
|
@ -51,6 +51,9 @@ func (w *Witness) toExtWitness() *extWitness {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fromExtWitness converts the consensus witness format into our internal one.
|
// 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 {
|
func (w *Witness) fromExtWitness(ext *extWitness) error {
|
||||||
w.Block, w.Headers = ext.Block, ext.Headers
|
w.Block, w.Headers = ext.Block, ext.Headers
|
||||||
|
|
||||||
|
|
@ -58,8 +61,6 @@ func (w *Witness) fromExtWitness(ext *extWitness) error {
|
||||||
for _, code := range ext.Codes {
|
for _, code := range ext.Codes {
|
||||||
w.Codes[string(code)] = struct{}{}
|
w.Codes[string(code)] = struct{}{}
|
||||||
}
|
}
|
||||||
w.lock.Lock()
|
|
||||||
defer w.lock.Unlock()
|
|
||||||
w.State = make(map[string]struct{}, len(ext.State))
|
w.State = make(map[string]struct{}, len(ext.State))
|
||||||
for _, node := range ext.State {
|
for _, node := range ext.State {
|
||||||
w.State[string(node)] = struct{}{}
|
w.State[string(node)] = struct{}{}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue