Documentation ¶
Index ¶
- func FileExists(name string) bool
- func GetCurrentTime() time.Time
- func GetTimeMilliseconds() int64
- type CircularBuffer
- type DiskDatabase
- func (ddb *DiskDatabase) Delete(msgID string)
- func (ddb *DiskDatabase) MessageExist(msgID string) bool
- func (ddb *DiskDatabase) MessageIDs() []string
- func (ddb *DiskDatabase) Read(msgID string, msgInfo *MessageInfo) error
- func (ddb *DiskDatabase) TotalMessages() int
- func (ddb *DiskDatabase) UpdateValue(msg *ReceivedMessage) error
- func (ddb *DiskDatabase) Write(msgInfo *MessageInfo) error
- type MessageBuffer
- func (mbf *MessageBuffer) AddNewMessage(msg *ReceivedMessage) error
- func (mbf *MessageBuffer) Delete() error
- func (mbf *MessageBuffer) Export(msgID string) error
- func (mbf *MessageBuffer) GetMessageInfo(msgID string, mi *MessageInfo) error
- func (mbf *MessageBuffer) UpdateMessageInfo(msg *ReceivedMessage) error
- type MessageDatabase
- func (msgdb *MessageDatabase) AddMessage(msg *ReceivedMessage) (bool, error)
- func (msgdb *MessageDatabase) CheckIfSeen(msgID string) bool
- func (msgdb *MessageDatabase) DBExportPath() string
- func (msgdb *MessageDatabase) GetMessageIDsFromSlot(slot beacon.Slot) []string
- func (msgdb *MessageDatabase) GetMessageIDsFromValidator(validatorIndex beacon.ValidatorIndex) []string
- func (msgdb *MessageDatabase) GetMessageInfo(msgID string, msgInfo *MessageInfo) error
- func (msgdb *MessageDatabase) GetSlots() []beacon.Slot
- func (msgdb *MessageDatabase) GetValidators() []beacon.ValidatorIndex
- func (c *MessageDatabase) SetSpec(spec *beacon.Spec) error
- type MessageInfo
- func (mi *MessageInfo) AddNewMsgSender(msg *ReceivedMessage)
- func (mi *MessageInfo) GetContent() interface{}
- func (mi *MessageInfo) GetFirstArrivalTime() time.Time
- func (mi *MessageInfo) GetFirstSender() peer.ID
- func (mi *MessageInfo) GetGotFromList() map[peer.ID]time.Time
- func (mi *MessageInfo) GetMessageID() string
- func (mi *MessageInfo) GetMessageType() string
- func (mi *MessageInfo) GetProposerIndex() beacon.ValidatorIndex
- func (mi *MessageInfo) GetSlot() beacon.Slot
- type ReceivedMessage
- func (rm *ReceivedMessage) GetArrivalTime() time.Time
- func (rm *ReceivedMessage) GetContent() interface{}
- func (rm *ReceivedMessage) GetMessageID() string
- func (rm *ReceivedMessage) GetMessageType() string
- func (rm *ReceivedMessage) GetSender() peer.ID
- func (rm *ReceivedMessage) GetSlot() beacon.Slot
- func (rm *ReceivedMessage) GetValidatorIndex() beacon.ValidatorIndex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶
Exists reports whether the named file or directory exists.
func GetCurrentTime ¶
func GetTimeMilliseconds ¶
func GetTimeMilliseconds() int64
Types ¶
type CircularBuffer ¶
Definition of the struck that will contain the Circular Buffers for the messages received on the GossipSub keeping the last message IDs (The buffer is done as a cache memory for the las seen msgs)
func NewCircularBuffer ¶
func NewCircularBuffer(messageLimit int) *CircularBuffer
Gen and Initialize a Circular Buffer
func (*CircularBuffer) MsgOnBuffer ¶
func (c *CircularBuffer) MsgOnBuffer(id string) bool
Check if the root is already at the circular buffer GossipSub already has a cache of previously received messages, but since we pretend to change that, we might not keep more than once the same block With this we achieve a proper message count, but we just save it once
func (*CircularBuffer) Write ¶
func (c *CircularBuffer) Write(id string) (bool, interface{})
Write new root on the Circular Buffer Will return true and the root value of the oldest message if the circular was Full Will return False if the buffer is not full
type DiskDatabase ¶
type DiskDatabase struct {
Path string
}
currently the msgInfo will be exported as json
func NewDiskDatabase ¶
func NewDiskDatabase(path string) *DiskDatabase
func (*DiskDatabase) MessageExist ¶
func (ddb *DiskDatabase) MessageExist(msgID string) bool
func (*DiskDatabase) MessageIDs ¶
func (ddb *DiskDatabase) MessageIDs() []string
func (*DiskDatabase) Read ¶
func (ddb *DiskDatabase) Read(msgID string, msgInfo *MessageInfo) error
func (*DiskDatabase) TotalMessages ¶
func (ddb *DiskDatabase) TotalMessages() int
func (*DiskDatabase) UpdateValue ¶
func (ddb *DiskDatabase) UpdateValue(msg *ReceivedMessage) error
right now only supports to add a new sender and the arrival time
func (*DiskDatabase) Write ¶
func (ddb *DiskDatabase) Write(msgInfo *MessageInfo) error
type MessageBuffer ¶
type MessageBuffer struct { MessageList sync.Map // map[messageID(string)]ReceivedMessage Buffer *CircularBuffer DiskDatabase *DiskDatabase // Path for the phisical DB of messages }
Intended to be like a cache of received messages TODO: Change the Hard-coded Mainnet config from the TopicDB to here (so that every topic can have its own Spec)
func NewMessageBuffer ¶
func NewMessageBuffer(msgLimit int, diskDBPath string) *MessageBuffer
func (*MessageBuffer) AddNewMessage ¶
func (mbf *MessageBuffer) AddNewMessage(msg *ReceivedMessage) error
func (*MessageBuffer) Delete ¶
func (mbf *MessageBuffer) Delete() error
Delete the MessageInfo of a given Msg, currently not needed
func (*MessageBuffer) Export ¶
func (mbf *MessageBuffer) Export(msgID string) error
could be used to export the MessageInfo tha was in the Circular Buffer
func (*MessageBuffer) GetMessageInfo ¶
func (mbf *MessageBuffer) GetMessageInfo(msgID string, mi *MessageInfo) error
func (*MessageBuffer) UpdateMessageInfo ¶
func (mbf *MessageBuffer) UpdateMessageInfo(msg *ReceivedMessage) error
Update the message info of a message that we already sawfmt.
type MessageDatabase ¶
type MessageDatabase struct { MessageBuffer *MessageBuffer // This seen message list might be a bit too much to keep it in memory at one point, // TODO: -Find a cleaner way to have it MessageSeenList map[string]bool // messageID - true ValidatorMessages map[beacon.ValidatorIndex][]string // ValidatorIndex - messageID SlotMessages map[beacon.Slot][]string // slot - messageID Spec *beacon.Spec // Currently only the Beacon Blocks can be supported BlockNotChan chan *beacon.SignedBeaconBlock // AttestNotChan chan *beacon.Attestation | beacon.PendingAttestation DiskDBPath string sync.RWMutex }
Circular databases for the Received messages
func NewMessageDatabase ¶
func NewMessageDatabase(spec *beacon.Spec, msgLimit int, diskDBPath string) *MessageDatabase
func (*MessageDatabase) AddMessage ¶
func (msgdb *MessageDatabase) AddMessage(msg *ReceivedMessage) (bool, error)
Returns if the message was already on the DB (to see if we need to notify of a new message)
func (*MessageDatabase) CheckIfSeen ¶
func (msgdb *MessageDatabase) CheckIfSeen(msgID string) bool
Return True if the message was seen before
func (*MessageDatabase) DBExportPath ¶
func (msgdb *MessageDatabase) DBExportPath() string
func (*MessageDatabase) GetMessageIDsFromSlot ¶
func (msgdb *MessageDatabase) GetMessageIDsFromSlot(slot beacon.Slot) []string
if empty, returns an empty array
func (*MessageDatabase) GetMessageIDsFromValidator ¶
func (msgdb *MessageDatabase) GetMessageIDsFromValidator(validatorIndex beacon.ValidatorIndex) []string
func (*MessageDatabase) GetMessageInfo ¶
func (msgdb *MessageDatabase) GetMessageInfo(msgID string, msgInfo *MessageInfo) error
func (*MessageDatabase) GetSlots ¶
func (msgdb *MessageDatabase) GetSlots() []beacon.Slot
func (*MessageDatabase) GetValidators ¶
func (msgdb *MessageDatabase) GetValidators() []beacon.ValidatorIndex
func (*MessageDatabase) SetSpec ¶
func (c *MessageDatabase) SetSpec(spec *beacon.Spec) error
TODO: This spec will be hard-coded to the Mainnet Specifications (All the topics will use the same Spec) Configure the Specifications for the Received Gossip Messages (Needed to Serialize and Deserialize the Received messages)
type MessageInfo ¶
type MessageInfo struct { MessageID string MessageType string // block / attestation Slot beacon.Slot ValidatorIndex beacon.ValidatorIndex GotFromList map[peer.ID]time.Time FirstSender peer.ID FirstArrivalTime time.Time // currently also de content is getting recorded, let's see later Content interface{} }
func NewMessageInfo ¶
func NewMessageInfo(msg *ReceivedMessage) *MessageInfo
func (*MessageInfo) AddNewMsgSender ¶
func (mi *MessageInfo) AddNewMsgSender(msg *ReceivedMessage)
func (*MessageInfo) GetContent ¶
func (mi *MessageInfo) GetContent() interface{}
func (*MessageInfo) GetFirstArrivalTime ¶
func (mi *MessageInfo) GetFirstArrivalTime() time.Time
func (*MessageInfo) GetFirstSender ¶
func (mi *MessageInfo) GetFirstSender() peer.ID
func (*MessageInfo) GetGotFromList ¶
func (mi *MessageInfo) GetGotFromList() map[peer.ID]time.Time
func (*MessageInfo) GetMessageID ¶
func (mi *MessageInfo) GetMessageID() string
func (*MessageInfo) GetMessageType ¶
func (mi *MessageInfo) GetMessageType() string
func (*MessageInfo) GetProposerIndex ¶
func (mi *MessageInfo) GetProposerIndex() beacon.ValidatorIndex
func (*MessageInfo) GetSlot ¶
func (mi *MessageInfo) GetSlot() beacon.Slot
type ReceivedMessage ¶
type ReceivedMessage struct { MessageID string MessageType string // block / attestation Slot beacon.Slot ValidatorIndex beacon.ValidatorIndex Sender peer.ID ArrivalTime time.Time // currently also de content is getting recorded, let's see later Content interface{} }
func (*ReceivedMessage) GetArrivalTime ¶
func (rm *ReceivedMessage) GetArrivalTime() time.Time
func (*ReceivedMessage) GetContent ¶
func (rm *ReceivedMessage) GetContent() interface{}
func (*ReceivedMessage) GetMessageID ¶
func (rm *ReceivedMessage) GetMessageID() string
func (*ReceivedMessage) GetMessageType ¶
func (rm *ReceivedMessage) GetMessageType() string
func (*ReceivedMessage) GetSender ¶
func (rm *ReceivedMessage) GetSender() peer.ID
func (*ReceivedMessage) GetSlot ¶
func (rm *ReceivedMessage) GetSlot() beacon.Slot
func (*ReceivedMessage) GetValidatorIndex ¶
func (rm *ReceivedMessage) GetValidatorIndex() beacon.ValidatorIndex