Documentation
¶
Index ¶
- Constants
- Variables
- func CreateBlock(prevHash string, number uint64) (*database.Block, common.Hash)
- func GeneratePolicy(n int, randomWeights bool) (*policy.SigningPolicy, []*ecdsa.PrivateKey)
- func InMemoryDB(t *testing.T, name string) (*gorm.DB, string)
- func RandomNormalizedArray(n int, seed int64) []float64
- type MemStorage
- func (k *MemStorage[T]) Get(_ context.Context, key string) (T, error)
- func (k *MemStorage[T]) Remove(_ context.Context, key string) error
- func (k *MemStorage[T]) Set(_ context.Context, key string, item T) error
- func (k *MemStorage[T]) SetWithTTL(ctx context.Context, key string, item T, _ time.Duration) error
Constants ¶
View Source
const TotalWeight = 1<<16 - 1 // max uint16
Variables ¶
View Source
var ( PrivKey1 *ecdsa.PrivateKey // has weight 1/7 PrivKey2 *ecdsa.PrivateKey // has weight 3/7 PrivKey3 *ecdsa.PrivateKey // has weight 3/7 )
View Source
var MockSigningPolicy, MockPrivKeys = GeneratePolicy(100, true)
View Source
var TestSigningPolicy *policy.SigningPolicy
Functions ¶
func GeneratePolicy ¶
func GeneratePolicy(n int, randomWeights bool) (*policy.SigningPolicy, []*ecdsa.PrivateKey)
GeneratePolicy creates a policy with n providers and returns the policy and providers private keys.
If randomWeights is true, the weights are randomized, if not, the weights are uniform.
func RandomNormalizedArray ¶
RandomNormalizedArray generates an array of n random floats that sum to 1
Types ¶
type MemStorage ¶
type MemStorage[T any] struct { // contains filtered or unexported fields }
MemStorage is an in-memory implementation of storage.Storage[T] for use in tests.
func NewMemStorage ¶
func NewMemStorage[T any]() *MemStorage[T]
NewMemStorage creates a new empty MemStorage[T].
func (*MemStorage[T]) Set ¶
func (k *MemStorage[T]) Set(_ context.Context, key string, item T) error
func (*MemStorage[T]) SetWithTTL ¶
Click to show internal directories.
Click to hide internal directories.