github.com/status-im/status-go@v1.1.0/waku/common/events.go (about)

     1  // Copyright 2019 The Waku Library Authors.
     2  //
     3  // The Waku library is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Lesser General Public License as published by
     5  // the Free Software Foundation, either version 3 of the License, or
     6  // (at your option) any later version.
     7  //
     8  // The Waku library is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty off
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    11  // GNU Lesser General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Lesser General Public License
    14  // along with the Waku library. If not, see <http://www.gnu.org/licenses/>.
    15  //
    16  // This software uses the go-ethereum library, which is licensed
    17  // under the GNU Lesser General Public Library, version 3 or any later.
    18  
    19  package common
    20  
    21  import (
    22  	"github.com/ethereum/go-ethereum/common"
    23  	"github.com/ethereum/go-ethereum/p2p/enode"
    24  )
    25  
    26  // EventType used to define known waku events.
    27  type EventType string
    28  
    29  const (
    30  	// EventEnvelopeSent fires when envelope was sent to a peer.
    31  	EventEnvelopeSent EventType = "envelope.sent"
    32  
    33  	// EventEnvelopeExpired fires when envelop expired
    34  	EventEnvelopeExpired EventType = "envelope.expired"
    35  
    36  	// EventEnvelopeReceived is sent once envelope was received from a peer.
    37  	// EventEnvelopeReceived must be sent to the feed even if envelope was previously in the cache.
    38  	// And event, ideally, should contain information about peer that sent envelope to us.
    39  	EventEnvelopeReceived EventType = "envelope.received"
    40  
    41  	// EventBatchAcknowledged is sent when batch of envelopes was acknowledged by a peer.
    42  	EventBatchAcknowledged EventType = "batch.acknowledged"
    43  
    44  	// EventEnvelopeAvailable fires when envelop is available for filters
    45  	EventEnvelopeAvailable EventType = "envelope.available"
    46  
    47  	// EventMailServerRequestSent fires when such request is sent.
    48  	EventMailServerRequestSent EventType = "mailserver.request.sent"
    49  
    50  	// EventMailServerRequestCompleted fires after mailserver sends all the requested messages
    51  	EventMailServerRequestCompleted EventType = "mailserver.request.completed"
    52  
    53  	// EventMailServerRequestExpired fires after mailserver the request TTL ends.
    54  	// This event is independent and concurrent to EventMailServerRequestCompleted.
    55  	// Request should be considered as expired only if expiry event was received first.
    56  	EventMailServerRequestExpired EventType = "mailserver.request.expired"
    57  
    58  	// EventMailServerEnvelopeArchived fires after an envelope has been archived
    59  	EventMailServerEnvelopeArchived EventType = "mailserver.envelope.archived"
    60  
    61  	// EventMailServerSyncFinished fires when the sync of messages is finished.
    62  	EventMailServerSyncFinished EventType = "mailserver.sync.finished"
    63  )
    64  
    65  // EnvelopeEvent represents an envelope event.
    66  type EnvelopeEvent struct {
    67  	Event EventType
    68  	Topic TopicType
    69  	Hash  common.Hash
    70  	Batch common.Hash
    71  	Peer  enode.ID
    72  	Data  interface{}
    73  }