copy actor object when iterating over actors

This is a pretty big footgun.
This commit is contained in:
Steven Allen 2020-09-22 11:09:41 -07:00
parent 5314ba8c6d
commit ab070f2ebe

View File

@ -385,6 +385,7 @@ func (st *StateTree) MutateActor(addr address.Address, f func(*types.Actor) erro
func (st *StateTree) ForEach(f func(address.Address, *types.Actor) error) error {
var act types.Actor
return st.root.ForEach(&act, func(k string) error {
act := act // copy
addr, err := address.NewFromBytes([]byte(k))
if err != nil {
return xerrors.Errorf("invalid address (%x) found in state tree key: %w", []byte(k), err)