gitee.com/lh-her-team/common@v1.5.1/birdsnest/config.go (about) 1 // Package birdsnest configuration implement 2 package birdsnest 3 4 type KeyType int32 5 6 const ( 7 // KeyType_KTDefault default type 8 KeyType_KTDefault KeyType = 0 9 // KeyType_KTTimestampKey timestamp type 10 KeyType_KTTimestampKey KeyType = 1 11 ) 12 13 // KeyType_name key type name map 14 var KeyType_name = map[KeyType]string{ 15 KeyType_KTDefault: "Default", 16 KeyType_KTTimestampKey: "TimestampKey", 17 } 18 19 // SerializeIntervalType Serialize interval type 20 type SerializeIntervalType int32 21 22 const ( 23 // SerializeIntervalType_Height Timed serialize type 24 SerializeIntervalType_Height SerializeIntervalType = 0 25 // SerializeIntervalType_Timed Timed serialize type 26 SerializeIntervalType_Timed SerializeIntervalType = 1 27 // SerializeIntervalType_Exit Exit serialize type 28 SerializeIntervalType_Exit SerializeIntervalType = 2 29 ) 30 31 // SerializeIntervalType_name SerializeIntervalType name map 32 var SerializeIntervalType_name = map[SerializeIntervalType]string{ 33 SerializeIntervalType_Height: "Height", 34 SerializeIntervalType_Timed: "Timed", 35 SerializeIntervalType_Exit: "Exit", 36 } 37 38 // FilterExtensionType filter extension type 39 type FilterExtensionType int32 40 41 const ( 42 // FilterExtensionType_FETDefault default filter extension type 43 FilterExtensionType_FETDefault FilterExtensionType = 0 44 // FilterExtensionType_FETTimestamp timestamp filter extension type 45 FilterExtensionType_FETTimestamp FilterExtensionType = 1 46 ) 47 48 // RuleType rule type 49 type RuleType int32 50 51 const ( 52 // RuleType_AbsoluteExpireTime absolute expire time 53 RuleType_AbsoluteExpireTime RuleType = 0 54 ) 55 56 type BirdsNestConfig struct { 57 // ChainId 58 ChainId string `json:"chain_id,omitempty"` 59 // Length cuckoo numbers 60 Length uint32 `json:"length,omitempty"` 61 // rules configuration 62 Rules *RulesConfig `json:"rules,omitempty"` 63 // Cuckoo configuration 64 Cuckoo *CuckooConfig `json:"cuckoo,omitempty"` 65 // Snapshot configuration 66 Snapshot *SnapshotSerializerConfig `json:"snapshot,omitempty"` 67 } 68 69 // RulesConfig rules configuration 70 type RulesConfig struct { 71 // absolute expire time second 72 AbsoluteExpireTime int64 `json:"absolute_expire_time,omitempty"` 73 } 74 75 // CuckooConfig Cuckoo configuration 76 type CuckooConfig struct { 77 // KeyType key type 78 KeyType KeyType `json:"key_type,omitempty"` 79 // TagsPerBucket num of tags for each bucket, which is b in paper. tag is fingerprint, which is f in paper. 80 TagsPerBucket uint32 `json:"tags_per_bucket,omitempty"` 81 // BitsPerItem num of bits for each item, which is length of tag(fingerprint) 82 BitsPerItem uint32 `json:"bits_per_item,omitempty"` 83 // MaxNumKeys num of keys that filter will store. this value should close to and lower 84 // nextPow2(maxNumKeys/tagsPerBucket) * maxLoadFactor. cause table.NumBuckets is always a 85 // power of two 86 MaxNumKeys uint32 `json:"max_num_keys,omitempty"` 87 // TableType has two constant parameters to choose from: 88 // TableTypeSingle normal single table 89 // TableTypePacked packed table, use semi-sort to save 1 bit per item 90 TableType uint32 `json:"table_type,omitempty"` 91 } 92 93 // SnapshotSerializerConfig Snapshot serializer config 94 type SnapshotSerializerConfig struct { 95 // Type serialize interval type 96 Type SerializeIntervalType `json:"type,omitempty"` 97 // Timed serialize interval configuration 98 Timed *TimedSerializeIntervalConfig `json:"timed,omitempty"` 99 // BlockHeight serialize interval configuration 100 BlockHeight *BlockHeightSerializeIntervalConfig `json:"block_height,omitempty"` 101 // Path filepath 102 Path string `json:"path,omitempty"` 103 } 104 105 // TimedSerializeIntervalConfig Timed serialization interval configuration 106 type TimedSerializeIntervalConfig struct { 107 // Timed Interval 108 Interval int64 `json:"interval,omitempty"` 109 } 110 111 // BlockHeightSerializeIntervalConfig Block height serialization interval configuration 112 type BlockHeightSerializeIntervalConfig struct { 113 // Block height Interval 114 Interval uint64 `json:"interval,omitempty"` 115 }