go-spacemesh
go-spacemesh copied to clipboard
atxs: refactor atx type to avoid struct update
atx struct is updated in two cases:
- when received to compute id
- and will be updated after it was verified, to set correct base_tick_height and tick_count https://github.com/spacemeshos/go-spacemesh/pull/3399
any mistakes can be catched only during runtime and only if we have sufficient test coverage. moreover this is prone to concurrency issues, if fields that are updated will be read concurrently in the other goroutine.
instead we should treat data as data and use different struct when we need more data. for example after atx is verified and verified data is required downstream we should use type:
type VerifiedAtx struct {
Atx
BaseTickHeight uint64
TickCount uint64
}