github.com/koko1123/flow-go-1@v0.29.6/module/mempool/queue/internal/messageEntity.go (about)

     1  package internal
     2  
     3  import (
     4  	"github.com/koko1123/flow-go-1/engine"
     5  	"github.com/koko1123/flow-go-1/model/flow"
     6  )
     7  
     8  // MessageEntity is an internal data structure for storing messages in HeroQueue.
     9  type MessageEntity struct {
    10  	Msg engine.Message
    11  	id  flow.Identifier
    12  }
    13  
    14  var _ flow.Entity = (*MessageEntity)(nil)
    15  
    16  func NewMessageEntity(msg *engine.Message) MessageEntity {
    17  	return MessageEntity{
    18  		Msg: *msg,
    19  		id:  identifierOfMessage(msg),
    20  	}
    21  }
    22  
    23  func (m MessageEntity) ID() flow.Identifier {
    24  	return m.id
    25  }
    26  
    27  func (m MessageEntity) Checksum() flow.Identifier {
    28  	return m.id
    29  }
    30  
    31  func identifierOfMessage(msg *engine.Message) flow.Identifier {
    32  	return flow.MakeID(msg)
    33  }