insolar

package
v0.9.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package insolar contains common definitions used by other modules.

Index

Constants

View Source
const (
	// GenesisNameRootDomain is the name of root domain contract for genesis record.
	GenesisNameRootDomain = "rootdomain"
	// GenesisNameNodeDomain is the name of node domain contract for genesis record.
	GenesisNameNodeDomain = "nodedomain"
	// GenesisNameNodeRecord is the name of node contract for genesis record.
	GenesisNameNodeRecord = "noderecord"
	// GenesisNameMember is the name of member contract for genesis record.
	GenesisNameMember = "member"
	// GenesisNameWallet is the name of wallet contract for genesis record.
	GenesisNameWallet = "wallet"
	// GenesisNameAccount is the name of wallet contract for genesis record.
	GenesisNameAccount = "account"
	// GenesisNameDeposit is the name of deposit contract for genesis record.
	GenesisNameDeposit = "deposit"
	// GenesisNameCostCenter is the name of cost center contract for genesis record.
	GenesisNameCostCenter = "costcenter"
	// GenesisNameMigrationAdmin is the name of migration admin contract for genesis record.
	GenesisNameMigrationAdmin = "migrationadmin"
	// GenesisNamePKShard is the name of public key shard contract for genesis record.
	GenesisNamePKShard = "pkshard"
	// GenesisNameMigrationShard is the name of migration address shard contract for genesis record.
	GenesisNameMigrationShard = "migrationshard"

	GenesisNameRootMember            = "root" + GenesisNameMember
	GenesisNameRootWallet            = "root" + GenesisNameWallet
	GenesisNameRootAccount           = "root" + GenesisNameAccount
	GenesisNameMigrationAdminMember  = "migration" + GenesisNameMember
	GenesisNameMigrationAdminWallet  = "migration" + GenesisNameWallet
	GenesisNameMigrationAdminAccount = "migration" + GenesisNameAccount
	GenesisNameFeeWallet             = "fee" + GenesisNameWallet
	GenesisNameFeeAccount            = "fee" + GenesisNameAccount

	GenesisAmountMigrationDaemonMembers       = 10
	GenesisAmountActiveMigrationDaemonMembers = 3

	GenesisAmountPublicKeyShards        = 10
	GenesisAmountMigrationAddressShards = 10
)
View Source
const (
	// JetSize is a Jet's size (depth+prefix).
	JetSize = RecordIDSize - PulseNumberSize
	// JetPrefixSize is a Jet's prefix size.
	JetPrefixSize = JetSize - 1
	// JetMaximumDepth is a Jet's maximum depth (maximum offset in bits).
	JetMaximumDepth = JetPrefixSize*8 - 1
	// JetPrefixOffset is an offset where prefix starts in jet id.
	JetPrefixOffset = PulseNumberSize + 1
)
View Source
const (
	StaticRoleUnknown = StaticRole(iota)
	StaticRoleVirtual
	StaticRoleHeavyMaterial
	StaticRoleLightMaterial
)
View Source
const (
	// PulseNumberSize declares the number of bytes in the pulse number
	PulseNumberSize = 4
	// EntropySize declares the number of bytes in the pulse entropy
	EntropySize = 64
	// OriginIDSize declares the number of bytes in the origin id
	OriginIDSize = 16
)
View Source
const (
	// FirstPulseNumber is the hardcoded first pulse number. Because first 65536 numbers are saved for the system's needs
	FirstPulseNumber = pulse.MinTimePulse
	// PulseNumberJet is a special pulse number value that signifies jet ID.
	PulseNumberJet = PulseNumber(1)
	// BuiltinContractPulseNumber declares special pulse number that creates namespace for builtin contracts
	BuiltinContractPulseNumber = PulseNumber(200)

	InvalidPulseEpoch   int = 0
	EphemeralPulseEpoch     = InvalidPulseEpoch + 1
)
View Source
const (
	// RecordHashSize is a record hash size. We use 224-bit SHA-3 hash (28 bytes).
	RecordHashSize = 28
	// RecordIDSize is relative record address.
	RecordIDSize = PulseNumberSize + RecordHashSize
	// RecordHashOffset is a offset where hash bytes starts in ID.
	RecordHashOffset = PulseNumberSize
	// RecordRefSize is absolute records address (including domain ID).
	RecordRefSize = RecordIDSize * 2
	// RecordRefIDSeparator is character that separates ID from DomainID in serialized Reference.
	RecordRefIDSeparator = "."
)
View Source
const (
	// DynamicRoleUndefined is used for special cases.
	DynamicRoleUndefined = DynamicRole(iota)
	// DynamicRoleVirtualExecutor is responsible for current pulse CPU operations.
	DynamicRoleVirtualExecutor
	// DynamicRoleVirtualValidator is responsible for previous pulse CPU operations.
	DynamicRoleVirtualValidator
	// DynamicRoleLightExecutor is responsible for current pulse Disk operations.
	DynamicRoleLightExecutor
	// DynamicRoleLightValidator is responsible for previous pulse Disk operations.
	DynamicRoleLightValidator
	// DynamicRoleHeavyExecutor is responsible for permanent Disk operations.
	DynamicRoleHeavyExecutor
)
View Source
const (
	ShortNodeIDSize = 4
)

Variables

View Source
var (
	// ErrUnknown is returned when error type cannot be defined.
	ErrUnknown = errors.New("unknown error")
	// ErrDeactivated is returned when requested object is deactivated.
	ErrDeactivated = errors.New("object is deactivated")
	// ErrStateNotAvailable is returned when requested object is deactivated.
	ErrStateNotAvailable = errors.New("object state is not available")
	// ErrHotDataTimeout is returned when no hot data received for a specific jet
	ErrHotDataTimeout = errors.New("requests were abandoned due to hot-data timeout")
	// ErrNoPendingRequest is returned when there are no pending requests on current LME
	ErrNoPendingRequest = errors.New("no pending requests are available")
	// ErrNotFound is returned when something not found
	ErrNotFound = errors.New("not found")
	// ErrTooManyPendingRequests is returned when a limit of pending requests has been reached on a current LME
	ErrTooManyPendingRequests = errors.New("the limit of pending requests count has been reached")
)

AllStaticRoles is an array of all possible StaticRoles.

View Source
var EphemeralPulse = &Pulse{
	PulseNumber:      FirstPulseNumber,
	Entropy:          [EntropySize]byte{},
	EpochPulseNumber: EphemeralPulseEpoch,
	PulseTimestamp:   pulse.UnixTimeOfMinTimePulse,
}

EphemeralPulse is used for discovery network bootstrap

View Source
var GenesisNameMigrationAddressShards = func() (result [GenesisAmountMigrationAddressShards]string) {
	for i := 0; i < GenesisAmountMigrationAddressShards; i++ {
		result[i] = GenesisNameMigrationShard + "_" + strconv.Itoa(i)
	}
	return
}()
View Source
var GenesisNameMigrationDaemonMembers = func() (result [GenesisAmountMigrationDaemonMembers]string) {
	for i := 0; i < GenesisAmountMigrationDaemonMembers; i++ {
		result[i] = "migration_daemon_" + strconv.Itoa(i) + "_" + GenesisNameMember
	}
	return
}()
View Source
var GenesisNamePublicKeyShards = func() (result [GenesisAmountPublicKeyShards]string) {
	for i := 0; i < GenesisAmountPublicKeyShards; i++ {
		result[i] = GenesisNamePKShard + "_" + strconv.Itoa(i)
	}
	return
}()
View Source
var GenesisPulse = &Pulse{
	PulseNumber:      FirstPulseNumber,
	Entropy:          [EntropySize]byte{},
	EpochPulseNumber: FirstPulseNumber,
	PulseTimestamp:   pulse.UnixTimeOfMinTimePulse,
}

GenesisPulse is a first pulse for the system because first 2 bits of pulse number and first 65536 pulses a are used by system needs and pulse numbers are related to the seconds of Unix time for calculation pulse numbers we use the formula = unix.Now() - firstPulseDate + 65536

View Source
var GenesisRecord genesisBinary = []byte{0xAC}

GenesisRecord is initial chain record.

View Source
var RootModule = "github.com/insolar/insolar"
View Source
var ZeroJetID = *NewJetID(0, nil)

ZeroJetID is value of an empty Jet ID

Functions

func Deserialize

func Deserialize(data []byte, to interface{}) error

Deserialize deserializes data to specific interface

func MustDeserialize

func MustDeserialize(data []byte, to interface{})

MustDeserialize deserializes data to specific interface, panics on error.

func MustSerialize

func MustSerialize(o interface{}) []byte

MustSerialize serializes interface, panics on error.

func Serialize

func Serialize(o interface{}) ([]byte, error)

Serialize serializes interface

Types

type APIRunner

type APIRunner interface {
	IsAPIRunner() bool
}

APIRunner

type Arguments

type Arguments []byte

Arguments is a dedicated type for arguments, that represented as binary cbored blob

func (*Arguments) MarshalJSON

func (args *Arguments) MarshalJSON() ([]byte, error)

MarshalJSON uncbor Arguments slice recursively

type AuthorizationCertificate

type AuthorizationCertificate interface {
	NodeMeta

	GetRole() StaticRole
	SerializeNodePart() []byte
	GetDiscoverySigns() map[Reference][]byte
}

AuthorizationCertificate interface provides methods to manage info about node from it certificate

type CallMode

type CallMode int

CallMode indicates whether we execute or validate

const (
	ExecuteCallMode CallMode = iota
	ValidateCallMode
)

func (CallMode) String

func (m CallMode) String() string

type Certificate

type Certificate interface {
	AuthorizationCertificate

	GetRootDomainReference() *Reference
	GetDiscoveryNodes() []DiscoveryNode

	GetMajorityRule() int
	GetMinRoles() (virtual uint, heavyMaterial uint, lightMaterial uint)
}

Certificate interface provides methods to manage keys

type CertificateGetter

type CertificateGetter interface {
	// GetState returns our current thoughs about whole network
	GetCert(context.Context, *Reference) (Certificate, error)
}

type CertificateManager

type CertificateManager interface {
	GetCertificate() Certificate
}

CertificateManager interface provides methods to manage nodes certificate

type ContractConstructor

type ContractConstructor func(args []byte) (state []byte, result []byte, err error)

ContractConstructor is a typedef of typical contract constructor

type ContractConstructors

type ContractConstructors map[string]ContractConstructor

ContractConstructors maps name to contract constructor

type ContractMethod

type ContractMethod func(oldState []byte, args []byte) (newState []byte, result []byte, err error)

ContractConstructor is a typedef for wrapper contract header

type ContractMethods

type ContractMethods map[string]ContractMethod

ContractMethods maps name to contract method

type ContractRequester

type ContractRequester interface {
	Call(ctx context.Context, msg Payload) (Reply, *Reference, error)
	SendRequest(ctx context.Context, ref *Reference, method string, argsIn []interface{}) (Reply, error)
	SendRequestWithPulse(ctx context.Context, ref *Reference, method string, argsIn []interface{}, pulse PulseNumber) (Reply, *Reference, error)
}

ContractRequester is the global contract requester handler. Other system parts communicate with contract requester through it.

type ContractWrapper

type ContractWrapper struct {
	GetCode      ContractMethod
	GetPrototype ContractMethod

	Methods      ContractMethods
	Constructors ContractConstructors
}

ContractWrapper stores all needed about contract wrapper (it's methods/constructors)

type CryptographyService

type CryptographyService interface {
	Signer
	GetPublicKey() (crypto.PublicKey, error)
	Verify(crypto.PublicKey, Signature, []byte) bool
}

type DelegationToken

type DelegationToken interface {
	// Type returns token type.
	Type() DelegationTokenType

	// Verify checks against the token. See also delegationtoken.Verify(...)
	Verify(parcel Parcel) (bool, error)
}

DelegationToken is the base interface for delegation tokens

type DelegationTokenFactory

type DelegationTokenFactory interface {
	IssuePendingExecution(msg Message, pulse PulseNumber) (DelegationToken, error)
	Verify(parcel Parcel) (bool, error)
}

type DelegationTokenType

type DelegationTokenType byte

DelegationTokenType is an enum type of delegation token

const (
	// DTTypePendingExecution allows to continue method calls
	DTTypePendingExecution DelegationTokenType = iota + 1
	DTTypeGetObjectRedirect
	DTTypeGetCodeRedirect
)

func (DelegationTokenType) String

func (i DelegationTokenType) String() string

type DiscoveryNode

type DiscoveryNode interface {
	NodeMeta

	GetRole() StaticRole
	GetHost() string
}

type DiscoveryNodeRegister

type DiscoveryNodeRegister struct {
	Role      string
	PublicKey string
}

DiscoveryNodeRegister carries data required for registering discovery node via genesis.

type DynamicRole

type DynamicRole int

DynamicRole is number representing a node role.

func (DynamicRole) IsVirtualRole

func (r DynamicRole) IsVirtualRole() bool

IsVirtualRole checks if node role is virtual (validator or executor).

func (DynamicRole) String

func (i DynamicRole) String() string

type Entropy

type Entropy [EntropySize]byte

Entropy is 64 random bytes used in every pseudo-random calculations.

func (Entropy) Compare

func (entropy Entropy) Compare(other Entropy) int

func (Entropy) Equal

func (entropy Entropy) Equal(other Entropy) bool

func (Entropy) Marshal

func (entropy Entropy) Marshal() ([]byte, error)

func (Entropy) MarshalTo

func (entropy Entropy) MarshalTo(data []byte) (int, error)

func (Entropy) Size

func (entropy Entropy) Size() int

func (*Entropy) Unmarshal

func (entropy *Entropy) Unmarshal(data []byte) error

func (*Entropy) UnmarshalJSON

func (entropy *Entropy) UnmarshalJSON(data []byte) error

type GenesisContractState

type GenesisContractState struct {
	Name       string
	Prototype  string
	ParentName string
	Memory     []byte
}

GenesisContractState carries data required for contract object creation via genesis.

type GenesisContractsConfig

type GenesisContractsConfig struct {
	RootBalance               string
	MDBalance                 string
	RootPublicKey             string
	MigrationAdminPublicKey   string
	MigrationDaemonPublicKeys []string
	VestingPeriodInPulses     int64
	LokupPeriodInPulses       int64
	MigrationAddresses        [GenesisAmountMigrationAddressShards][]string
}

GenesisContractsConfig carries data required for contract object initialization via genesis.

type GenesisHeavyConfig

type GenesisHeavyConfig struct {
	// DiscoveryNodes is the list with discovery node info.
	DiscoveryNodes  []DiscoveryNodeRegister
	ContractsConfig GenesisContractsConfig
	// Skip is flag for skipping genesis on heavy node. Useful for some test cases.
	Skip bool
}

GenesisHeavyConfig carries data required for initial genesis on heavy node.

type GlobuleID

type GlobuleID uint32

GlobuleID is the ID of the globe

type Hasher

type Hasher interface {
	hash.Hash

	Hash([]byte) []byte
}

type HealthChecker

type HealthChecker interface {
	// IsAlive returns true if todo: fix requirements
	IsAlive() bool
}

HealthChecker interface provides method to check network health

type ID

type ID [RecordIDSize]byte

ID is a unified record ID.

func NewID

func NewID(pulse PulseNumber, hash []byte) *ID

NewID generates ID byte representation.

func NewIDFromBase58

func NewIDFromBase58(str string) (*ID, error)

NewIDFromBase58 deserializes ID from base58 encoded string.

func NewIDFromBytes

func NewIDFromBytes(raw []byte) *ID

NewIDFromBytes converts byte slice to ID.

func (ID) Bytes

func (id ID) Bytes() []byte

Bytes returns byte slice of ID.

func (ID) Compare

func (id ID) Compare(other ID) int

func (*ID) DebugString

func (id *ID) DebugString() string

DebugString prints ID in human readable form.

func (*ID) Equal

func (id *ID) Equal(other ID) bool

Equal checks if reference points to the same record.

func (*ID) Hash

func (id *ID) Hash() []byte

Hash returns a copy of Hash part of ID.

func (ID) IsEmpty

func (id ID) IsEmpty() bool

IsEmpty - check for void

func (ID) Marshal

func (id ID) Marshal() ([]byte, error)

func (*ID) MarshalJSON

func (id *ID) MarshalJSON() ([]byte, error)

MarshalJSON serializes ID into JSONFormat.

func (*ID) MarshalTo

func (id *ID) MarshalTo(data []byte) (int, error)

func (ID) NotEmpty

func (id ID) NotEmpty() bool

NotEmpty - check for void

func (*ID) Pulse

func (id *ID) Pulse() PulseNumber

Pulse returns a copy of Pulse part of ID.

func (*ID) Size

func (id *ID) Size() int

func (ID) String

func (id ID) String() string

String implements stringer on ID and returns base58 encoded value

func (*ID) Unmarshal

func (id *ID) Unmarshal(data []byte) error

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

type JetID

type JetID ID

JetID should be used, when id is a jetID

func NewJetID

func NewJetID(depth uint8, prefix []byte) *JetID

NewJetID creates a new jet with provided ID and index

func (JetID) DebugString

func (id JetID) DebugString() string

DebugString prints JetID in human readable form.

func (JetID) Depth

func (id JetID) Depth() uint8

Depth extracts depth from a jet id.

func (JetID) Equal

func (id JetID) Equal(other JetID) bool

func (JetID) IsEmpty

func (id JetID) IsEmpty() bool

IsEmpty - check for void

func (*JetID) IsValid

func (id *JetID) IsValid() bool

IsValid returns true is JetID has a predefined reserved pulse number.

func (JetID) Marshal

func (id JetID) Marshal() ([]byte, error)

func (*JetID) MarshalTo

func (id *JetID) MarshalTo(data []byte) (n int, err error)

MarshalTo is a protobuf required method. It marshals data

func (JetID) Prefix

func (id JetID) Prefix() []byte

Prefix extracts prefix from a jet id.

func (*JetID) Size

func (id *JetID) Size() int

Size is a protobuf required method. It returns size of JetID

func (*JetID) Unmarshal

func (id *JetID) Unmarshal(data []byte) error

Unmarshal is a protobuf required method. It unmarshals data

type JetIDCollection

type JetIDCollection []JetID

func (JetIDCollection) DebugString

func (ids JetIDCollection) DebugString() string

type KeyProcessor

type KeyProcessor interface {
	GeneratePrivateKey() (crypto.PrivateKey, error)
	ExtractPublicKey(crypto.PrivateKey) crypto.PublicKey

	ExportPublicKeyPEM(crypto.PublicKey) ([]byte, error)
	ImportPublicKeyPEM([]byte) (crypto.PublicKey, error)

	ExportPrivateKeyPEM(crypto.PrivateKey) ([]byte, error)
	ImportPrivateKeyPEM([]byte) (crypto.PrivateKey, error)

	ExportPublicKeyBinary(crypto.PublicKey) ([]byte, error)
	ImportPublicKeyBinary([]byte) (crypto.PublicKey, error)
}

type KeyStore

type KeyStore interface {
	GetPrivateKey(string) (crypto.PrivateKey, error)
}

type LeaveApproved

type LeaveApproved struct{}

type Leaver

type Leaver interface {
	// Leave notify other nodes that this node want to leave and doesn't want to receive new tasks
	Leave(ctx context.Context, ETA PulseNumber)
}

type LogFormat

type LogFormat uint8
const (
	TextFormat LogFormat = iota
	JSONFormat
)

func ParseFormat

func ParseFormat(formatStr string) (LogFormat, error)

func (LogFormat) String

func (l LogFormat) String() string

type LogLevel

type LogLevel uint8

full copy of zerolog functions to work with logging level needed to support logging level in packet

const (
	NoLevel LogLevel = iota
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
	PanicLevel
)

NoLevel means it should be ignored

func ParseLevel

func ParseLevel(levelStr string) (LogLevel, error)

func (LogLevel) Equal

func (l LogLevel) Equal(other LogLevel) bool

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	// WithLevel sets log level.
	WithLevel(string) (Logger, error)
	// WithLevelNumber sets log level with number
	WithLevelNumber(level LogLevel) (Logger, error)
	// WithFormat sets logger output format
	WithFormat(format LogFormat) (Logger, error)

	// WithCaller switch on/off 'caller' field computation.
	WithCaller(flag bool) Logger
	// WithSkipFrameCount changes skipFrameCount by delta value (it can be negative).
	WithSkipFrameCount(delta int) Logger
	// WithFuncName switch on/off 'func' field computation.
	WithFuncName(flag bool) Logger

	// Debug logs a message at level Debug.
	Debug(...interface{})
	// Debugf formatted logs a message at level Debug.
	Debugf(string, ...interface{})

	// Info logs a message at level Info.
	Info(...interface{})
	// Infof formatted logs a message at level Info.
	Infof(string, ...interface{})

	// Warn logs a message at level Warn.
	Warn(...interface{})
	// Warnf logs a message at level Warn.
	Warnf(string, ...interface{})

	// Error logs a message at level Error.
	Error(...interface{})
	// Errorf logs a message at level Error.
	Errorf(string, ...interface{})

	// Fatal logs a message at level Fatal and than call os.exit().
	Fatal(...interface{})
	// Fatalf formatted logs a message at level Fatal and than call os.exit().
	Fatalf(string, ...interface{})

	// Panic logs a message at level Panic and than call panic().
	Panic(...interface{})
	// Panicf formatted logs a message at level Panic and than call panic().
	Panicf(string, ...interface{})

	// SetOutput sets the output destination for the logger.
	WithOutput(w io.Writer) Logger
	// WithFields return copy of Logger with predefined fields.
	WithFields(map[string]interface{}) Logger
	// WithField return copy of Logger with predefined single field.
	WithField(string, interface{}) Logger

	// Is returns if passed log level equal current log level
	Is(level LogLevel) bool
}

Logger is the interface for loggers used in the Insolar components.

type LogicCallContext

type LogicCallContext struct {
	Mode CallMode // either "execution" or "validation"

	Request *Reference // reference of incoming request record

	Callee    *Reference // Contract that is called
	Parent    *Reference // Parent of the callee
	Prototype *Reference // Prototype (base class) of the callee
	Code      *Reference // Code reference of the callee

	Caller          *Reference // Contract that made the call
	CallerPrototype *Reference // Prototype (base class) of the caller

	TraceID string // trace mark for Jaegar and friends
}

LogicCallContext is a context of contract execution. Everything that is required to implement foundation functions. This struct shouldn't be used in core components.

type LogicRunner

type LogicRunner interface {
	LRI()
	OnPulse(context.Context, Pulse, Pulse) error
	AddUnwantedResponse(ctx context.Context, msg Payload) error
}

LogicRunner is an interface that should satisfy logic executor

type MachineLogicExecutor

type MachineLogicExecutor interface {
	CallMethod(
		ctx context.Context, callContext *LogicCallContext,
		code Reference, data []byte,
		method string, args Arguments,
	) (
		newObjectState []byte, methodResults Arguments, err error,
	)
	CallConstructor(
		ctx context.Context, callContext *LogicCallContext,
		code Reference, name string, args Arguments,
	) (
		objectState []byte, result Arguments, err error,
	)
}

MachineLogicExecutor is an interface for implementers of one particular machine type

type MachineType

type MachineType int

MachineType is a type of virtual machine

const (
	MachineTypeNotExist             = 0
	MachineTypeBuiltin  MachineType = iota + 1
	MachineTypeGoPlugin

	MachineTypesLastID
)

Real constants of MachineType

func (MachineType) Equal

func (m MachineType) Equal(other MachineType) bool

type Message

type Message interface {
	// Type returns message type.
	Type() MessageType

	// GetCaller returns initiator of this event.
	GetCaller() *Reference

	// DefaultTarget returns of target of this event.
	DefaultTarget() *Reference

	// DefaultRole returns role for this event
	DefaultRole() DynamicRole

	// AllowedSenderObjectAndRole extracts information from message
	// verify sender required to 's "caller" for sender
	// verification purpose. If nil then check of sender's role is not
	// provided by the message bus
	AllowedSenderObjectAndRole() (*Reference, DynamicRole)
}

Message is a routable packet, ATM just a method call

type MessageHandler

type MessageHandler func(context.Context, Parcel) (Reply, error)

MessageHandler is a function for message handling. It should be registered via Register method.

type MessageSendOptions

type MessageSendOptions struct {
	Receiver *Reference
	Token    DelegationToken
}

MessageSendOptions represents options for message sending.

func (*MessageSendOptions) Safe

Safe returns original options, falling back on defaults if nil.

type MessageSignature

type MessageSignature interface {
	GetSign() []byte
	GetSender() Reference
	SetSender(Reference)
}

type MessageType

type MessageType byte

MessageType is an enum type of message.

const (
	// TypeValidationResults sends from Validator to new Executor with results of validation actions of previous Executor
	TypeValidationResults MessageType = iota

	// TypeGenesisRequest used for bootstrap object generation.
	TypeGenesisRequest
)

func (MessageType) String

func (i MessageType) String() string

type NetworkNode

type NetworkNode interface {
	// ID is the unique identifier of the node
	ID() Reference
	// ShortID get short ID of node
	ShortID() ShortNodeID
	// Role is the candidate Role for the node
	Role() StaticRole
	// PublicKey is the public key of the node
	PublicKey() crypto.PublicKey
	// Address is the network address of the node
	Address() string
	// GetGlobuleID returns node current globule id
	GetGlobuleID() GlobuleID
	// Version of node software
	Version() string
	// LeavingETA is pulse number, after which node leave
	LeavingETA() PulseNumber
	// GetState get state of the node
	GetState() NodeState
	// GetPower get power of node
	GetPower() Power
}

type NetworkState

type NetworkState int

NetworkState type for bootstrapping process

const (
	// NoNetworkState state means that nodes doesn`t match majority_rule
	NoNetworkState NetworkState = iota
	JoinerBootstrap
	WaitConsensus
	WaitMajority
	WaitMinRoles
	WaitPulsar
	CompleteNetworkState
)

func (NetworkState) String

func (i NetworkState) String() string

type NetworkStatus

type NetworkStatus interface {
	GetNetworkStatus() StatusReply
}

type Node

type Node struct {
	ID   Reference
	Role StaticRole
}

Node represents insolar node.

type NodeMeta

type NodeMeta interface {
	GetNodeRef() *Reference
	GetPublicKey() crypto.PublicKey
}

type NodeState

type NodeState uint8

NodeState is the state of the node

const (
	// NodeUndefined node started but is not connected to network yet
	NodeUndefined NodeState = iota
	// NodeJoining node is in first pulse of discovery bootstrap or is joining to a bootstrapped network
	NodeJoining
	// NodeReady node is connected to network
	NodeReady
	// NodeLeaving node is about to leave network
	NodeLeaving
)

func (NodeState) String

func (i NodeState) String() string

type Parcel

type Parcel interface {
	Message
	MessageSignature

	Message() Message
	Context(context.Context) context.Context

	Pulse() PulseNumber

	DelegationToken() DelegationToken
}

Parcel by senders private key.

type Payload

type Payload interface {
	Marshal() ([]byte, error)
}

Payload represents any kind of data that can be encoded in consistent manner.

type PendingState

type PendingState int

PendingState is a state of execution for each object

const (
	PendingUnknown PendingState = iota // PendingUnknown signalizes that we don't know about execution state
	NotPending                         // NotPending means that we know that this task is not executed by another VE
	InPending                          // InPending means that we know that method on object is executed by another VE
)

func (PendingState) Equal

func (s PendingState) Equal(other PendingState) bool

type PlatformCryptographyScheme

type PlatformCryptographyScheme interface {
	PublicKeySize() int
	SignatureSize() int
	ReferenceHashSize() int
	IntegrityHashSize() int

	ReferenceHasher() Hasher
	IntegrityHasher() Hasher

	DataSigner(crypto.PrivateKey, Hasher) Signer
	DigestSigner(key crypto.PrivateKey) Signer
	DataVerifier(crypto.PublicKey, Hasher) Verifier
	DigestVerifier(crypto.PublicKey) Verifier
}

type Power

type Power uint8

Power is node power

type Pulse

type Pulse struct {
	PulseNumber     PulseNumber
	PrevPulseNumber PulseNumber
	NextPulseNumber PulseNumber

	PulseTimestamp   int64
	EpochPulseNumber int
	OriginID         [OriginIDSize]byte

	Entropy Entropy
	Signs   map[string]PulseSenderConfirmation
}

Pulse is base data structure for a pulse.

type PulseDistributor

type PulseDistributor interface {
	// Distribute distributes a pulse across the network.
	Distribute(context.Context, Pulse)
}

PulseDistributor is interface for pulse distribution.

type PulseManager

type PulseManager interface {
	// Set set's new pulse and closes current jet drop. If dry is true, nothing will be saved to storage.
	Set(ctx context.Context, pulse Pulse) error
}

PulseManager provides Ledger's methods related to Pulse.

type PulseNumber

type PulseNumber pulse.Number

PulseNumber is a sequential number of Pulse. Upper 2 bits are reserved for use in references (scope), must be zero otherwise. Valid Absolute PulseNumber must be >65536. If PulseNumber <65536 it is a relative PulseNumber

func NewPulseNumber

func NewPulseNumber(buf []byte) PulseNumber

NewPulseNumber creates pulse number from bytes.

func NewPulseNumberFromStr

func NewPulseNumberFromStr(pn string) (PulseNumber, error)

func (PulseNumber) Bytes

func (pn PulseNumber) Bytes() []byte

Bytes serializes pulse number.

func (PulseNumber) Equal

func (pn PulseNumber) Equal(other PulseNumber) bool

func (*PulseNumber) MarshalTo

func (pn *PulseNumber) MarshalTo(data []byte) (int, error)

func (PulseNumber) Size

func (pn PulseNumber) Size() int

func (PulseNumber) String

func (pn PulseNumber) String() string

func (*PulseNumber) Unmarshal

func (pn *PulseNumber) Unmarshal(data []byte) error

type PulseRange

type PulseRange struct {
	Begin PulseNumber
	End   PulseNumber
}

PulseRange represents range of pulses.

func (*PulseRange) String

func (pr *PulseRange) String() string

type PulseSenderConfirmation

type PulseSenderConfirmation struct {
	PulseNumber     PulseNumber
	ChosenPublicKey string
	Entropy         Entropy
	Signature       []byte
}

PulseSenderConfirmation contains confirmations of the pulse from other pulsars Because the system is using BFT for consensus between pulsars, because of it All pulsar send to the chosen pulsar their confirmations Every node in the network can verify the signatures

type RedirectReply

type RedirectReply interface {
	// Redirected creates redirected message from redirect data.
	Redirected(genericMsg Message) Message
	// GetReceiver returns node reference to send message to.
	GetReceiver() *Reference
	// GetToken returns delegation token.
	GetToken() DelegationToken
}

RedirectReply is used to create redirected messages.

type Reference

type Reference [RecordRefSize]byte

Reference is a unified record reference.

func NewEmptyReference

func NewEmptyReference() *Reference

NewEmptyReference returns empty Reference.

func NewReference

func NewReference(id ID) *Reference

NewReference returns Reference composed from domain and record.

func NewReferenceFromBase58

func NewReferenceFromBase58(str string) (*Reference, error)

NewReferenceFromBase58 deserializes reference from base58 encoded string.

func NewReferenceFromBytes

func NewReferenceFromBytes(from []byte) *Reference

NewReferenceFromBytes : After CBOR Marshal/Unmarshal Ref can be converted to byte slice, this converts it back

func (Reference) Bytes

func (ref Reference) Bytes() []byte

Bytes returns byte slice of Reference.

func (Reference) Compare

func (ref Reference) Compare(other Reference) int

Compare compares two record references

func (Reference) Domain

func (ref Reference) Domain() *ID

Domain returns domain ID part of reference.

func (Reference) Equal

func (ref Reference) Equal(other Reference) bool

Equal checks if reference points to the same record.

func (Reference) IsEmpty

func (ref Reference) IsEmpty() bool

IsEmpty - check for void

func (Reference) Marshal

func (ref Reference) Marshal() ([]byte, error)

func (*Reference) MarshalJSON

func (ref *Reference) MarshalJSON() ([]byte, error)

MarshalJSON serializes reference into JSONFormat.

func (*Reference) MarshalTo

func (ref *Reference) MarshalTo(data []byte) (int, error)

func (*Reference) Record

func (ref *Reference) Record() *ID

Record returns record's ID.

func (*Reference) Size

func (ref *Reference) Size() int

func (Reference) String

func (ref Reference) String() string

String outputs base58 Reference representation.

func (*Reference) Unmarshal

func (ref *Reference) Unmarshal(data []byte) error

func (*Reference) UnmarshalJSON

func (ref *Reference) UnmarshalJSON(data []byte) error

type Reply

type Reply interface {
	// Type returns message type.
	Type() ReplyType
}

Reply for an `Message`

type ReplyType

type ReplyType byte

ReplyType is an enum type of message reply.

type ShortNodeID

type ShortNodeID uint32 // ZERO is RESERVED

ShortNodeID is the shortened ID of node that is unique inside the globe

const AbsentShortNodeID ShortNodeID = 0

func (ShortNodeID) Equal

func (v ShortNodeID) Equal(other ShortNodeID) bool

func (ShortNodeID) IsAbsent

func (v ShortNodeID) IsAbsent() bool

type Signature

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

func SignatureFromBytes

func SignatureFromBytes(raw []byte) Signature

func (*Signature) Bytes

func (s *Signature) Bytes() []byte

type Signer

type Signer interface {
	Sign([]byte) (*Signature, error)
}

type StaticRole

type StaticRole uint32

StaticRole holds role of node.

func GetStaticRoleFromString

func GetStaticRoleFromString(role string) StaticRole

GetStaticRoleFromString converts role from string to StaticRole.

func (StaticRole) String

func (nr StaticRole) String() string

type StatusReply

type StatusReply struct {
	NetworkState    NetworkState
	Origin          NetworkNode
	ActiveListSize  int
	WorkingListSize int
	// Nodes from active list
	Nodes []NetworkNode
	// Pulse from network pulse storage
	Pulse     Pulse
	Version   string
	Timestamp time.Time
	// node start timestamp for uptime duration
	StartTime time.Time
}

type TerminationHandler

type TerminationHandler interface {
	// Leave locks until network accept leaving claim
	Leave(context.Context, PulseNumber)
	OnLeaveApproved(context.Context)
	// Abort forces to stop all node components
	Abort(reason string)
	// Terminating is an accessor
	Terminating() bool
}

TerminationHandler handles such node events as graceful stop, abort, etc.

type Verifier

type Verifier interface {
	Verify(Signature, []byte) bool
}

Directories

Path Synopsis
Package backoff provides an exponential-backoff implementation.
Package backoff provides an exponential-backoff implementation.
bus
Package delegationtoken is about an authorization token that allows a node to perform actions it can not normally perform during this pulse
Package delegationtoken is about an authorization token that allows a node to perform actions it can not normally perform during this pulse
bus
Package gen contains functions for generating random base insolar types.
Package gen contains functions for generating random base insolar types.
Package jet provides objects and interfaces for working with Jet objects.
Package jet provides objects and interfaces for working with Jet objects.
Package jetcoordinator is responsible for all jet manipulations.
Package jetcoordinator is responsible for all jet manipulations.
Package message represents message that messagebus can route
Package message represents message that messagebus can route
Package node contains node storage
Package node contains node storage
Package Pulse contains Pulse storage.
Package Pulse contains Pulse storage.
Package reply represents responses to messages of the messagebus
Package reply represents responses to messages of the messagebus
Package db contains primitives for storing and indexing data.
Package db contains primitives for storing and indexing data.

Jump to

Keyboard shortcuts

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