Integrate BACKBEAT SDK and resolve KACHING license validation
Major integrations and fixes: - Added BACKBEAT SDK integration for P2P operation timing - Implemented beat-aware status tracking for distributed operations - Added Docker secrets support for secure license management - Resolved KACHING license validation via HTTPS/TLS - Updated docker-compose configuration for clean stack deployment - Disabled rollback policies to prevent deployment failures - Added license credential storage (CHORUS-DEV-MULTI-001) Technical improvements: - BACKBEAT P2P operation tracking with phase management - Enhanced configuration system with file-based secrets - Improved error handling for license validation - Clean separation of KACHING and CHORUS deployment stacks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
97
vendor/github.com/libp2p/go-libp2p-kbucket/keyspace/keyspace.go
generated
vendored
Normal file
97
vendor/github.com/libp2p/go-libp2p-kbucket/keyspace/keyspace.go
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
package keyspace
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// Key represents an identifier in a KeySpace. It holds a reference to the
|
||||
// associated KeySpace, as well references to both the Original identifier,
|
||||
// as well as the new, KeySpace Bytes one.
|
||||
type Key struct {
|
||||
|
||||
// Space is the KeySpace this Key is related to.
|
||||
Space KeySpace
|
||||
|
||||
// Original is the original value of the identifier
|
||||
Original []byte
|
||||
|
||||
// Bytes is the new value of the identifier, in the KeySpace.
|
||||
Bytes []byte
|
||||
}
|
||||
|
||||
// Equal returns whether this key is equal to another.
|
||||
func (k1 Key) Equal(k2 Key) bool {
|
||||
if k1.Space != k2.Space {
|
||||
panic("k1 and k2 not in same key space.")
|
||||
}
|
||||
return k1.Space.Equal(k1, k2)
|
||||
}
|
||||
|
||||
// Less returns whether this key comes before another.
|
||||
func (k1 Key) Less(k2 Key) bool {
|
||||
if k1.Space != k2.Space {
|
||||
panic("k1 and k2 not in same key space.")
|
||||
}
|
||||
return k1.Space.Less(k1, k2)
|
||||
}
|
||||
|
||||
// Distance returns this key's distance to another
|
||||
func (k1 Key) Distance(k2 Key) *big.Int {
|
||||
if k1.Space != k2.Space {
|
||||
panic("k1 and k2 not in same key space.")
|
||||
}
|
||||
return k1.Space.Distance(k1, k2)
|
||||
}
|
||||
|
||||
// KeySpace is an object used to do math on identifiers. Each keyspace has its
|
||||
// own properties and rules. See XorKeySpace.
|
||||
type KeySpace interface {
|
||||
|
||||
// Key converts an identifier into a Key in this space.
|
||||
Key([]byte) Key
|
||||
|
||||
// Equal returns whether keys are equal in this key space
|
||||
Equal(Key, Key) bool
|
||||
|
||||
// Distance returns the distance metric in this key space
|
||||
Distance(Key, Key) *big.Int
|
||||
|
||||
// Less returns whether the first key is smaller than the second.
|
||||
Less(Key, Key) bool
|
||||
}
|
||||
|
||||
// byDistanceToCenter is a type used to sort Keys by proximity to a center.
|
||||
type byDistanceToCenter struct {
|
||||
Center Key
|
||||
Keys []Key
|
||||
}
|
||||
|
||||
func (s byDistanceToCenter) Len() int {
|
||||
return len(s.Keys)
|
||||
}
|
||||
|
||||
func (s byDistanceToCenter) Swap(i, j int) {
|
||||
s.Keys[i], s.Keys[j] = s.Keys[j], s.Keys[i]
|
||||
}
|
||||
|
||||
func (s byDistanceToCenter) Less(i, j int) bool {
|
||||
a := s.Center.Distance(s.Keys[i])
|
||||
b := s.Center.Distance(s.Keys[j])
|
||||
return a.Cmp(b) == -1
|
||||
}
|
||||
|
||||
// SortByDistance takes a KeySpace, a center Key, and a list of Keys toSort.
|
||||
// It returns a new list, where the Keys toSort have been sorted by their
|
||||
// distance to the center Key.
|
||||
func SortByDistance(sp KeySpace, center Key, toSort []Key) []Key {
|
||||
toSortCopy := make([]Key, len(toSort))
|
||||
copy(toSortCopy, toSort)
|
||||
bdtc := &byDistanceToCenter{
|
||||
Center: center,
|
||||
Keys: toSortCopy, // copy
|
||||
}
|
||||
sort.Sort(bdtc)
|
||||
return bdtc.Keys
|
||||
}
|
||||
59
vendor/github.com/libp2p/go-libp2p-kbucket/keyspace/xor.go
generated
vendored
Normal file
59
vendor/github.com/libp2p/go-libp2p-kbucket/keyspace/xor.go
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
package keyspace
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math/big"
|
||||
"math/bits"
|
||||
|
||||
u "github.com/ipfs/boxo/util"
|
||||
sha256 "github.com/minio/sha256-simd"
|
||||
)
|
||||
|
||||
// XORKeySpace is a KeySpace which:
|
||||
// - normalizes identifiers using a cryptographic hash (sha256)
|
||||
// - measures distance by XORing keys together
|
||||
var XORKeySpace = &xorKeySpace{}
|
||||
var _ KeySpace = XORKeySpace // ensure it conforms
|
||||
|
||||
type xorKeySpace struct{}
|
||||
|
||||
// Key converts an identifier into a Key in this space.
|
||||
func (s *xorKeySpace) Key(id []byte) Key {
|
||||
hash := sha256.Sum256(id)
|
||||
key := hash[:]
|
||||
return Key{
|
||||
Space: s,
|
||||
Original: id,
|
||||
Bytes: key,
|
||||
}
|
||||
}
|
||||
|
||||
// Equal returns whether keys are equal in this key space
|
||||
func (s *xorKeySpace) Equal(k1, k2 Key) bool {
|
||||
return bytes.Equal(k1.Bytes, k2.Bytes)
|
||||
}
|
||||
|
||||
// Distance returns the distance metric in this key space
|
||||
func (s *xorKeySpace) Distance(k1, k2 Key) *big.Int {
|
||||
// XOR the keys
|
||||
k3 := u.XOR(k1.Bytes, k2.Bytes)
|
||||
|
||||
// interpret it as an integer
|
||||
dist := big.NewInt(0).SetBytes(k3)
|
||||
return dist
|
||||
}
|
||||
|
||||
// Less returns whether the first key is smaller than the second.
|
||||
func (s *xorKeySpace) Less(k1, k2 Key) bool {
|
||||
return bytes.Compare(k1.Bytes, k2.Bytes) < 0
|
||||
}
|
||||
|
||||
// ZeroPrefixLen returns the number of consecutive zeroes in a byte slice.
|
||||
func ZeroPrefixLen(id []byte) int {
|
||||
for i, b := range id {
|
||||
if b != 0 {
|
||||
return i*8 + bits.LeadingZeros8(uint8(b))
|
||||
}
|
||||
}
|
||||
return len(id) * 8
|
||||
}
|
||||
Reference in New Issue
Block a user