forked from streamingfast/bstream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
registry.go
62 lines (55 loc) · 2.25 KB
/
registry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package bstream
// bstreams.NewDBinBlockReader
// var GetBlockReaderFactory BlockReaderFactory
// bstream.NewDBinBlockWriter
// var GetBlockWriterFactory BlockWriterFactory
// var GetBlockWriterHeaderLen int
var GetProtocolFirstStreamableBlock = uint64(0)
var GetMaxNormalLIBDistance = uint64(1000)
var NormalizeBlockID = func(in string) string { // some chains have block IDs that optionally start with 0x or are case insensitive
return in
}
func ValidateRegistry() error {
//if GetBlockReaderFactory == nil {
// return fmt.Errorf(missingInitializationErrorMessage("GetBlockReaderFactory"))
//}
//
//if GetBlockWriterFactory == nil {
// return fmt.Errorf(missingInitializationErrorMessage("GetBlockWriterFactory"))
//}
//
//if GetBlockWriterHeaderLen == 0 {
// return fmt.Errorf(missingInitializationErrorMessage("GetBlockWriterHeaderLen"))
//}
return nil
}
//func getBlockReaderFactory() BlockReaderFactory {
// if GetBlockReaderFactory == nil {
// panic(missingInitializationErrorMessage("GetBlockReaderFactory"))
// }
//
// return GetBlockReaderFactory
//}
//func missingInitializationErrorMessage(field string) string {
// return fmt.Sprintf(`the global variable 'bstream.%s' is nil, it was not initialized correctly, you are probably missing a critical chain specific import that sets those value, usually in the form '_ "github.com/streamingfast/firehose-<chain>/types"' where '<chain>' is one of firehose supported chain`, field)
//}
// InitGeneric initializes `bstream` with a generic block payload setter, reader, decoder and writer that are suitable
// for all chains. This is used in `firehose-core` as well as in testing method in respective tests to instantiate
// bstream.
//func InitGeneric(protocol string) {
// GetBlockWriterHeaderLen = dbin.HeaderLenght(protocol)
//
// GetBlockWriterFactory = BlockWriterFactoryFunc(func(writer io.Writer) (BlockWriter, error) {
// return NewDBinBlockWriter(writer, protocol)
// })
//
// GetBlockReaderFactory = BlockReaderFactoryFunc(func(reader io.Reader) (BlockReader, error) {
// return NewDBinBlockReader(reader, func(contentType string) error {
// if contentType != protocol {
// return fmt.Errorf("reader only knows about %s block kind, got %s", protocol, contentType)
// }
//
// return nil
// })
// })
//}