Files
zeekay 361f012277 codec: rip github.com/luxfi/codec from leaf-misc (Wave 1D)
Replace codec.Uint64/Float64 with in-package Uint64/Float64 JSON
wrappers (jsonnum.go). The pubsub messages need string-encoded
numerics at the JSON-RPC boundary; no broader codec dependency is
needed for that.

Files touched:
- jsonnum.go (new): Uint64/Float64 with MarshalJSON/UnmarshalJSON
- messages.go: drop codec import, use local Uint64/Float64

luxfi/codec is now indirect-only via workspace transitives.
2026-06-05 11:56:38 -07:00

77 lines
1.8 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package pubsub
import (
"github.com/luxfi/address"
"github.com/luxfi/sdk/api"
)
// NewBloom command for a new bloom filter
//
// Deprecated: The pubsub server is deprecated.
type NewBloom struct {
// MaxElements size of bloom filter
MaxElements Uint64 `json:"maxElements"`
// CollisionProb expected error rate of filter
CollisionProb Float64 `json:"collisionProb"`
}
// NewSet command for a new map set
//
// Deprecated: The pubsub server is deprecated.
type NewSet struct{}
// AddAddresses command to add addresses
//
// Deprecated: The pubsub server is deprecated.
type AddAddresses struct {
api.JSONAddresses
// addressIds array of addresses, kept as a [][]byte for use in the bloom filter
addressIds [][]byte
}
// Command execution command
//
// Deprecated: The pubsub server is deprecated.
type Command struct {
NewBloom *NewBloom `json:"newBloom,omitempty"`
NewSet *NewSet `json:"newSet,omitempty"`
AddAddresses *AddAddresses `json:"addAddresses,omitempty"`
}
func (c *Command) String() string {
switch {
case c.NewBloom != nil:
return "newBloom"
case c.NewSet != nil:
return "newSet"
case c.AddAddresses != nil:
return "addAddresses"
default:
return "unknown"
}
}
func (c *NewBloom) IsParamsValid() bool {
p := float64(c.CollisionProb)
return c.MaxElements > 0 && 0 < p && p <= 1
}
// parseAddresses converts the bech32 addresses to their byte format.
func (c *AddAddresses) parseAddresses() error {
if c.addressIds == nil {
c.addressIds = make([][]byte, len(c.Addresses))
}
for i, addrStr := range c.Addresses {
_, _, addrBytes, err := address.Parse(addrStr)
if err != nil {
return err
}
c.addressIds[i] = addrBytes
}
return nil
}