Documentation ¶
Overview ¶
Package core contains common definitions used by other modules.
Index ¶
- Constants
- Variables
- func ContextWithMessageBus(ctx context.Context, bus MessageBus) context.Context
- func Deserialize(data []byte, to interface{}) error
- func KVSize(kvs []KV) (amount int64)
- func Serialize(o interface{}) ([]byte, error)
- func UnMarshalResponse(resp []byte, typeHolders []interface{}) ([]interface{}, error)
- type APIRunner
- type Arguments
- type ArtifactManager
- type AuthorizationCertificate
- type Cascade
- type Certificate
- type CertificateManager
- type CodeDescriptor
- type Component
- type Components
- type ContractRequester
- type CryptographyService
- type DelegationToken
- type DelegationTokenFactory
- type DelegationTokenType
- type DiscoveryNode
- type DynamicRole
- type Entropy
- type Genesis
- type GenesisDataProvider
- type GlobalInsolarLock
- type GlobuleID
- type Hasher
- type HeavySync
- type JetCoordinator
- type KV
- type KeyProcessor
- type KeyStore
- type Logger
- type LogicCallContext
- type LogicRunner
- type MachineLogicExecutor
- type MachineType
- type Message
- type MessageBus
- type MessageHandler
- type MessageSendOptions
- type MessageSignature
- type MessageType
- type Network
- type NetworkCoordinator
- type NetworkState
- type NetworkSwitcher
- type Node
- type NodeMeta
- type NodeNetwork
- type NodeNetworkState
- type NodeState
- type ObjectDescriptor
- type Parcel
- type PlatformCryptographyScheme
- type Pulse
- type PulseDistributor
- type PulseManager
- type PulseNumber
- type PulseRange
- type PulseSenderConfirmation
- type PulseStorage
- type RecordID
- type RecordRef
- func (ref RecordRef) Bytes() []byte
- func (ref RecordRef) Compare(other RecordRef) int
- func (ref RecordRef) Domain() *RecordID
- func (ref RecordRef) Equal(other RecordRef) bool
- func (ref RecordRef) FromSlice(from []byte) RecordRef
- func (ref RecordRef) IsEmpty() bool
- func (ref *RecordRef) MarshalJSON() ([]byte, error)
- func (ref *RecordRef) Record() *RecordID
- func (ref *RecordRef) SetDomain(recID RecordID)
- func (ref *RecordRef) SetRecord(recID RecordID)
- func (ref RecordRef) String() string
- type RedirectReply
- type RefIterator
- type RemoteProcedure
- type Reply
- type ReplyType
- type ShortNodeID
- type Signature
- type Signer
- type StaticRole
- type StorageExportResult
- type StorageExporter
- type SwitcherWorkAround
- type TapeWriter
- type TerminationHandler
- type Verifier
Constants ¶
const ( // JetSize is a Jet's size (depth+prefix). JetSize = RecordIDSize - PulseNumberSize // JetPrefixSize is a Jet's prefix size. JetPrefixSize = JetSize - 1 )
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 )
const ( StaticRoleUnknown = StaticRole(iota) StaticRoleVirtual StaticRoleHeavyMaterial StaticRoleLightMaterial )
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 )
const ( // FirstPulseNumber is the hardcoded first pulse number. Because first 65536 numbers are saved for the system's needs FirstPulseNumber = 65537 // PulseNumberJet is a special pulse number value that signifies jet ID. PulseNumberJet = PulseNumber(1) // PulseNumberCurrent is a special pulse number value that signifies current pulse number. PulseNumberCurrent = PulseNumber(2) )
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 // RecordRefSize is absolute records address (including domain ID). RecordRefSize = RecordIDSize * 2 // RecordRefIDSeparator is character that separates RecordID from DomainID in serialized RecordRef RecordRefIDSeparator = "." )
Variables ¶
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") // ErrNoNodes is returned if no matching nodes found ErrNoNodes = errors.New("no matching nodes") )
var ( // TODOJetID temporary stub for passing jet ID in ledger functions // on period Jet ID full implementation // TODO: remove it after jets support readyness - @nordicdyno 5.Dec.2018 TODOJetID = *NewRecordID(PulseNumberJet, nil) DomainID = *NewRecordID(0, nil) )
var AllStaticRoles = []StaticRole{ StaticRoleVirtual, StaticRoleLightMaterial, StaticRoleHeavyMaterial, }
AllStaticRoles is an array of all possible StaticRoles.
var GenesisPulse = &Pulse{ PulseNumber: FirstPulseNumber, Entropy: [EntropySize]byte{}, EpochPulseNumber: 1, PulseTimestamp: firstPulseDate, }
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
Functions ¶
func ContextWithMessageBus ¶ added in v0.6.3
func ContextWithMessageBus(ctx context.Context, bus MessageBus) context.Context
ContextWithMessageBus returns new context with provided message bus.
func Deserialize ¶ added in v0.6.3
Deserialize deserializes data to specific interface
func UnMarshalResponse ¶ added in v0.6.0
UnMarshalResponse unmarshals return values by cbor
Types ¶
type Arguments ¶
type Arguments []byte
Arguments is a dedicated type for arguments, that represented as binary cbored blob
func MarshalArgs ¶ added in v0.6.0
MarshalArgs marshals arguments by cbor
func (*Arguments) MarshalJSON ¶ added in v0.7.5
MarshalJSON uncbor Arguments slice recursively
type ArtifactManager ¶
type ArtifactManager interface { // GenesisRef returns the root record reference. // // Root record is the parent for all top-level records. GenesisRef() *RecordRef // RegisterRequest creates request record in storage. RegisterRequest(ctx context.Context, object RecordRef, parcel Parcel) (*RecordID, error) // RegisterValidation marks provided object state as approved or disapproved. // // When fetching object, validity can be specified. RegisterValidation(ctx context.Context, object RecordRef, state RecordID, isValid bool, validationMessages []Message) error // RegisterResult saves VM method call result. RegisterResult(ctx context.Context, object, request RecordRef, payload []byte) (*RecordID, error) // GetCode returns code from code record by provided reference according to provided machine preference. // // This method is used by VM to fetch code for execution. GetCode(ctx context.Context, ref RecordRef) (CodeDescriptor, error) // GetObject returns descriptor for provided state. // // If provided state is nil, the latest state will be returned (with deactivation check). Returned descriptor will // provide methods for fetching all related data. GetObject(ctx context.Context, head RecordRef, state *RecordID, approved bool) (ObjectDescriptor, error) // GetPendingRequest returns a pending request for object. GetPendingRequest(ctx context.Context, objectID RecordID) (Parcel, error) // HasPendingRequests returns true if object has unclosed requests. HasPendingRequests(ctx context.Context, object RecordRef) (bool, error) // GetDelegate returns provided object's delegate reference for provided type. // // Object delegate should be previously created for this object. If object delegate does not exist, an error will // be returned. GetDelegate(ctx context.Context, head, asType RecordRef) (*RecordRef, error) // GetChildren returns children iterator. // // During iteration children refs will be fetched from remote source (parent object). GetChildren(ctx context.Context, parent RecordRef, pulse *PulseNumber) (RefIterator, error) // DeclareType creates new type record in storage. // // Type is a contract interface. It contains one method signature. DeclareType(ctx context.Context, domain, request RecordRef, typeDec []byte) (*RecordID, error) // DeployCode creates new code record in storage. // // Code records are used to activate prototype. DeployCode(ctx context.Context, domain, request RecordRef, code []byte, machineType MachineType) (*RecordID, error) // ActivatePrototype creates activate object record in storage. Provided prototype reference will be used as objects prototype // memory as memory of created object. If memory is not provided, the prototype default memory will be used. // // Request reference will be this object's identifier and referred as "object head". ActivatePrototype( ctx context.Context, domain, request, parent, code RecordRef, memory []byte, ) (ObjectDescriptor, error) // ActivateObject creates activate object record in storage. If memory is not provided, the prototype default // memory will be used. // // Request reference will be this object's identifier and referred as "object head". ActivateObject( ctx context.Context, domain, request, parent, prototype RecordRef, asDelegate bool, memory []byte, ) (ObjectDescriptor, error) // UpdatePrototype creates amend object record in storage. Provided reference should be a reference to the head of // the prototype. Provided memory well be the new object memory. // // Returned reference will be the latest object state (exact) reference. UpdatePrototype( ctx context.Context, domain, request RecordRef, obj ObjectDescriptor, memory []byte, code *RecordRef, ) (ObjectDescriptor, error) // UpdateObject creates amend object record in storage. Provided reference should be a reference to the head of the // object. Provided memory well be the new object memory. // // Returned reference will be the latest object state (exact) reference. UpdateObject( ctx context.Context, domain, request RecordRef, obj ObjectDescriptor, memory []byte, ) (ObjectDescriptor, error) // DeactivateObject creates deactivate object record in storage. Provided reference should be a reference to the head // of the object. If object is already deactivated, an error should be returned. // // Deactivated object cannot be changed. DeactivateObject(ctx context.Context, domain, request RecordRef, obj ObjectDescriptor) (*RecordID, error) // State returns hash state for artifact manager. State() ([]byte, error) }
ArtifactManager is a high level storage interface.
type AuthorizationCertificate ¶ added in v0.7.5
type AuthorizationCertificate interface { NodeMeta GetRole() StaticRole SerializeNodePart() []byte GetDiscoverySigns() map[RecordRef][]byte }
AuthorizationCertificate interface provides methods to manage info about node from it certificate
type Cascade ¶ added in v0.2.0
type Cascade struct { // NodeIds contains the slice of node identifiers that will receive the message NodeIds []RecordRef // GeneratedEntropy is used for pseudorandom cascade building Entropy Entropy // Replication factor is the number of children nodes of the each node of the cascade ReplicationFactor uint }
Cascade contains routing data for cascade sending
type Certificate ¶ added in v0.6.1
type Certificate interface { AuthorizationCertificate GetRootDomainReference() *RecordRef GetDiscoveryNodes() []DiscoveryNode }
Certificate interface provides methods to manage keys
type CertificateManager ¶ added in v0.7.5
type CertificateManager interface { GetCertificate() Certificate VerifyAuthorizationCertificate(authCert AuthorizationCertificate) (bool, error) NewUnsignedCertificate(pKey string, role string, nodeRef string) (Certificate, error) }
CertificateManager interface provides methods to manage nodes certificate
type CodeDescriptor ¶
type CodeDescriptor interface { // Ref returns reference to represented code record. Ref() *RecordRef // MachineType returns code machine type for represented code. MachineType() MachineType // Code returns code data. Code() ([]byte, error) }
CodeDescriptor represents meta info required to fetch all code data.
type Component ¶
type Component interface { Start(ctx context.Context, components Components) error Stop(ctx context.Context) error }
Component controller methods Deprecated: and should be removed
type Components ¶
type Components struct { NodeNetwork NodeNetwork LogicRunner LogicRunner Network Network MessageBus MessageBus }
Components is a registry for other core interfaces Fields order are important and represent start and stop order in the daemon Deprecated: and should be removed after drop TmpLedger, DO NOT EDIT
type ContractRequester ¶ added in v0.6.3
type ContractRequester interface { SendRequest(ctx context.Context, ref *RecordRef, method string, argsIn []interface{}) (Reply, error) // CallMethod - low level calls contract CallMethod(ctx context.Context, base Message, async bool, ref *RecordRef, method string, argsIn Arguments, mustPrototype *RecordRef) (Reply, error) CallConstructor(ctx context.Context, base Message, async bool, prototype *RecordRef, to *RecordRef, method string, argsIn Arguments, saveType int) (*RecordRef, error) }
ContractRequester is the global contract requester handler. Other system parts communicate with contract requester through it.
type CryptographyService ¶ added in v0.6.3
type DelegationToken ¶ added in v0.6.3
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 ¶ added in v0.6.3
type DelegationTokenFactory interface { IssuePendingExecution(msg Message, pulse PulseNumber) (DelegationToken, error) IssueGetObjectRedirect(sender *RecordRef, redirectedMessage Message) (DelegationToken, error) IssueGetChildrenRedirect(sender *RecordRef, redirectedMessage Message) (DelegationToken, error) IssueGetCodeRedirect(sender *RecordRef, redirectedMessage Message) (DelegationToken, error) Verify(parcel Parcel) (bool, error) }
type DelegationTokenType ¶ added in v0.6.3
type DelegationTokenType byte
DelegationTokenType is an enum type of delegation token
const ( // DTTypePendingExecution allows to continue method calls DTTypePendingExecution DelegationTokenType = iota + 1 DTTypeGetObjectRedirect DTTypeGetChildrenRedirect DTTypeGetCodeRedirect )
func (DelegationTokenType) String ¶ added in v0.6.3
func (i DelegationTokenType) String() string
type DiscoveryNode ¶ added in v0.6.3
type DynamicRole ¶ added in v0.6.3
type DynamicRole int
DynamicRole is number representing a node role.
func (DynamicRole) IsVirtualRole ¶ added in v0.7.5
func (r DynamicRole) IsVirtualRole() bool
IsVirtualRole checks if node role is virtual (validator or executor).
type Entropy ¶ added in v0.2.0
type Entropy [EntropySize]byte
Entropy is 64 random bytes used in every pseudo-random calculations.
type Genesis ¶ added in v0.6.3
type Genesis interface{}
Genesis is the global genesis handler. Other system parts communicate with genesis through it.
type GenesisDataProvider ¶ added in v0.6.3
type GenesisDataProvider interface { GetRootDomain(ctx context.Context) *RecordRef GetNodeDomain(ctx context.Context) (*RecordRef, error) GetRootMember(ctx context.Context) (*RecordRef, error) }
GenesisDataProvider is the global genesis data provider handler. Other system parts communicate with genesis data provider through it.
type GlobalInsolarLock ¶ added in v0.6.3
GlobalInsolarLock is lock of all incoming and outcoming network calls. It's not intended to be used in multiple threads. And main use of it is `Set` method of `PulseManager`.
type HeavySync ¶ added in v0.6.3
type HeavySync interface { Start(ctx context.Context, jet RecordID, pn PulseNumber) error Store(ctx context.Context, jet RecordID, pn PulseNumber, kvs []KV) error Stop(ctx context.Context, jet RecordID, pn PulseNumber) error Reset(ctx context.Context, jet RecordID, pn PulseNumber) error }
HeavySync provides methods for sync on heavy node.
type JetCoordinator ¶ added in v0.0.6
type JetCoordinator interface { // Me returns current node. Me() RecordRef // IsAuthorized checks for role on concrete pulse for the address. IsAuthorized(ctx context.Context, role DynamicRole, obj RecordID, pulse PulseNumber, node RecordRef) (bool, error) // QueryRole returns node refs responsible for role bound operations for given object and pulse. QueryRole(ctx context.Context, role DynamicRole, obj RecordID, pulse PulseNumber) ([]RecordRef, error) VirtualExecutorForObject(ctx context.Context, objID RecordID, pulse PulseNumber) (*RecordRef, error) VirtualValidatorsForObject(ctx context.Context, objID RecordID, pulse PulseNumber) ([]RecordRef, error) LightExecutorForObject(ctx context.Context, objID RecordID, pulse PulseNumber) (*RecordRef, error) LightValidatorsForObject(ctx context.Context, objID RecordID, pulse PulseNumber) ([]RecordRef, error) // LightExecutorForJet calculates light material executor for provided jet. LightExecutorForJet(ctx context.Context, jetID RecordID, pulse PulseNumber) (*RecordRef, error) LightValidatorsForJet(ctx context.Context, jetID RecordID, pulse PulseNumber) ([]RecordRef, error) Heavy(ctx context.Context, pulse PulseNumber) (*RecordRef, error) IsBeyondLimit(ctx context.Context, currentPN, targetPN PulseNumber) (bool, error) NodeForJet(ctx context.Context, jetID RecordID, rootPN, targetPN PulseNumber) (*RecordRef, error) // NodeForObject calculates a node (LME or heavy) for a specific jet for a specific pulseNumber NodeForObject(ctx context.Context, objectID RecordID, rootPN, targetPN PulseNumber) (*RecordRef, error) }
JetCoordinator provides methods for calculating Jet affinity (e.g. to which Jet a message should be sent).
type KeyProcessor ¶ added in v0.6.3
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 ¶ added in v0.6.3
type KeyStore interface {
GetPrivateKey(string) (crypto.PrivateKey, error)
}
type Logger ¶ added in v0.0.6
type Logger interface { // SetLevel sets log level. SetLevel(string) error // 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. SetOutput(w io.Writer) // 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 }
Logger is the interface for loggers used in the Insolar components.
type LogicCallContext ¶ added in v0.0.6
type LogicCallContext struct { Mode string // either "execution" or "validation" Callee *RecordRef // Contract that was called Request *RecordRef // ref of request Prototype *RecordRef // Image of the callee Code *RecordRef // ref of contract code CallerPrototype *RecordRef // Image of the caller Parent *RecordRef // Parent of the callee Caller *RecordRef // Contract that made the call Time time.Time // Time when call was made Pulse Pulse // Number of the pulse TraceID string }
LogicCallContext is a context of contract execution
type LogicRunner ¶
type LogicRunner interface { Execute(context.Context, Parcel) (res Reply, err error) HandleValidateCaseBindMessage(context.Context, Parcel) (res Reply, err error) HandleValidationResultsMessage(context.Context, Parcel) (res Reply, err error) HandleExecutorResultsMessage(context.Context, Parcel) (res Reply, err error) OnPulse(context.Context, Pulse) error }
LogicRunner is an interface that should satisfy logic executor
type MachineLogicExecutor ¶
type MachineLogicExecutor interface { CallMethod( ctx context.Context, callContext *LogicCallContext, code RecordRef, data []byte, method string, args Arguments, ) ( newObjectState []byte, methodResults Arguments, err error, ) CallConstructor( ctx context.Context, callContext *LogicCallContext, code RecordRef, name string, args Arguments, ) ( objectState []byte, err error, ) Stop() 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
type Message ¶
type Message interface { // Type returns message type. Type() MessageType // GetCaller returns initiator of this event. GetCaller() *RecordRef // DefaultTarget returns of target of this event. DefaultTarget() *RecordRef // 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() (*RecordRef, DynamicRole) }
Message is a routable packet, ATM just a method call
type MessageBus ¶ added in v0.4.0
type MessageBus interface { // Send an `Message` and get a `Reply` or error from remote host. Send(context.Context, Message, *MessageSendOptions) (Reply, error) // Register saves message handler in the registry. Only one handler can be registered for a message type. Register(p MessageType, handler MessageHandler) error // MustRegister is a Register wrapper that panics if an error was returned. MustRegister(p MessageType, handler MessageHandler) // NewPlayer creates a new player from stream. This is a very long operation, as it saves replies in storage until the // stream is exhausted. // // Player can be created from MessageBus and passed as MessageBus instance. NewPlayer(ctx context.Context, reader io.Reader) (MessageBus, error) // NewRecorder creates a new recorder with unique tape that can be used to store message replies. // // Recorder can be created from MessageBus and passed as MessageBus instance.s NewRecorder(ctx context.Context, currentPulse Pulse) (MessageBus, error) // Called each new pulse, cleans next pulse messages buffer OnPulse(context.Context, Pulse) error }
MessageBus interface
func MessageBusFromContext ¶ added in v0.6.3
func MessageBusFromContext(ctx context.Context, fallback MessageBus) MessageBus
MessageBusFromContext returns MessageBus from context. If provided context does not have MessageBus, fallback will be returned.
type MessageHandler ¶ added in v0.4.0
MessageHandler is a function for message handling. It should be registered via Register method.
type MessageSendOptions ¶ added in v0.6.3
type MessageSendOptions struct { Receiver *RecordRef Token DelegationToken }
MessageSendOptions represents options for message sending.
func (*MessageSendOptions) Safe ¶ added in v0.6.3
func (o *MessageSendOptions) Safe() *MessageSendOptions
Safe returns original options, falling back on defaults if nil.
type MessageSignature ¶ added in v0.6.3
type MessageType ¶ added in v0.4.0
type MessageType byte
MessageType is an enum type of message.
const ( // TypeCallMethod calls method and returns request TypeCallMethod MessageType = iota // TypeCallConstructor is a message for calling constructor and obtain its reply TypeCallConstructor // TypePutResults when execution finishes, tell results to requester TypeReturnResults // TypeExecutorResults message that goes to new Executor to validate previous Executor actions through CaseBind TypeExecutorResults // TypeValidateCaseBind sends CaseBind form Executor to Validators for redo all actions TypeValidateCaseBind // TypeValidationResults sends from Validator to new Executor with results of validation actions of previous Executor TypeValidationResults // TypePendingFinished is sent by the old executor to the current executor when pending execution finishes TypePendingFinished // TypeStillExecuting is sent by an old executor on pulse switch if it wants to continue executing // to the current executor TypeStillExecuting // TypeGetCode retrieves code from storage. TypeGetCode // TypeGetObject retrieves object from storage. TypeGetObject // TypeGetDelegate retrieves object represented as provided type. TypeGetDelegate // TypeGetChildren retrieves object's children. TypeGetChildren // TypeUpdateObject amends object. TypeUpdateObject // TypeRegisterChild registers child on the parent object. TypeRegisterChild // TypeJetDrop carries jet drop to validators TypeJetDrop // TypeSetRecord saves record in storage. TypeSetRecord // TypeValidateRecord saves record in storage. TypeValidateRecord // TypeSetBlob saves blob in storage. TypeSetBlob // TypeGetObjectIndex fetches object index from storage. TypeGetObjectIndex // TypeGetPendingRequests fetches pending requests for object. TypeGetPendingRequests // TypeHotRecords saves hot-records in storage. TypeHotRecords // TypeGetJet requests to calculate a jet for provided object. TypeGetJet // TypeAbandonedRequestsNotification informs virtual node about unclosed requests. TypeAbandonedRequestsNotification // TypeGetRequest fetches request from ledger. TypeGetRequest // TypeGetPendingRequestID fetches a pending request id from ledger TypeGetPendingRequestID // TypeValidationCheck checks if validation of a particular record can be performed. TypeValidationCheck // TypeHeavyStartStop carries start/stop signal for heavy replication. TypeHeavyStartStop // TypeHeavyPayload carries Key/Value records for replication to Heavy Material node. TypeHeavyPayload // TypeHeavyReset resets current sync (on errors) TypeHeavyReset // TypeBootstrapRequest used for bootstrap object generation. TypeBootstrapRequest // TypeNodeSignRequest used to request sign for new node TypeNodeSignRequest )
func (MessageType) String ¶ added in v0.5.0
func (i MessageType) String() string
type Network ¶
type Network interface { // SendParcel sends a message. SendMessage(nodeID RecordRef, method string, msg Parcel) ([]byte, error) // SendCascadeMessage sends a message. SendCascadeMessage(data Cascade, method string, msg Parcel) error // RemoteProcedureRegister is remote procedure register func. RemoteProcedureRegister(name string, method RemoteProcedure) }
Network is interface for network modules facade.
type NetworkCoordinator ¶ added in v0.6.0
type NetworkCoordinator interface { // GetCert returns certificate object by node reference, using discovery nodes for signing GetCert(context.Context, *RecordRef) (Certificate, error) // ValidateCert checks certificate signature ValidateCert(context.Context, AuthorizationCertificate) (bool, error) // SetPulse uses PulseManager component for saving pulse info SetPulse(ctx context.Context, pulse Pulse) error // IsStarted returns true if component was started and false in other way IsStarted() bool }
NetworkCoordinator encapsulates logic of network configuration
type NetworkState ¶ added in v0.6.3
type NetworkState int
NetworkState type for bootstrapping process
const ( // NoNetworkState state means that nodes doesn`t match majority_rule NoNetworkState NetworkState = iota // VoidNetworkState state means that nodes have not complete min_role_count rule for proper work VoidNetworkState // JetlessNetworkState state means that every Jet need proof completeness of stored data JetlessNetworkState // AuthorizationNetworkState state means that every node need to validate ActiveNodeList using NodeDomain AuthorizationNetworkState // CompleteNetworkState state means network is ok and ready for proper work CompleteNetworkState )
func (NetworkState) String ¶ added in v0.6.3
func (i NetworkState) String() string
type NetworkSwitcher ¶ added in v0.6.3
type NetworkSwitcher interface { // GetState method returns current network state GetState() NetworkState // OnPulse method checks current state and finds out reasons to update this state OnPulse(context.Context, Pulse) error }
NetworkSwitcher is a network FSM using for bootstrapping
type Node ¶ added in v0.6.2
type Node interface { // ID is the unique identifier of the node ID() RecordRef // 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 // ConsensusAddress is the network address of the node for consensus packets exchange ConsensusAddress() string // GetGlobuleID returns node current globule id GetGlobuleID() GlobuleID // Version of node software Version() string // Leaving indicates, that node preparing for graceful shutdown Leaving() bool // LeavingETA is pulse number, after which node leave LeavingETA() PulseNumber // IsWorking true if node is in working node list IsWorking() bool // GetState get state of the node GetState() NodeState }
type NodeNetwork ¶ added in v0.6.2
type NodeNetwork interface { // GetState get state of the NodeKeeper GetState() NodeNetworkState // GetOrigin get origin node for the current insolard. Returns nil if the current insolard is not a working node. GetOrigin() Node // GetWorkingNode get working node by its reference. Returns nil if node is not found. GetWorkingNode(ref RecordRef) Node // GetWorkingNodes get working nodes. GetWorkingNodes() []Node // GetWorkingNodesByRole get working nodes by role GetWorkingNodesByRole(role DynamicRole) []RecordRef }
type NodeNetworkState ¶ added in v0.8.0
type NodeNetworkState uint8
const ( // UndefinedNodeNetworkState is state of NodeKeeper while it is not valid UndefinedNodeNetworkState NodeNetworkState = iota + 1 // WaitingNodeNetworkState is state of NodeKeeper while it is not part of consensus yet (waits for its join claim to pass) WaitingNodeNetworkState // ReadyNodeNetworkState is state of NodeKeeper when it is ready for consensus ReadyNodeNetworkState )
func (NodeNetworkState) String ¶ added in v0.8.0
func (i NodeNetworkState) String() string
type ObjectDescriptor ¶
type ObjectDescriptor interface { // HeadRef returns head reference to represented object record. HeadRef() *RecordRef // StateID returns reference to object state record. StateID() *RecordID // Memory fetches object memory from storage. Memory() []byte // IsPrototype determines if the object is a prototype. IsPrototype() bool // Code returns code reference. Code() (*RecordRef, error) // Prototype returns prototype reference. Prototype() (*RecordRef, error) // Children returns object's children references. Children(pulse *PulseNumber) (RefIterator, error) // ChildPointer returns the latest child for this object. ChildPointer() *RecordID // Parent returns object's parent. Parent() *RecordRef }
ObjectDescriptor represents meta info required to fetch all object data.
type Parcel ¶ added in v0.6.3
type Parcel interface { Message MessageSignature Message() Message Context(context.Context) context.Context Pulse() PulseNumber DelegationToken() DelegationToken }
Parcel by senders private key.
type PlatformCryptographyScheme ¶ added in v0.6.3
type Pulse ¶ added in v0.2.0
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 ¶ added in v0.7.5
type PulseDistributor interface { // Distribute distributes a pulse across the network. Distribute(context.Context, Pulse) }
PulseDistributor is interface for pulse distribution.
type PulseManager ¶ added in v0.2.0
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, persist bool) error }
PulseManager provides Ledger's methods related to Pulse.
type PulseNumber ¶ added in v0.0.6
type PulseNumber uint32
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 CalculatePulseNumber ¶ added in v0.4.0
func CalculatePulseNumber(now time.Time) PulseNumber
CalculatePulseNumber is helper for calculating next pulse number, when a network is being started
func NewPulseNumber ¶ added in v0.6.3
func NewPulseNumber(buf []byte) PulseNumber
NewPulseNumber creates pulse number from bytes.
func (PulseNumber) Bytes ¶ added in v0.2.0
func (pn PulseNumber) Bytes() []byte
Bytes serializes pulse number.
type PulseRange ¶ added in v0.6.3
type PulseRange struct { Begin PulseNumber End PulseNumber }
PulseRange represents range of pulses.
func (*PulseRange) String ¶ added in v0.6.3
func (pr *PulseRange) String() string
type PulseSenderConfirmation ¶ added in v0.4.0
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 PulseStorage ¶ added in v0.7.5
PulseStorage provides the interface for fetching current pulse of the system
type RecordID ¶ added in v0.4.0
type RecordID [RecordIDSize]byte
RecordID is a unified record ID.
func NewIDFromBase58 ¶ added in v0.7.5
NewIDFromBase58 deserializes RecordID from base58 encoded string.
func NewRecordID ¶ added in v0.6.2
func NewRecordID(pulse PulseNumber, hash []byte) *RecordID
NewRecordID generates RecordID byte representation.
func (*RecordID) DebugString ¶ added in v0.7.5
DebugString prints ID in human readable form.
func (*RecordID) MarshalJSON ¶ added in v0.6.3
MarshalJSON serializes ID into JSON.
func (*RecordID) Pulse ¶ added in v0.6.2
func (id *RecordID) Pulse() PulseNumber
Pulse returns a copy of Pulse part of RecordID.
type RecordRef ¶
type RecordRef [RecordRefSize]byte
RecordRef is a unified record reference.
func NewRecordRef ¶ added in v0.6.2
NewRecordRef returns RecordRef composed from domain and record
func NewRefFromBase58 ¶ added in v0.2.0
NewRefFromBase58 deserializes reference from base58 encoded string.
func (RecordRef) FromSlice ¶ added in v0.6.3
FromSlice : After CBOR Marshal/Unmarshal Ref can be converted to byte slice, this converts it back
func (*RecordRef) MarshalJSON ¶ added in v0.6.3
MarshalJSON serializes reference into JSON.
type RedirectReply ¶ added in v0.6.3
type RedirectReply interface { // Redirected creates redirected message from redirect data. Redirected(genericMsg Message) Message // GetReceiver returns node reference to send message to. GetReceiver() *RecordRef // GetToken returns delegation token. GetToken() DelegationToken }
RedirectReply is used to create redirected messages.
type RefIterator ¶ added in v0.0.6
RefIterator is used for iteration over affined children(parts) of container.
type RemoteProcedure ¶
RemoteProcedure is remote procedure call function.
type Reply ¶ added in v0.4.0
type Reply interface { // Type returns message type. Type() ReplyType }
Reply for an `Message`
type ShortNodeID ¶ added in v0.6.3
type ShortNodeID uint32
ShortNodeID is the shortened ID of node that is unique inside the globe
type Signature ¶ added in v0.6.1
type Signature struct {
// contains filtered or unexported fields
}
func SignatureFromBytes ¶ added in v0.6.3
type StaticRole ¶ added in v0.6.3
type StaticRole uint32
StaticRole holds role of node.
func GetStaticRoleFromString ¶ added in v0.6.3
func GetStaticRoleFromString(role string) StaticRole
GetStaticRoleFromString converts role from string to StaticRole.
func (StaticRole) String ¶ added in v0.7.5
func (nr StaticRole) String() string
type StorageExportResult ¶ added in v0.6.3
type StorageExportResult struct { Data map[string]interface{} NextFrom *PulseNumber Size int }
StorageExportResult represents storage data view.
type StorageExporter ¶ added in v0.6.3
type StorageExporter interface { // Export returns data view from storage. Export(ctx context.Context, fromPulse PulseNumber, size int) (*StorageExportResult, error) }
StorageExporter provides methods for fetching data view from storage.
type SwitcherWorkAround ¶ added in v0.6.3
type SwitcherWorkAround interface { // IsBootstrapped method shows that all DiscoveryNodes finds each other IsBootstrapped() bool // SetIsBootstrapped method set is bootstrap completed SetIsBootstrapped(isBootstrap bool) }
TODO: remove this interface when bootstrap mechanism completed SwitcherWorkAround temp interface for NetworkSwitcher interaction
type TapeWriter ¶ added in v0.7.5
type TerminationHandler ¶ added in v0.8.0
type TerminationHandler interface { // Abort forces to stop all node components Abort(reason string) }
TerminationHandler handles such node events as graceful stop, abort, etc.
func NewTerminationHandler ¶ added in v0.8.0
func NewTerminationHandler() TerminationHandler
Source Files ¶
- apirunner.go
- certificate.go
- components.go
- contractrequester.go
- cryptography.go
- delegationtoken.go
- delegationtokentype_string.go
- doc.go
- errors.go
- genesis.go
- genesisdataprovider.go
- heavy.go
- keystore.go
- ledger.go
- logger.go
- messagebus.go
- messagetype_string.go
- network.go
- networkcoordinator.go
- networkstate_string.go
- networkswitcher.go
- nodenetwork.go
- nodenetworkstate_string.go
- noderole.go
- nodestate_string.go
- platformpolicy.go
- pulse.go
- record.go
- serialization.go
- termination_handler.go
- vm.go
Directories ¶
Path | Synopsis |
---|---|
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 |
Package message represents message that messagebus can route
|
Package message represents message that messagebus can route |
Package reply represents responses to messages of the messagebus
|
Package reply represents responses to messages of the messagebus |