light

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

TODO(@Wondertan): Instead of doing sampling over the coordinates do a random walk over NMT trees.

Index

Constants

This section is empty.

Variables

View Source
var DefaultSampleAmount = 16

DefaultSampleAmount sets the default amount of samples to be sampled from the network by ShareAvailability.

Functions

func Node

Node creates a new empty Light Node.

func RandNode

func RandNode(dn *availability_test.DagNet, squareSize int) (*availability_test.Node, *share.Root)

RandNode creates a Light Node filled with a random block of the given size.

func RandService

func RandService() (*service.ShareService, blockservice.BlockService)

RandService provides an unfilled share.Service with corresponding blockservice.BlockService than can be filled by the test.

func RandServiceWithSquare

func RandServiceWithSquare(t *testing.T, n int) (*service.ShareService, *share.Root)

RandServiceWithSquare provides a share.Service filled with 'n' NMT trees of 'n' random shares, essentially storing a whole square.

Types

type Sample

type Sample struct {
	Row, Col int
}

Sample is a point in 2D space over square.

func SampleSquare

func SampleSquare(squareWidth int, num int) ([]Sample, error)

SampleSquare randomly picks *num* unique points from the given *width* square and returns them as samples.

type ShareAvailability

type ShareAvailability struct {
	// contains filtered or unexported fields
}

ShareAvailability implements share.Availability using Data Availability Sampling technique. It is light because it does not require the downloading of all the data to verify its availability. It is assumed that there are a lot of lightAvailability instances on the network doing sampling over the same Root to collectively verify its availability.

func NewShareAvailability

func NewShareAvailability(
	bserv blockservice.BlockService,
	disc *discovery.Discovery,
) *ShareAvailability

NewShareAvailability creates a new light Availability.

func TestAvailability

func TestAvailability(bServ blockservice.BlockService) *ShareAvailability

func (*ShareAvailability) ProbabilityOfAvailability

func (la *ShareAvailability) ProbabilityOfAvailability() float64

ProbabilityOfAvailability calculates the probability that the data square is available based on the amount of samples collected (DefaultSampleAmount).

Formula: 1 - (0.75 ** amount of samples)

func (*ShareAvailability) SharesAvailable

func (la *ShareAvailability) SharesAvailable(ctx context.Context, dah *share.Root) error

SharesAvailable randomly samples DefaultSampleAmount amount of Shares committed to the given Root. This way SharesAvailable subjectively verifies that Shares are available.

func (*ShareAvailability) Start

func (*ShareAvailability) Stop

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL