github.com/ava-labs/avalanchego@v1.11.11/network/p2p/gossip/gossipable.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package gossip 5 6 import "github.com/ava-labs/avalanchego/ids" 7 8 // Gossipable is an item that can be gossiped across the network 9 type Gossipable interface { 10 GossipID() ids.ID 11 } 12 13 // Marshaller handles parsing logic for a concrete Gossipable type 14 type Marshaller[T Gossipable] interface { 15 MarshalGossip(T) ([]byte, error) 16 UnmarshalGossip([]byte) (T, error) 17 } 18 19 // Set holds a set of known Gossipable items 20 type Set[T Gossipable] interface { 21 // Add adds a Gossipable to the set. Returns an error if gossipable was not 22 // added. 23 Add(gossipable T) error 24 // Has returns true if the gossipable is in the set. 25 Has(gossipID ids.ID) bool 26 // Iterate iterates over elements until [f] returns false 27 Iterate(f func(gossipable T) bool) 28 // GetFilter returns the byte representation of bloom filter and its 29 // corresponding salt. 30 GetFilter() (bloom []byte, salt []byte) 31 }