soc

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: BSD-3-Clause Imports: 6 Imported by: 15

Documentation

Overview

Package swarm contains most basic and general Swarm concepts.

Copyright 2020 The Swarm Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	IdSize        = 32
	SignatureSize = 65
	AddressSize   = crypto.AddressSize
)

Variables

This section is empty.

Functions

func CreateAddress

func CreateAddress(id Id, owner *Owner) (swarm.Address, error)

CreateAddress creates a new soc address from the soc id and the ethereum address of the signer

func NewChunk

func NewChunk(id Id, ch swarm.Chunk, signer crypto.Signer) (swarm.Chunk, error)

NewChunk is a convenience function to create a single-owner chunk ready to be sent on the network.

func NewValidator

func NewValidator() swarm.Validator

NewValidator creates a new Validator.

Types

type Id

type Id []byte

Id is a soc identifier

type Owner

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

Owner is a wrapper that enforces valid length address of soc owner.

func NewOwner

func NewOwner(address []byte) (*Owner, error)

NewOwner creates a new Owner.

type Soc

type Soc struct {
	Chunk swarm.Chunk
	// contains filtered or unexported fields
}

Soc wraps a single soc.

func FromChunk

func FromChunk(sch swarm.Chunk) (*Soc, error)

FromChunk recreates an Soc representation from swarm.Chunk data.

func New

func New(id Id, ch swarm.Chunk) *Soc

New creates a new Soc representation from arbitrary soc id and a content-addressed chunk.

By default the span of the soc data is set to the length of the payload.

func (*Soc) AddSigner

func (s *Soc) AddSigner(signer crypto.Signer) error

AddSigner currently sets a single signer for the soc.

This method will overwrite any value set with WithOwnerAddress with the address derived from the given signer.

func (*Soc) Address

func (s *Soc) Address() (swarm.Address, error)

Address returns the soc Chunk address.

func (*Soc) OwnerAddress

func (s *Soc) OwnerAddress() []byte

OwnerAddress returns the ethereum address of the signer of the Chunk.

func (*Soc) ToChunk

func (s *Soc) ToChunk() (swarm.Chunk, error)

ToChunk generates a signed chunk payload ready for submission to the swarm network.

The method will fail if no signer has been added.

func (*Soc) WithOwnerAddress

func (s *Soc) WithOwnerAddress(ownerAddress *Owner) *Soc

WithOwnerAddress provides the possibility of setting the ethereum address for the owner of an soc in the absence of a signer.

type Validator

type Validator struct {
}

SocVaildator validates that the address of a given chunk is a single-owner chunk.

func (*Validator) Validate

func (v *Validator) Validate(ch swarm.Chunk) (valid bool)

Validate performs the validation check.

Jump to

Keyboard shortcuts

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