Documentation ¶
Index ¶
- Constants
- func AddContext(err error, ctx string) error
- func CalculateLeaves(dataSize uint64) uint64
- func ComposeErrors(errs ...error) error
- func ContainsError(base, target error) bool
- func DecodePriceTable(pt *rhpv3.HostPriceTable, d *types.Decoder)
- func DecodeSettings(hs *rhpv2.HostSettings, d *types.Decoder)
- func EncodePriceTable(pt *rhpv3.HostPriceTable, e *types.Encoder)
- func EncodeSettings(hs *rhpv2.HostSettings, e *types.Encoder)
- func EqualIPNets(ipNetsA, ipNetsB []string) bool
- func FromFloat(f float64) types.Currency
- func IsLocal(addr string) bool
- func IsLoopback(addr string) bool
- func IsStdValid(addr string) error
- func IsValid(addr string) error
- func LookupIPNets(addr string) (ipNets []string, err error)
- func MulFloat(c types.Currency, f float64) types.Currency
- func PeekErr(errChan <-chan error) (err error)
- func VerifyRangeProof(segments []byte, proof []types.Hash256, start, end int, root types.Hash256) bool
- func VerifySegment(base []byte, hashSet []types.Hash256, numSegments, proofIndex uint64, ...) bool
- type MerkleTree
Constants ¶
const ( // SegmentSize is the chunk size that is used when taking the Merkle root // of a file. 64 is chosen because bandwidth is scarce and it optimizes for // the smallest possible storage proofs. Using a larger base, even 256 // bytes, would result in substantially faster hashing, but the bandwidth // tradeoff was deemed to be more important, as blockchain space is scarce. SegmentSize = 64 )
Variables ¶
This section is empty.
Functions ¶
func AddContext ¶
AddContext wraps an error in a context.
func CalculateLeaves ¶
CalculateLeaves calculates the number of leaves that would be pushed from data of size 'dataSize'.
func ComposeErrors ¶
ComposeErrors combines several errors in one.
func ContainsError ¶
ContainsError checks if one error contains the other.
func DecodePriceTable ¶
func DecodePriceTable(pt *rhpv3.HostPriceTable, d *types.Decoder)
DecodePriceTable decodes the host's price table.
func DecodeSettings ¶
func DecodeSettings(hs *rhpv2.HostSettings, d *types.Decoder)
DecodeSettings decodes the host's settings.
func EncodePriceTable ¶
func EncodePriceTable(pt *rhpv3.HostPriceTable, e *types.Encoder)
EncodePriceTable encodes the host's price table.
func EncodeSettings ¶
func EncodeSettings(hs *rhpv2.HostSettings, e *types.Encoder)
EncodeSettings encodes the host's settings.
func EqualIPNets ¶
EqualIPNets checks if two slices of IP subnets contain the same subnets.
func IsLocal ¶
IsLocal returns true if the input IP address belongs to a local address range such as 192.168.x.x or 127.x.x.x.
func IsLoopback ¶
IsLoopback returns true for IP addresses that are on the same machine.
func IsStdValid ¶
IsStdValid returns an error if the NetAddress is invalid. A valid NetAddress is of the form "host:port", such that "host" is either a valid IPv4/IPv6 address or a valid hostname, and "port" is an integer in the range [1,65535]. Valid IPv4 addresses, IPv6 addresses, and hostnames are detailed in RFCs 791, 2460, and 952, respectively. Loopback addresses are allowed.
func IsValid ¶
IsValid is an extension to IsStdValid that also forbids the loopback address.
NOTE: IsValid is being phased out in favor of allowing the loopback address but verifying through other means that the connection is not to yourself (which is the original reason that the loopback address was banned).
func LookupIPNets ¶
LookupIPNets returns string representations of the CIDR subnets.
func PeekErr ¶
PeekErr checks if a chan error has an error waiting to be returned. If it has it will return that error. Otherwise it returns 'nil'.
Types ¶
type MerkleTree ¶
type MerkleTree struct {
merkletree.Tree
}
MerkleTree wraps merkletree.Tree, changing some of the function definitions to assume sia-specific constants and return sia-specific types.
func NewTree ¶
func NewTree() *MerkleTree
NewTree returns a MerkleTree, which can be used for getting Merkle roots and Merkle proofs on data. See merkletree.Tree for more details.
func (*MerkleTree) PushObject ¶
func (t *MerkleTree) PushObject(obj types.EncoderTo)
PushObject encodes and adds the hash of the encoded object to the tree as a leaf.
func (*MerkleTree) Root ¶
func (t *MerkleTree) Root() (h types.Hash256)
Root is a redefinition of merkletree.Tree.Root, returning a types.Hash256 instead of a []byte.