github.com/onflow/flow-go@v0.33.17/model/flow/entity.go (about) 1 package flow 2 3 // Entity defines how flow entities should be defined 4 // Entities are flat data structures holding multiple data fields. 5 // Entities don't include nested entities, they only include pointers to 6 // other entities. For example, they keep a slice of entity commits instead 7 // of keeping a slice of entity object itself. This simplifies storage, signature and validation 8 // of entities. 9 type Entity interface { 10 11 // ID returns a unique id for this entity using a hash of the immutable 12 // fields of the entity. 13 ID() Identifier 14 15 // Checksum returns a unique checksum for the entity, including the mutable 16 // data such as signatures. 17 Checksum() Identifier 18 } 19 20 func EntitiesToIDs[T Entity](entities []T) []Identifier { 21 ids := make([]Identifier, 0, len(entities)) 22 for _, entity := range entities { 23 ids = append(ids, entity.ID()) 24 } 25 return ids 26 }