mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-20 04:56:41 +00:00

* [NOD-1162] [FIX] Connection manager should run the moment it adds a request * [NOD-1162] [FIX] Set peerID on handshake * [NOD-1162] [FIX] Broadcast should send to outgoing route, not incoming * [NOD-1162] [FIX] Add CmdInvRelayBlock to MakeEmptyMessage * [NOD-1162] [FIX] Initialize Hash before decoding MsgInvRelayBlock * [NOD-1162] [FIX] Invert condition * [NOD-1162] [FIX] Fixes to encoding of MsgGetRelayBlocks * [NOD-1162] [FIX] Add MsgGetRelayBlocks to MakeEmptyMessage * [NOD-1162] Add comment
36 lines
731 B
Go
36 lines
731 B
Go
package blockrelay
|
|
|
|
import "github.com/kaspanet/kaspad/util/daghash"
|
|
|
|
type hashesQueueSet struct {
|
|
queue []*daghash.Hash
|
|
set map[daghash.Hash]struct{}
|
|
}
|
|
|
|
func (r *hashesQueueSet) enqueueIfNotExists(hash *daghash.Hash) {
|
|
if _, ok := r.set[*hash]; ok {
|
|
return
|
|
}
|
|
r.queue = append(r.queue, hash)
|
|
r.set[*hash] = struct{}{}
|
|
}
|
|
|
|
func (r *hashesQueueSet) dequeue(numItems int) []*daghash.Hash {
|
|
var hashes []*daghash.Hash
|
|
hashes, r.queue = r.queue[:numItems], r.queue[numItems:]
|
|
for _, hash := range hashes {
|
|
delete(r.set, *hash)
|
|
}
|
|
return hashes
|
|
}
|
|
|
|
func (r *hashesQueueSet) len() int {
|
|
return len(r.queue)
|
|
}
|
|
|
|
func newHashesQueueSet() *hashesQueueSet {
|
|
return &hashesQueueSet{
|
|
set: make(map[daghash.Hash]struct{}),
|
|
}
|
|
}
|