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 shortTypeURL := strings.TrimPrefix(firstStreamableBlock.Payload.TypeUrl, "type.googleapis.com/") for _, protocol := range wellknown.WellKnownProtocols { if protocol.BlockType == shortTypeURL { resp.BlockIdEncoding = protocol.BytesEncoding break } } if !validate { if resp.ChainName == "" { if chain := wellknown.WellKnownProtocols.ChainByGenesisBlock(firstStreamableBlock.Number, firstStreamableBlock.Id); chain != nil { resp.ChainName = chain.Name resp.ChainNameAliases = chain.Aliases } } return nil } if resp.ChainName != "" { if chain := wellknown.WellKnownProtocols.ChainByName(resp.ChainName); chain != nil { if firstStreamableBlock.Number == chain.GenesisBlockNumber && chain.GenesisBlockID != firstStreamableBlock.Id { return fmt.Errorf("chain name defined in flag: %q inconsistent with the genesis block ID %q (expected: %q)", resp.ChainName, ox(firstStreamableBlock.Id), ox(chain.GenesisBlockID)) } resp.ChainName = chain.Name resp.ChainNameAliases = chain.Aliases } else if chain := wellknown.WellKnownProtocols.ChainByGenesisBlock(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.Name) } } else { if chain := wellknown.WellKnownProtocols.ChainByGenesisBlock(firstStreamableBlock.Number, firstStreamableBlock.Id); chain != nil { resp.ChainName = chain.Name 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 ¶
This section is empty.
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.