pb

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig       = errors.New("invalid configuration file")
	ErrInvalidSignature    = errors.New("invalid configuration signature")
	ErrInvalidNetworkState = errors.New("invalid network state")
	ErrInvalidPeerID       = errors.New("invalid peer ID")
	ErrMissingPeerAddrs    = errors.New("missing peer addresses")
	ErrInvalidPeerAddr     = errors.New("invalid peer address")
	ErrMissingLastUpdated  = errors.New("missing last updated timestamp")
	ErrInvalidLastUpdated  = errors.New("invalid last updated (maybe outdated)")
)

Errors used by the NetworkConfig.

View Source
var (
	ErrInvalidLengthProtector = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowProtector   = fmt.Errorf("proto: integer overflow")
)
View Source
var NetworkState_name = map[int32]string{
	0: "BOOTSTRAP",
	1: "PROTECTED",
}
View Source
var NetworkState_value = map[string]int32{
	"BOOTSTRAP": 0,
	"PROTECTED": 1,
}

Functions

This section is empty.

Types

type NetworkConfig

type NetworkConfig struct {
	NetworkState         NetworkState          `` /* 145-byte string literal not displayed */
	Participants         map[string]*PeerAddrs `` /* 151-byte string literal not displayed */
	LastUpdated          *types.Timestamp      `protobuf:"bytes,3,opt,name=last_updated,json=lastUpdated" json:"last_updated,omitempty"`
	Signature            *crypto.Signature     `protobuf:"bytes,10,opt,name=signature" json:"signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{}              `json:"-"`
	XXX_unrecognized     []byte                `json:"-"`
	XXX_sizecache        int32                 `json:"-"`
}

The NetworkConfig message contains the network state and its participants (signed by a trusted node).

func NewNetworkConfig

func NewNetworkConfig(networkState NetworkState) *NetworkConfig

NewNetworkConfig creates a NetworkConfig.

func (*NetworkConfig) Descriptor

func (*NetworkConfig) Descriptor() ([]byte, []int)

func (*NetworkConfig) GetLastUpdated

func (m *NetworkConfig) GetLastUpdated() *types.Timestamp

func (*NetworkConfig) GetNetworkState

func (m *NetworkConfig) GetNetworkState() NetworkState

func (*NetworkConfig) GetParticipants

func (m *NetworkConfig) GetParticipants() map[string]*PeerAddrs

func (*NetworkConfig) GetSignature

func (m *NetworkConfig) GetSignature() *crypto.Signature

func (*NetworkConfig) LoadFromFile

func (c *NetworkConfig) LoadFromFile(ctx context.Context, path string, signerID peer.ID) (err error)

LoadFromFile loads the given configuration and validates it.

func (*NetworkConfig) Marshal

func (m *NetworkConfig) Marshal() (dAtA []byte, err error)

func (*NetworkConfig) MarshalTo

func (m *NetworkConfig) MarshalTo(dAtA []byte) (int, error)

func (*NetworkConfig) ProtoMessage

func (*NetworkConfig) ProtoMessage()

func (*NetworkConfig) Reset

func (m *NetworkConfig) Reset()

func (*NetworkConfig) Sign

func (c *NetworkConfig) Sign(ctx context.Context, privKey crypto.PrivKey) error

Sign signs the current configuration data.

func (*NetworkConfig) Size

func (m *NetworkConfig) Size() (n int)

func (*NetworkConfig) String

func (m *NetworkConfig) String() string

func (*NetworkConfig) Unmarshal

func (m *NetworkConfig) Unmarshal(dAtA []byte) error

func (*NetworkConfig) ValidateContent

func (c *NetworkConfig) ValidateContent(ctx context.Context) error

ValidateContent validates that the contents of the configuration is correctly typed (peerIDs, addresses, etc).

func (*NetworkConfig) ValidateSignature

func (c *NetworkConfig) ValidateSignature(ctx context.Context, peerID peer.ID) bool

ValidateSignature verifies that the network configuration was signed by a given peer.

func (*NetworkConfig) XXX_DiscardUnknown

func (m *NetworkConfig) XXX_DiscardUnknown()

func (*NetworkConfig) XXX_Marshal

func (m *NetworkConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NetworkConfig) XXX_Merge

func (dst *NetworkConfig) XXX_Merge(src proto.Message)

func (*NetworkConfig) XXX_Size

func (m *NetworkConfig) XXX_Size() int

func (*NetworkConfig) XXX_Unmarshal

func (m *NetworkConfig) XXX_Unmarshal(b []byte) error

type NetworkState

type NetworkState int32
const (
	// The network is in the bootstrap phase (not fully private yet).
	NetworkState_BOOTSTRAP NetworkState = 0
	// The network bootstrap phase is complete and the network is now protected.
	NetworkState_PROTECTED NetworkState = 1
)

func (NetworkState) EnumDescriptor

func (NetworkState) EnumDescriptor() ([]byte, []int)

func (NetworkState) String

func (x NetworkState) String() string

type PeerAddrs

type PeerAddrs struct {
	Addresses            []string `protobuf:"bytes,1,rep,name=addresses" json:"addresses,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

A list of multiaddresses.

func (*PeerAddrs) Descriptor

func (*PeerAddrs) Descriptor() ([]byte, []int)

func (*PeerAddrs) GetAddresses

func (m *PeerAddrs) GetAddresses() []string

func (*PeerAddrs) Marshal

func (m *PeerAddrs) Marshal() (dAtA []byte, err error)

func (*PeerAddrs) MarshalTo

func (m *PeerAddrs) MarshalTo(dAtA []byte) (int, error)

func (*PeerAddrs) ProtoMessage

func (*PeerAddrs) ProtoMessage()

func (*PeerAddrs) Reset

func (m *PeerAddrs) Reset()

func (*PeerAddrs) Size

func (m *PeerAddrs) Size() (n int)

func (*PeerAddrs) String

func (m *PeerAddrs) String() string

func (*PeerAddrs) Unmarshal

func (m *PeerAddrs) Unmarshal(dAtA []byte) error

func (*PeerAddrs) XXX_DiscardUnknown

func (m *PeerAddrs) XXX_DiscardUnknown()

func (*PeerAddrs) XXX_Marshal

func (m *PeerAddrs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PeerAddrs) XXX_Merge

func (dst *PeerAddrs) XXX_Merge(src proto.Message)

func (*PeerAddrs) XXX_Size

func (m *PeerAddrs) XXX_Size() int

func (*PeerAddrs) XXX_Unmarshal

func (m *PeerAddrs) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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