-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathregistry.go
More file actions
82 lines (72 loc) · 3.12 KB
/
Copy pathregistry.go
File metadata and controls
82 lines (72 loc) · 3.12 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package bstream
// bstreams.NewDBinBlockReader
// var GetBlockReaderFactory BlockReaderFactory
// bstream.NewDBinBlockWriter
// var GetBlockWriterFactory BlockWriterFactory
// var GetBlockWriterHeaderLen int
var GetProtocolFirstStreamableBlock = uint64(0)
var GetMaxNormalLIBDistance = uint64(1000)
// DefaultMergedBlocksBundleSize is the number of blocks per merged-blocks file
// assumed by readers when no explicit bundle size is provided (see
// FileSourceWithBundleSize). Like GetProtocolFirstStreamableBlock, it is meant
// to be set once at process startup. It must match the size of the files
// actually present in the merged-blocks store.
var DefaultMergedBlocksBundleSize = uint64(100)
// SanitizeBundleSize protects the merged-blocks math against a bundle size of 0,
// which would otherwise cause an integer divide-by-zero panic (see
// hub.substractAndRoundDownBlocks) or an infinite loop while walking merged
// files. A 0 typically means DefaultMergedBlocksBundleSize was left unset by a
// misconfigured process; we fall back to the standard 100-blocks bundle.
func SanitizeBundleSize(bundleSize uint64) uint64 {
if bundleSize == 0 {
return 100
}
return bundleSize
}
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
// })
// })
//}