Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultInfoResponseFiller = func(firstStreamableBlock *pbbstream.Block, resp *pbfirehose.InfoResponse, validate bool) error { resp.FirstStreamableBlockId = firstStreamableBlock.Id networksWithFirehose := networks.GetFirehoseRegistry() shortTypeURL := strings.TrimPrefix(firstStreamableBlock.Payload.TypeUrl, "type.googleapis.com/") for _, protocol := range networksWithFirehose { if protocol.Firehose.BlockType == shortTypeURL { if resp.BlockIdEncoding == pbfirehose.InfoResponse_BLOCK_ID_ENCODING_UNSET { resp.BlockIdEncoding = BlockIdEncodingForNetwork(protocol) } break } } if !validate { if resp.ChainName == "" { if chain := networksWithFirehose.FindByGenesisBlock(firstStreamableBlock.Number, firstStreamableBlock.Id); chain != nil { resp.ChainName = chain.ID if len(resp.ChainNameAliases) == 0 { resp.ChainNameAliases = chain.Aliases } } } return nil } if resp.ChainName != "" { if chain := networksWithFirehose.Find(resp.ChainName); chain != nil { if firstStreamableBlock.Number == uint64(chain.Firehose.FirstStreamableBlock.Height) && nox(chain.Firehose.FirstStreamableBlock.ID) != nox(firstStreamableBlock.Id) { return fmt.Errorf("chain name defined in flag: %q inconsistent with the genesis block ID %q (expected: %q)", resp.ChainName, nox(firstStreamableBlock.Id), nox(chain.Firehose.FirstStreamableBlock.ID)) } resp.ChainName = chain.ID if len(resp.ChainNameAliases) == 0 { resp.ChainNameAliases = chain.Aliases } } else if chain := networksWithFirehose.FindByFirstStreamableBlock(firstStreamableBlock.Number, firstStreamableBlock.Id); chain != nil { return fmt.Errorf("chain name defined in flag: %q inconsistent with the one discovered from genesis block %q", resp.ChainName, chain.ID) } } else { if chain := networksWithFirehose.FindByFirstStreamableBlock(firstStreamableBlock.Number, firstStreamableBlock.Id); chain != nil { resp.ChainName = chain.ID if len(resp.ChainNameAliases) == 0 { resp.ChainNameAliases = chain.Aliases } } } if firstStreamableBlock.Payload.TypeUrl == "type.googleapis.com/sf.ethereum.type.v2.Block" { var seenDetailLevel bool for _, feature := range resp.BlockFeatures { if feature == "base" || feature == "extended" || feature == "hybrid" { seenDetailLevel = true break } } if !seenDetailLevel { return fmt.Errorf("ethereum blocks are used without setting detail level in 'advertise-block-features': expected one of 'base', 'extended' or 'hybrid' (or use 'firehose-ethereum' binary instead to serve this chain and get automatic detection/validation)") } } return nil }
Functions ¶
func BlockIdEncodingForNetwork ¶ added in v1.9.11
func BlockIdEncodingForNetwork(network *registry.Network) pbfirehose.InfoResponse_BlockIdEncoding
BlockIdEncodingForNetwork returns the InfoResponse_BlockIdEncoding for a given network based on its Firehose.BytesEncoding.
Types ¶
type InfoServer ¶
func NewInfoServer ¶
func NewInfoServer( chainName string, chainNameAliases []string, blockIDEncoding pbfirehose.InfoResponse_BlockIdEncoding, blockFeatures []string, firstStreamableBlock uint64, validate bool, responseFiller func(block *pbbstream.Block, resp *pbfirehose.InfoResponse, validate bool) error, logger *zap.Logger, ) *InfoServer
func (*InfoServer) Info ¶
func (s *InfoServer) Info(ctx context.Context, request *pbfirehose.InfoRequest) (*pbfirehose.InfoResponse, error)
Click to show internal directories.
Click to hide internal directories.