From 33b49adc25a678fe946d71bd397c659f007c8dfa Mon Sep 17 00:00:00 2001 From: ayaz <3712860+ayazans@users.noreply.github.com> Date: Sat, 18 Jul 2020 00:12:19 -0400 Subject: [PATCH] naming style changes and linter error fixes --- batch.go | 4 +- batchdb.go | 2 +- cmd/sample/main.go | 3 +- db.go | 10 ++--- db_internal.go | 4 +- db_test.go | 30 +++++++------- entry.go | 1 + errors.go | 8 ++-- iterator.go | 8 ++-- memdb/memdb.go | 34 ++++++++-------- message/id.go | 8 ++-- message/topic.go | 28 ++++++------- mutex.go | 10 ++--- trie.go | 99 ++++++++++++++++++++++----------------------- unitdb.png | Bin 5487 -> 0 bytes 15 files changed, 123 insertions(+), 126 deletions(-) delete mode 100644 unitdb.png diff --git a/batch.go b/batch.go index abd6bb8..0e71ead 100644 --- a/batch.go +++ b/batch.go @@ -51,7 +51,7 @@ type ( // Batch is a write batch. Batch struct { - batchId uid.LID + batchID uid.LID opts *BatchOptions managed bool grouped bool @@ -151,7 +151,7 @@ func (b *Batch) DeleteEntry(e *Entry) error { case b.opts.Immutable: return errImmutable case len(e.ID) == 0: - return errMsgIdEmpty + return errMsgIDEmpty case len(e.Topic) == 0: return errTopicEmpty case len(e.Topic) > maxTopicLength: diff --git a/batchdb.go b/batchdb.go index b62c363..a75c0c1 100644 --- a/batchdb.go +++ b/batchdb.go @@ -68,7 +68,7 @@ func (db *DB) batch() *Batch { opts := DefaultBatchOptions opts.Immutable = db.flags.Immutable opts.Encryption = db.encryption == 1 - b := &Batch{opts: opts, batchId: uid.NewLID(), db: db} + b := &Batch{opts: opts, batchID: uid.NewLID(), db: db} b.buffer = db.bufPool.Get() return b diff --git a/cmd/sample/main.go b/cmd/sample/main.go index 99f3cfd..9fc9d82 100644 --- a/cmd/sample/main.go +++ b/cmd/sample/main.go @@ -18,8 +18,7 @@ func main() { } defer db.Close() - // Use DB.SetEntry() method to bulk store messages as topic is parsed on first request and subsequent requests skips parsing. - + // Use Entry.WithPayload() method to bulk store messages as topic is parsed on first request and subsequent requests skips parsing. topic := []byte("teams.alpha.ch1.u1") entry := &unitdb.Entry{Topic: topic} for j := 0; j < 50; j++ { diff --git a/db.go b/db.go index 6b6b979..db67fff 100644 --- a/db.go +++ b/db.go @@ -329,7 +329,7 @@ func (db *DB) Get(q *Query) (items [][]byte, err error) { } e, err := db.readEntry(we.topicHash, we.seq) if err != nil { - if err == errMsgIdDeleted { + if err == errMsgIDDeleted { invalidCount++ return nil } @@ -341,13 +341,13 @@ func (db *DB) Get(q *Query) (items [][]byte, err error) { logger.Error().Err(err).Str("context", "data.readMessage") return err } - msgId := message.ID(id) - if !msgId.EvalPrefix(q.Contract, q.cutoff) { + msgID := message.ID(id) + if !msgID.EvalPrefix(q.Contract, q.cutoff) { invalidCount++ return nil } - if msgId.IsEncrypted() { + if msgID.IsEncrypted() { val, err = db.mac.Decrypt(nil, val) if err != nil { logger.Error().Err(err).Str("context", "mac.decrypt") @@ -520,7 +520,7 @@ func (db *DB) DeleteEntry(e *Entry) error { case db.flags.Immutable: return errImmutable case len(e.ID) == 0: - return errMsgIdEmpty + return errMsgIDEmpty case len(e.Topic) == 0: return errTopicEmpty case len(e.Topic) > maxTopicLength: diff --git a/db_internal.go b/db_internal.go index ce9823a..3bc05d0 100644 --- a/db_internal.go +++ b/db_internal.go @@ -186,7 +186,7 @@ func (db *DB) readEntry(topicHash uint64, seq uint64) (entry, error) { e := entry{} data, err := db.mem.Get(topicHash, cacheKey) if err != nil { - return entry{}, errMsgIdDeleted + return entry{}, errMsgIDDeleted } if data != nil { e.UnmarshalBinary(data[:entrySize]) @@ -484,7 +484,7 @@ func (db *DB) isClosed() bool { // Check read ok status. func (db *DB) ok() error { if db.isClosed() { - return errors.New("wal is closed.") + return errors.New("wal is closed") } return nil } diff --git a/db_test.go b/db_test.go index 1c7653d..1a3d5c2 100644 --- a/db_test.go +++ b/db_test.go @@ -65,13 +65,13 @@ func TestSimple(t *testing.T) { entry := NewEntry(topic).WithContract(contract).WithTTL([]byte("1m")) for i = 0; i < n; i++ { - messageId := db.NewID() - entry.WithID(messageId) + messageID := db.NewID() + entry.WithID(messageID) val := []byte(fmt.Sprintf("msg.%2d", i)) if err := db.PutEntry(entry.WithPayload(val)); err != nil { t.Fatal(err) } - ids = append(ids, messageId) + ids = append(ids, messageID) } verifyMsgsAndClose := func() { @@ -115,15 +115,15 @@ func TestSimple(t *testing.T) { } for i = 0; i < n; i++ { - messageId := db.NewID() + messageID := db.NewID() val := []byte(fmt.Sprintf("msg.%2d", i)) if err := db.Put(topic, val); err != nil { t.Fatal(err) } - if err := db.PutEntry(NewEntry(topic).WithID(messageId).WithPayload(val)); err != nil { + if err := db.PutEntry(NewEntry(topic).WithID(messageID).WithPayload(val)); err != nil { t.Fatal(err) } - ids = append(ids, messageId) + ids = append(ids, messageID) } db.tinyCommit() if err := db.Sync(); err != nil { @@ -183,13 +183,13 @@ func TestBatch(t *testing.T) { // wg.Add(1) var ids [][]byte for i = 0; i < n; i++ { - messageId := db.NewID() + messageID := db.NewID() topic := append(topic, []byte("?ttl=1h")...) val := []byte(fmt.Sprintf("msg.%2d", i)) - if err := b.PutEntry(NewEntry(topic).WithID(messageId).WithPayload(val).WithContract(contract)); err != nil { + if err := b.PutEntry(NewEntry(topic).WithID(messageID).WithPayload(val).WithContract(contract)); err != nil { t.Fatal(err) } - ids = append(ids, messageId) + ids = append(ids, messageID) } for _, id := range ids { if err := b.Delete(id, topic); err != nil { @@ -338,12 +338,12 @@ func TestLeasing(t *testing.T) { topic := []byte("unit1.test") var ids [][]byte for i = 0; i < n; i++ { - messageId := db.NewID() + messageID := db.NewID() val := []byte(fmt.Sprintf("msg.%2d", i)) - if err := db.PutEntry(NewEntry(topic).WithID(messageId).WithPayload(val)); err != nil { + if err := db.PutEntry(NewEntry(topic).WithID(messageID).WithPayload(val)); err != nil { t.Fatal(err) } - ids = append(ids, messageId) + ids = append(ids, messageID) } db.tinyCommit() if err := db.Sync(); err != nil { @@ -353,15 +353,15 @@ func TestLeasing(t *testing.T) { db.Delete(id, topic) } for i = 0; i < n; i++ { - messageId := db.NewID() + messageID := db.NewID() val := []byte(fmt.Sprintf("msg.%2d", i)) if err := db.Put(topic, val); err != nil { t.Fatal(err) } - if err := db.PutEntry(NewEntry(topic).WithID(messageId).WithPayload(val)); err != nil { + if err := db.PutEntry(NewEntry(topic).WithID(messageID).WithPayload(val)); err != nil { t.Fatal(err) } - ids = append(ids, messageId) + ids = append(ids, messageID) } db.tinyCommit() if err := db.Sync(); err != nil { diff --git a/entry.go b/entry.go index 5ce6c1a..8d31bcd 100644 --- a/entry.go +++ b/entry.go @@ -39,6 +39,7 @@ type ( val []byte encryption bool } + // Entry entry is a message entry structure Entry struct { internalEntry ID []byte // The ID of the message diff --git a/errors.go b/errors.go index c725ce5..6b2849f 100644 --- a/errors.go +++ b/errors.go @@ -22,10 +22,10 @@ import ( var ( errTopicEmpty = errors.New("Topic is empty") - errMsgIdEmpty = errors.New("Message Id is empty") - errMsgIdDeleted = errors.New("Message Id is deleted") - errMsgIdDoesNotExist = errors.New("Message Id does not exist in database") - errMsgIdPrefixMismatch = errors.New("Message Id does not match topic or Contract") + errMsgIDEmpty = errors.New("Message ID is empty") + errMsgIDDeleted = errors.New("Message ID is deleted") + errMsgIDDoesNotExist = errors.New("Message ID does not exist in database") + errMsgIDPrefixMismatch = errors.New("Message ID does not match topic or Contract") errTtlTooLarge = errors.New("TTL is too large") errTopicTooLarge = errors.New("Topic is too large") errMsgExpired = errors.New("Message has expired") diff --git a/iterator.go b/iterator.go index 6b2d47b..ecfcebf 100644 --- a/iterator.go +++ b/iterator.go @@ -138,7 +138,7 @@ func (it *ItemIterator) Next() { } e, err := it.db.readEntry(we.topicHash, we.seq) if err != nil { - if err == errMsgIdDoesNotExist { + if err == errMsgIDDoesNotExist { logger.Error().Err(err).Str("context", "db.readEntry") return err } @@ -150,13 +150,13 @@ func (it *ItemIterator) Next() { logger.Error().Err(err).Str("context", "data.readMessage") return err } - msgId := message.ID(id) - if !msgId.EvalPrefix(it.query.Contract, it.query.cutoff) { + msgID := message.ID(id) + if !msgID.EvalPrefix(it.query.Contract, it.query.cutoff) { it.invalidKeys++ return nil } - if msgId.IsEncrypted() { + if msgID.IsEncrypted() { val, err = it.db.mac.Decrypt(nil, val) if err != nil { logger.Error().Err(err).Str("context", "mac.Decrypt") diff --git a/memdb/memdb.go b/memdb/memdb.go index 304bb56..e6c5e88 100644 --- a/memdb/memdb.go +++ b/memdb/memdb.go @@ -144,15 +144,15 @@ func (db *DB) Close() error { return nil } -// getCache returns cache under given blockId -func (db *DB) getCache(blockId uint64) *memCache { - return db.blockCache[db.consistent.FindBlock(blockId)] +// getCache returns cache under given blockID +func (db *DB) getCache(blockID uint64) *memCache { + return db.blockCache[db.consistent.FindBlock(blockID)] } -// Get gets data for the provided key under a blockId -func (db *DB) Get(blockId uint64, key uint64) ([]byte, error) { +// Get gets data for the provided key under a blockID +func (db *DB) Get(blockID uint64, key uint64) ([]byte, error) { // Get cache - cache := db.getCache(blockId) + cache := db.getCache(blockID) cache.RLock() defer cache.RUnlock() // Get item from cache. @@ -175,10 +175,10 @@ func (db *DB) Get(blockId uint64, key uint64) ([]byte, error) { return data[4:], nil } -// Remove sets data offset to -1 for the key under a blockId -func (db *DB) Remove(blockId uint64, key uint64) error { +// Remove sets data offset to -1 for the key under a blockID +func (db *DB) Remove(blockID uint64, key uint64) error { // Get cache - cache := db.getCache(blockId) + cache := db.getCache(blockID) cache.RLock() defer cache.RUnlock() // Get item from cache. @@ -188,10 +188,10 @@ func (db *DB) Remove(blockId uint64, key uint64) error { return nil } -// Set sets the value for the given entry for a blockId. -func (db *DB) Set(blockId uint64, key uint64, data []byte) error { +// Set sets the value for the given entry for a blockID. +func (db *DB) Set(blockID uint64, key uint64, data []byte) error { // Get cache. - cache := db.getCache(blockId) + cache := db.getCache(blockID) cache.Lock() defer cache.Unlock() off, err := cache.data.allocate(uint32(len(data) + 4)) @@ -211,10 +211,10 @@ func (db *DB) Set(blockId uint64, key uint64, data []byte) error { return nil } -// Keys gets all keys from block cache for the provided blockId -func (db *DB) Keys(blockId uint64) []uint64 { +// Keys gets all keys from block cache for the provided blockID +func (db *DB) Keys(blockID uint64) []uint64 { // Get cache - cache := db.getCache(blockId) + cache := db.getCache(blockID) cache.RLock() defer cache.RUnlock() // Get keys from block cache. @@ -226,9 +226,9 @@ func (db *DB) Keys(blockId uint64) []uint64 { } // Free free keeps first offset that can be free if memdb exceeds target size. -func (db *DB) Free(blockId uint64, key uint64) error { +func (db *DB) Free(blockID uint64, key uint64) error { // Get cache - cache := db.getCache(blockId) + cache := db.getCache(blockID) cache.Lock() defer cache.Unlock() if cache.freeOffset > 0 { diff --git a/message/id.go b/message/id.go index 7c1a872..56bfad9 100644 --- a/message/id.go +++ b/message/id.go @@ -38,9 +38,9 @@ const ( // Contract generates contract from parts and concatenate contract and first part of the topic func Contract(parts []Part) uint64 { if len(parts) == 1 { - return /*uint64(Wildcard)<<32 +*/ uint64(parts[0].Query) + return uint64(parts[0].Hash) } - return uint64(parts[1].Query)<<32 + uint64(parts[0].Query) + return uint64(parts[1].Hash)<<32 + uint64(parts[0].Hash) } // ID represents a message ID encoded at 128bit and lexigraphically sortable @@ -54,7 +54,7 @@ func (id *ID) AddContract(contract uint64) { *id = newid } -// Contract gets the contract for the id. +// Contract gets the contract for the ID. func (id ID) Contract() uint64 { if len(id) < fixed+8 { return 0 @@ -62,7 +62,7 @@ func (id ID) Contract() uint64 { return binary.LittleEndian.Uint64(id[fixed:]) } -// NewID generates a new message identifier without containing a prefix. Prefix is set later when arrives. +// NewID generates a new message identifier without containing a prefix. Prefix is set later. func NewID(seq uint64, encrypted bool) ID { var eBit int8 if encrypted { diff --git a/message/topic.go b/message/topic.go index b1c1870..36aa47c 100644 --- a/message/topic.go +++ b/message/topic.go @@ -60,7 +60,7 @@ type Topic struct { // Part represents a parsed topic parts broken based on topic separator. type Part struct { - Query uint32 + Hash uint32 Wildchars uint8 } @@ -68,7 +68,7 @@ type Part struct { func (t *Topic) AddContract(contract uint32) { part := Part{ Wildchars: 0, - Query: contract, + Hash: contract, } parts := []Part{part} t.Parts = append(parts, t.Parts...) @@ -79,9 +79,9 @@ func (t *Topic) GetHash(contract uint64) uint64 { if len(t.Parts) == 1 { return contract } - h := t.Parts[0].Query + h := t.Parts[0].Hash for _, i := range t.Parts[1:] { - h ^= i.Query + h ^= i.Hash } return uint64(h)<<32 + (contract << 8) | uint64(t.Depth) } @@ -106,7 +106,7 @@ func (splitFunc) splitOpsKeyValue(c rune) bool { // Target returns the topic (first element of the query, second element of Parts) func (t *Topic) Target() uint32 { - return t.Parts[0].Query + return t.Parts[0].Hash } // TTL returns a Time-To-Live option. @@ -182,9 +182,9 @@ func (t *Topic) parseOptions(text []byte) (ok bool) { // GetHashCode combines the topic parts into a single hash. func (t *Topic) GetHashCode() uint32 { - h := t.Parts[0].Query + h := t.Parts[0].Hash for _, i := range t.Parts[1:] { - h ^= i.Query + h ^= i.Hash } return h } @@ -234,7 +234,7 @@ func parseStaticTopic(contract uint32, topic *Topic) (ok bool) { parts := bytes.FieldsFunc(topic.Topic, fn.splitTopic) part = Part{} for _, p := range parts { - part.Query = hash.WithSalt(p, contract) + part.Hash = hash.WithSalt(p, contract) topic.Parts = append(topic.Parts, part) } @@ -277,14 +277,14 @@ func parseWildcardTopic(contract uint32, topic *Topic) (ok bool) { if bytes.HasSuffix(p, q) { topic.TopicType = TopicWildcard if idx == 0 { - part.Query = hash.WithSalt(p, contract) + part.Hash = hash.WithSalt(p, contract) topic.Parts = append(topic.Parts, part) } wildchars++ wildcharcount++ continue } - part.Query = hash.WithSalt(p, contract) + part.Hash = hash.WithSalt(p, contract) topic.Parts = append(topic.Parts, part) if wildchars > 0 { if idx-wildcharcount-1 >= 0 { @@ -300,7 +300,7 @@ func parseWildcardTopic(contract uint32, topic *Topic) (ok bool) { topic.Parts[len(topic.Parts)-1:][0].Wildchars = wildchars } if topic.Depth == TopicMaxDepth { - part.Query = Wildcard + part.Hash = Wildcard topic.Parts = append(topic.Parts, part) } topic.Depth = depth @@ -328,7 +328,7 @@ func (t *Topic) Marshal() []byte { for _, part := range t.Parts { buf[n] = byte(part.Wildchars) n++ - binary.LittleEndian.PutUint32(buf[n:], part.Query) + binary.LittleEndian.PutUint32(buf[n:], part.Hash) n += 4 } return buf @@ -345,9 +345,9 @@ func (t *Topic) Unmarshal(data []byte) error { break } wildchars := uint8(buf.Next(1)[0]) - query := binary.LittleEndian.Uint32(buf.Next(4)) + hash := binary.LittleEndian.Uint32(buf.Next(4)) parts = append(parts, Part{ - Query: query, + Hash: hash, Wildchars: wildchars, }) } diff --git a/mutex.go b/mutex.go index 27f153b..5271938 100644 --- a/mutex.go +++ b/mutex.go @@ -26,13 +26,13 @@ const ( nMutex = 16 ) -// mutex mutex to lock/unlock on blockId +// mutex mutex to lock/unlock on blockID type mutex struct { internal []*sync.RWMutex consistent *hash.Consistent } -// newMutex creates mutex to lock/unlock blockId. +// newMutex creates mutex to lock/unlock blockID. func newMutex() mutex { mu := mutex{ internal: make([]*sync.RWMutex, nMutex), @@ -46,7 +46,7 @@ func newMutex() mutex { return mu } -// getMutex returns mutex under given blockId -func (mu *mutex) getMutex(blockId uint64) *sync.RWMutex { - return mu.internal[mu.consistent.FindBlock(blockId)] +// getMutex returns mutex under given blockID +func (mu *mutex) getMutex(blockID uint64) *sync.RWMutex { + return mu.internal[mu.consistent.FindBlock(blockID)] } diff --git a/trie.go b/trie.go index 91d5082..7da731f 100644 --- a/trie.go +++ b/trie.go @@ -41,42 +41,42 @@ func (top *topics) addUnique(value topic) (added bool) { return } -type key struct { - query uint32 +type part struct { + hash uint32 wildchars uint8 } -type part struct { - k key +type node struct { + part part depth uint8 - parent *part - children map[key]*part + parent *node + children map[part]*node topics topics } -func (p *part) orphan() { - if p.parent == nil { +func (n *node) orphan() { + if n.parent == nil { return } - delete(p.parent.children, p.k) - if len(p.parent.children) == 0 { - p.parent.orphan() + delete(n.parent.children, n.part) + if len(n.parent.children) == 0 { + n.parent.orphan() } } -// partTrie represents an efficient collection of Trie with lookup capability. -type partTrie struct { - summary map[uint64]*part // summary is map of topichash to node of tree. - root *part // The root node of the tree. +// topicTrie represents an efficient collection of Trie with lookup capability. +type topicTrie struct { + summary map[uint64]*node // summary is map of topichash to node of tree. + root *node // The root node of the tree. } -// newPartTrie creates a new part Trie. -func newPartTrie() *partTrie { - return &partTrie{ - summary: make(map[uint64]*part), - root: &part{ - children: make(map[key]*part), +// newTrie creates a new Trie. +func newTopicTrie() *topicTrie { + return &topicTrie{ + summary: make(map[uint64]*node), + root: &node{ + children: make(map[part]*node), }, } } @@ -85,15 +85,15 @@ func newPartTrie() *partTrie { type trie struct { sync.RWMutex mutex - partTrie *partTrie + topicTrie *topicTrie } // NewTrie new trie creates a Trie with an initialized Trie. // Mutex is used to lock concurent read/write on a contract, and it does not lock entire trie. func newTrie() *trie { return &trie{ - mutex: newMutex(), - partTrie: newPartTrie(), + mutex: newMutex(), + topicTrie: newTopicTrie(), } } @@ -101,7 +101,7 @@ func newTrie() *trie { func (t *trie) Count() int { t.RLock() defer t.RUnlock() - return len(t.partTrie.summary) + return len(t.topicTrie.summary) } // add adds a topic to trie. @@ -110,33 +110,33 @@ func (t *trie) add(topic topic, parts []message.Part, depth uint8) (added bool) mu := t.getMutex(topic.hash) mu.Lock() defer mu.Unlock() - if _, ok := t.partTrie.summary[topic.hash]; ok { + if _, ok := t.topicTrie.summary[topic.hash]; ok { return true } - curr := t.partTrie.root + curr := t.topicTrie.root for _, p := range parts { - k := key{ - query: p.Query, + newPart := part{ + hash: p.Hash, wildchars: p.Wildchars, } t.RLock() - child, ok := curr.children[k] + child, ok := curr.children[newPart] t.RUnlock() if !ok { - child = &part{ - k: k, + child = &node{ + part: newPart, parent: curr, - children: make(map[key]*part), + children: make(map[part]*node), } t.Lock() - curr.children[k] = child + curr.children[newPart] = child t.Unlock() } curr = child } t.Lock() curr.topics.addUnique(topic) - t.partTrie.summary[topic.hash] = curr + t.topicTrie.summary[topic.hash] = curr t.Unlock() added = true curr.depth = depth @@ -148,14 +148,14 @@ func (t *trie) lookup(query []message.Part, depth, topicType uint8) (tops topics t.RLock() defer t.RUnlock() // fmt.Println("trie.lookup: depth, parts ", depth, query) - t.ilookup(query, depth, topicType, &tops, t.partTrie.root) + t.ilookup(query, depth, topicType, &tops, t.topicTrie.root) return } -func (t *trie) ilookup(query []message.Part, depth, topicType uint8, tops *topics, currpart *part) { +func (t *trie) ilookup(query []message.Part, depth, topicType uint8, tops *topics, currNode *node) { // Add topics from the current branch - if currpart.depth == depth || (topicType == message.TopicStatic && currpart.k.query == message.Wildcard) { - for _, topic := range currpart.topics { + if currNode.depth == depth || (topicType == message.TopicStatic && currNode.part.hash == message.Wildcard) { + for _, topic := range currNode.topics { tops.addUnique(topic) } } @@ -167,17 +167,14 @@ func (t *trie) ilookup(query []message.Part, depth, topicType uint8, tops *topic q := query[0] // Go through the wildcard match branch - for k, p := range currpart.children { + for part, n := range currNode.children { switch { - case k.query == q.Query && q.Wildchars == k.wildchars: - // fmt.Println("trie.lookup: wildchars, part ", k.wildchars, k.query) - t.ilookup(query[1:], depth, topicType, tops, p) - case k.query == q.Query && uint8(len(query)) >= k.wildchars+1: - // fmt.Println("trie.lookup: wildchar, part ", k.wildchars, k.query) - t.ilookup(query[k.wildchars+1:], depth, topicType, tops, p) - case k.query == message.Wildcard: - // fmt.Println("trie.lookup: wildcard, part ", k.query) - t.ilookup(query[:], depth, topicType, tops, p) + case part.hash == q.Hash && q.Wildchars == part.wildchars: + t.ilookup(query[1:], depth, topicType, tops, n) + case part.hash == q.Hash && uint8(len(query)) >= part.wildchars+1: + t.ilookup(query[part.wildchars+1:], depth, topicType, tops, n) + case part.hash == message.Wildcard: + t.ilookup(query[:], depth, topicType, tops, n) } } } @@ -185,7 +182,7 @@ func (t *trie) ilookup(query []message.Part, depth, topicType uint8, tops *topic func (t *trie) getOffset(topicHash uint64) (off int64, ok bool) { t.RLock() defer t.RUnlock() - if curr, ok := t.partTrie.summary[topicHash]; ok { + if curr, ok := t.topicTrie.summary[topicHash]; ok { for _, topic := range curr.topics { if topic.hash == topicHash { return topic.offset, ok @@ -198,7 +195,7 @@ func (t *trie) getOffset(topicHash uint64) (off int64, ok bool) { func (t *trie) setOffset(top topic) (ok bool) { t.Lock() defer t.Unlock() - if curr, ok := t.partTrie.summary[top.hash]; ok { + if curr, ok := t.topicTrie.summary[top.hash]; ok { curr.topics.addUnique(top) return ok } diff --git a/unitdb.png b/unitdb.png deleted file mode 100644 index 2a110f5dd7000a5d31c0c05c2a34bc5e5e1fdb0c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5487 zcmdsb^;cA1)IKOZpn$Y=$AD78kW!KYA~AFcBcTi}Au-gD(hM~UN;$(YfRr>60t1Lh zN`nH@-NQSd_5Jbt7rgIX>)w0LKI_KwtiAVn_Kr6;)TW_gqaq?AqS4jSG$A4)1`@_; z6l8>JkX?*B;YQ-Cu4_s`I6^62zzK6=UlVP0BFr%R#(#?twWn%CMAh#ASB|8FIVDub z(wB(nPWOK&ahBMf`vfDapBC8fxtFV7prelqQD9)8gxhNmUuQ?Ci-eaCB!5SVjfjY0 zL|0SI^o`wiAvuq~6xo}5a2+?Ax!A8T00TgN%+YJlq4ff&J<5&30 zT|Dc}!Qg}TsmfoV&R$633j$&AA`E8ON=F}99ev&Y##!}#ALG3ii+@V>i*JGAbnpHj zxoGx-X~_HBjj^(PZO)+XmectVyd6)?I}$PNtNlK%QpgChR3q-r-;UdNWyrZgu^YcC zGNye7#fR>DwJdQ7Xa=M?{DGTU*p9cH%y`r{c$8$B*I4I2dWFle4|9t_6%}==n!r7I zI|nEgcN#xhy5_nVpv)^hBO3O5@%68M=UtyJ*n`w~$8@kh9c%ByU%QSVUs=_AZtPmJ z1f$op+y7)+Un#4E6tAp!x6V&)x^?D>x#v|rUU zt)wX8Qh7ACZq!W^NW{qfc4nJiFa=1m*A6}UeO5KFMqurc+?-zqX#2|;Zl`(o_3aC| zLym+k?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