me

package
v0.0.0-...-516970c Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: LGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JoinFriendMsg pkgservice.OpType

	// me-oplog
	AddMeOplogMsg
	AddMeOplogsMsg

	AddPendingMeOplogMsg
	AddPendingMeOplogsMsg

	SyncMeOplogMsg // 47
	SyncMeOplogAckMsg
	SyncMeOplogNewOplogsMsg
	SyncMeOplogNewOplogsAckMsg

	InvalidSyncMeOplogMsg

	ForceSyncMeOplogMsg
	ForceSyncMeOplogAckMsg
	ForceSyncMeOplogByMerkleMsg
	ForceSyncMeOplogByMerkleAckMsg
	ForceSyncMeOplogByOplogAckMsg

	SyncPendingMeOplogMsg
	SyncPendingMeOplogAckMsg

	SendRaftMsgsMsg // 53
	RequestRaftLeadMsg

	// init-me-info
	InitMeInfoMsg
	InitMeInfoAckMsg
	InitMeInfoSyncMsg

	// sync-board
	InternalSyncBoardMsg
	InternalSyncBoardAckMsg

	// sync-friend
	InternalSyncFriendMsg
	InternalSyncFriendAckMsg
)

protocol

View Source
const (
	MaxSyncRandomSeconds = 8
	MinSyncRandomSeconds = 5
)

sync

View Source
const (
	SyncJoinSeconds = 10 * time.Second

	RenewJoinFriendKeySeconds = pkgservice.RenewJoinKeySeconds
)

join

View Source
const (
	GenerateMeOplogMerkleTreeSeconds = 10 * time.Second

	ExpireGenerateMeOplogMerkleTreeSeconds = 60
	OffsetGenerateMeOplogMerkleTreeSeconds = 7200

	SleepTimeMeLock = 10
)

me-oplog

View Source
const (
	OffsetMasterOplogRaftIdx = 12

	SleepTimeMasterLock = 10
)

master-oplog

View Source
const (
	RaftTickTime        = 100 * time.Millisecond
	RaftElectionTick    = 50
	RaftHeartbeatTick   = 5
	RaftMaxSizePerMsg   = 1024 * 1024
	RaftMaxInflightMsgs = 16

	NRequestRaftLead = 10
)
View Source
const (
	WeightServer  = 2000000
	WeightDesktop = 2000
	WeightMobile  = 2
)

weight

View Source
const (
	MasterOpTypeAddMaster pkgservice.OpType
	MasterOpTypeRevokeMaster
)
View Source
const (
	MeOpTypeInvalid pkgservice.OpType = iota
	MeOpTypeCreateMe
	MeOpTypeSetNodeName

	OffsetMeOpTypeEntity

	MeOpTypeCreateBoard
	MeOpTypeJoinBoard
	MeOpTypeCreateFriend
	MeOpTypeJoinFriend

	MeOpTypeMigrateMe
	MeOpTypeDeleteMe

	NMeOpType
)
View Source
const (
	InitMeInfoTickTime = 3 * time.Second
)
View Source
const (
	MaxMasters = 0
)
View Source
const (
	NRenewSignKey = 100
)

sign-key

Variables

View Source
var (
	ErrInvalidMe = errors.New("invalid me")

	ErrInvalidNode = errors.New("invalid node")

	ErrInvalidPrivateKeyPostfix = errors.New("private-key and postfix must be specified at the same time")
	ErrInvalidPrivateKey        = errors.New("invalid private key")
	ErrInvalidPrivateKeyFileHex = errors.New("cannot set private-key file / hex at the same time")
	ErrInvalidPrivateKeyFile    = errors.New("invalid private key file")
	ErrInvalidPrivateKeyHex     = errors.New("invalid private key hex")

	ErrAlreadyMyNode = errors.New("already my node")

	ErrInvalidEntry     = errors.New("invalid raft entry")
	ErrInvalidRaftIndex = errors.New("invalid raft index")

	ErrUnableToBeLead = errors.New("unable to be lead")

	ErrWithLead = errors.New("with lead")
)
View Source
var (
	DataDirPrivateKey = "mykey"

	DefaultTitle = []byte("")
)

defaults

View Source
var (
	SleepTimeLock = 10

	DBMePrefix = []byte(".medb")

	DBMyNodePrefix = []byte(".mndb")

	DBRaftPrefix = []byte(".rfdb")

	DBKeyRaftHardState = []byte(".rfhs")
	DBKeyRaftSnapshot  = []byte(".rfsn")

	// raft in me
	DBKeyRaftLastIndex     = []byte(".rfli")
	DBKeyRaftAppliedIndex  = []byte(".rfai")
	DBKeyRaftSnapshotIndex = []byte(".rfsi")
	DBKeyRaftConfState     = []byte(".rfcs")
	DBKeyRaftLead          = []byte(".rfld")
)

db

View Source
var (
	RenewOpKeySeconds  int64 = 86400
	ExpireOpKeySeconds int64 = 259200
)

op-key

View Source
var (
	DBMeOplogPrefix       = []byte(".melg")
	DBMeIdxOplogPrefix    = []byte(".meig")
	DBMeMerkleOplogPrefix = []byte(".memk")

	DBMasterOplogPrefix    = []byte(".malg")
	DBMasterIdxOplogPrefix = []byte(".maig")
)

oplog

View Source
var (
	DefaultConfig = Config{
		DataDir: filepath.Join(node.DefaultDataDir(), "me"),
	}
)

default config

View Source
var (
	MasterIDZeros = make([]byte, OffsetMasterOplogRaftIdx)
)

Functions

func CleanRaftStorage

func CleanRaftStorage(myID *types.PttID, rs *RaftStorage, isLocked bool) error

func InitMe

func InitMe(dataDir string) error

func MasterOplogsToOplogs

func MasterOplogsToOplogs(typedLogs []*MasterOplog) []*pkgservice.BaseOplog

func MeOplogsToOplogs

func MeOplogsToOplogs(typedLogs []*MeOplog) []*pkgservice.BaseOplog

func ProtocolJoinBoardLogs

func ProtocolJoinBoardLogs() error

func ProtocolJoinFriendLogs

func ProtocolJoinFriendLogs() error

func TeardownMe

func TeardownMe()

Types

type ApproveJoinFriend

type ApproveJoinFriend struct {
	FriendData *friend.ApproveJoin `json:"F"`
}

type ApproveJoinMe

type ApproveJoinMe struct {
	MyInfo *MyInfo `json:"M"`

	OpKeyInfo *pkgservice.KeyInfo `json:"O"`
}

type Backend

type Backend struct {
	*pkgservice.BaseService

	Config *Config
	// contains filtered or unexported fields
}

func NewBackend

func NewBackend(ctx *pkgservice.ServiceContext, cfg *Config, ptt pkgservice.MyPtt, accountBackend *account.Backend, contentBackend *content.Backend, friendBacked *friend.Backend) (*Backend, error)

func (*Backend) APIs

func (b *Backend) APIs() []rpc.API

func (*Backend) ForceRemoveNode

func (b *Backend) ForceRemoveNode(nodeIDStr string) (bool, error)

func (*Backend) ForceSyncMeMerkle

func (b *Backend) ForceSyncMeMerkle(entityIDBytes []byte) (bool, error)

func (*Backend) Get

func (b *Backend) Get() (*BackendMyInfo, error)

func (*Backend) GetBoard

func (b *Backend) GetBoard(entityIDBytes []byte) (*content.BackendGetBoard, error)

func (*Backend) GetBoardRequests

func (b *Backend) GetBoardRequests(entityIDBytes []byte) ([]*pkgservice.BackendJoinRequest, error)

func (*Backend) GetFriendRequests

func (b *Backend) GetFriendRequests(entityIDBytes []byte) ([]*pkgservice.BackendJoinRequest, error)

func (*Backend) GetJoinKeys

func (b *Backend) GetJoinKeys(entityIDBytes []byte) ([]*pkgservice.KeyInfo, error)

func (*Backend) GetMeList

func (b *Backend) GetMeList() ([]*BackendMyInfo, error)

func (*Backend) GetMeOplogList

func (b *Backend) GetMeOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MeOplog, error)

func (*Backend) GetMeOplogMerkleNodeList

func (b *Backend) GetMeOplogMerkleNodeList(entityIDBytes []byte, level pkgservice.MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.BackendMerkleNode, error)

func (*Backend) GetMeRequests

func (b *Backend) GetMeRequests(entityIDBytes []byte) ([]*pkgservice.BackendJoinRequest, error)

func (*Backend) GetMyIDStr

func (b *Backend) GetMyIDStr() (string, error)

func (*Backend) GetMyMasterOplogList

func (b *Backend) GetMyMasterOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error)

func (*Backend) GetMyNodes

func (b *Backend) GetMyNodes(entityIDBytes []byte) ([]*MyNode, error)

func (*Backend) GetMyProfile

func (b *Backend) GetMyProfile(entityIDBytes []byte) (*account.Profile, error)

func (*Backend) GetPendingMeOplogInternalList

func (b *Backend) GetPendingMeOplogInternalList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MeOplog, error)

func (*Backend) GetPendingMeOplogMasterList

func (b *Backend) GetPendingMeOplogMasterList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MeOplog, error)

func (*Backend) GetRaftStatus

func (b *Backend) GetRaftStatus(entityIDBytes []byte) (*RaftStatus, error)

func (*Backend) GetRawMe

func (b *Backend) GetRawMe(entityIDBytes []byte) (*MyInfo, error)

func (*Backend) GetTotalWeight

func (b *Backend) GetTotalWeight(entityIDBytes []byte) (uint32, error)

func (*Backend) JoinBoard

func (b *Backend) JoinBoard(friendURL []byte) (*pkgservice.BackendJoinRequest, error)

func (*Backend) JoinFriend

func (b *Backend) JoinFriend(friendURL []byte) (*pkgservice.BackendJoinRequest, error)

func (*Backend) JoinMe

func (b *Backend) JoinMe(meURL []byte, myKeyBytes []byte) (*pkgservice.BackendJoinRequest, error)

func (*Backend) Name

func (b *Backend) Name() string

func (*Backend) RefreshMyNodeSignKey

func (b *Backend) RefreshMyNodeSignKey() (*pkgservice.KeyInfo, error)

func (*Backend) RefreshMySignKey

func (b *Backend) RefreshMySignKey() (*pkgservice.KeyInfo, error)

func (*Backend) RemoveBoardRequests

func (b *Backend) RemoveBoardRequests(entityIDBytes []byte, hash []byte) (bool, error)

func (*Backend) RemoveFriendRequests

func (b *Backend) RemoveFriendRequests(entityIDBytes []byte, hash []byte) (bool, error)

func (*Backend) RemoveMeRequests

func (b *Backend) RemoveMeRequests(entityIDBytes []byte, hash []byte) (bool, error)

func (*Backend) RemoveNode

func (b *Backend) RemoveNode(nodeIDStr string) (bool, error)

func (*Backend) RequestRaftLead

func (b *Backend) RequestRaftLead() (bool, error)

func (*Backend) Revoke

func (b *Backend) Revoke(myKey []byte) (bool, error)

func (*Backend) SetMyImage

func (b *Backend) SetMyImage(imgStr string) (*account.UserImg, error)

func (*Backend) SetMyName

func (b *Backend) SetMyName(name []byte) (*account.UserName, error)

func (*Backend) SetMyNameCard

func (b *Backend) SetMyNameCard(nameCard []byte) (*account.NameCard, error)

func (*Backend) SetMyNodeName

func (b *Backend) SetMyNodeName(nodeIDBytes []byte, name []byte) (*MyNode, error)

func (*Backend) ShowMeURL

func (b *Backend) ShowMeURL() (*pkgservice.BackendJoinURL, error)

func (*Backend) ShowMyMasterKey

func (b *Backend) ShowMyMasterKey() ([]byte, error)

func (*Backend) ShowMyNodeKey

func (b *Backend) ShowMyNodeKey() ([]byte, error)

func (*Backend) ShowMyNodeSignKey

func (b *Backend) ShowMyNodeSignKey() (*pkgservice.KeyInfo, error)

func (*Backend) ShowMySignKey

func (b *Backend) ShowMySignKey() (*pkgservice.KeyInfo, error)

func (*Backend) ShowURL

func (b *Backend) ShowURL() (*pkgservice.BackendJoinURL, error)

func (*Backend) Start

func (b *Backend) Start() error

func (*Backend) Stop

func (b *Backend) Stop() error

func (*Backend) ValidateMyMasterKey

func (b *Backend) ValidateMyMasterKey(keyBytes []byte) (bool, error)

func (*Backend) ValidateMyNodeKey

func (b *Backend) ValidateMyNodeKey(keyBytes []byte) (bool, error)

type BackendMyInfo

type BackendMyInfo struct {
	V        types.Version
	ID       *types.PttID
	CreateTS types.Timestamp `json:"CT"`
	UpdateTS types.Timestamp `json:"UT"`

	Status types.Status `json:"S"`

	RaftID uint64
	NodeID *discover.NodeID
}

func MarshalBackendMyInfo

func MarshalBackendMyInfo(m *MyInfo, ptt pkgservice.MyPtt) *BackendMyInfo

type Config

type Config struct {
	DataDir string

	PrivateKey *ecdsa.PrivateKey `toml:"-"`
	ID         *types.PttID      `toml:"-"` // we also need ID because other services need to know ID, but cannot directly acccess private-key and postfix.
	Postfix    string
}

func (*Config) DeleteKey

func (c *Config) DeleteKey() error

func (*Config) GetDataPrivateKeyByID

func (c *Config) GetDataPrivateKeyByID(myID *types.PttID) (*ecdsa.PrivateKey, error)

func (*Config) LoadKey

func (c *Config) LoadKey(filename string) (*ecdsa.PrivateKey, *types.PttID, error)

func (*Config) ResolvePath

func (c *Config) ResolvePath(path string) string

resolvePath resolves path in the instance directory.

func (*Config) ResolvePrivateKeyWithIDPath

func (c *Config) ResolvePrivateKeyWithIDPath(myID *types.PttID) (string, error)

func (*Config) RevokeKey

func (c *Config) RevokeKey() error

func (*Config) RevokeMyKey

func (c *Config) RevokeMyKey(myID *types.PttID) error

func (*Config) SaveKey

func (c *Config) SaveKey(filename string, key *ecdsa.PrivateKey, postfix string) error

func (*Config) SetMyKey

func (c *Config) SetMyKey(hex string, file string, postfix string, isSave bool) error

type InitMeInfo

type InitMeInfo struct {
	Status types.Status `json:"S"`
}

type InitMeInfoAck

type InitMeInfoAck struct {
	Status types.Status `json:"S"`
}

type InitMeInfoSync

type InitMeInfoSync struct {
	KeyBytes     []byte                        `json:"K"`
	PostfixBytes []byte                        `json:"P"`
	Oplog0       *pkgservice.BaseOplog         `json:"O"`
	ProfileData  *account.ApproveJoinEntity    `json:"p"`
	BoardData    *pkgservice.ApproveJoinEntity `json:"b"`
}

type InternalSyncBoardAck

type InternalSyncBoardAck struct {
	LogID *types.PttID `json:"l"`

	BoardData *pkgservice.ApproveJoinEntity `json:"B"`
}

type InternalSyncFriendAck

type InternalSyncFriendAck struct {
	LogID *types.PttID `json:"l"`

	InitFriendInfoAck *friend.InitFriendInfoAck `json:"i"`
}

type JoinBoardEvent

type JoinBoardEvent struct {
	JoinRequest *pkgservice.JoinRequest
}

type JoinFriendEvent

type JoinFriendEvent struct {
	JoinRequest *pkgservice.JoinRequest
}

type JoinMeEvent

type JoinMeEvent struct {
	JoinMeRequest *pkgservice.JoinRequest
}

type JoinMeRequest

type JoinMeRequest struct {
	JoinRequest *pkgservice.JoinRequest
	NodeType    pkgservice.NodeType
}

type MasterOpAddMaster

type MasterOpAddMaster struct {
	ID      *discover.NodeID
	From    *types.PttID               `json:"f"`
	Masters map[discover.NodeID]uint32 `json:"M"`
	Weight  uint32                     `json:"W"`
}

type MasterOpRevokeMaster

type MasterOpRevokeMaster struct {
	ID      *discover.NodeID
	From    *types.PttID               `json:"f"`
	Masters map[discover.NodeID]uint32 `json:"M"`
}

type MasterOplog

type MasterOplog struct {
	*pkgservice.BaseOplog `json:"O"`
}

func NewMasterOplog

func NewMasterOplog(id *types.PttID, ts types.Timestamp, doerID *types.PttID, op pkgservice.OpType, data interface{}, dbLock *types.LockMap) (*MasterOplog, error)

func OplogsToMasterOplogs

func OplogsToMasterOplogs(logs []*pkgservice.BaseOplog) []*MasterOplog

type MeOpCreateMe

type MeOpCreateMe struct {
	NodeID   *discover.NodeID    `json:"NID"`
	NodeType pkgservice.NodeType `json:"NT"`
	NodeName []byte              `json:"n"`
}

type MeOpDeleteMe

type MeOpDeleteMe struct{}

type MeOpEntity

type MeOpEntity struct {
	LogID *types.PttID `json:"l"`
}

type MeOpMigrateMe

type MeOpMigrateMe struct {
	ID *types.PttID
}

type MeOpSetNodeName

type MeOpSetNodeName struct {
	NodeID *discover.NodeID `json:"NID"`
	Name   []byte           `json:"n"`
}

type MeOplog

type MeOplog struct {
	*pkgservice.BaseOplog `json:"O"`
}

func NewMeOplog

func NewMeOplog(objID *types.PttID, ts types.Timestamp, doerID *types.PttID, op pkgservice.OpType, opData pkgservice.OpData, myID *types.PttID, dbLock *types.LockMap) (*MeOplog, error)

func OplogToMeOplog

func OplogToMeOplog(oplog *pkgservice.BaseOplog) *MeOplog

func OplogsToMeOplogs

func OplogsToMeOplogs(logs []*pkgservice.BaseOplog) []*MeOplog

func (*MeOplog) GetBaseOplog

func (o *MeOplog) GetBaseOplog() *pkgservice.BaseOplog

type MyInfo

type MyInfo struct {
	*pkgservice.BaseEntity `json:"e"`

	UpdateTS types.Timestamp `json:"UT"`

	ProfileID *types.PttID     `json:"PID"`
	Profile   *account.Profile `json:"-"`

	BoardID *types.PttID   `json:"BID"`
	Board   *content.Board `json:"-"`

	NodeSignID *types.PttID `json:"-"`
	// contains filtered or unexported fields
}

func NewEmptyMyInfo

func NewEmptyMyInfo() *MyInfo

func NewMyInfo

func NewMyInfo(id *types.PttID, myKey *ecdsa.PrivateKey, ptt pkgservice.MyPtt, service pkgservice.Service, spm pkgservice.ServiceProtocolManager, dbLock *types.LockMap) (*MyInfo, error)

func (*MyInfo) CreateEntityOpType

func (m *MyInfo) CreateEntityOpType(entity pkgservice.Entity) (pkgservice.OpType, error)

func (*MyInfo) CreateEntityOplog

func (m *MyInfo) CreateEntityOplog(entity pkgservice.Entity) error

func (*MyInfo) CreateJoinEntityOplog

func (m *MyInfo) CreateJoinEntityOplog(entity pkgservice.Entity) error

func (*MyInfo) CreateNodeSignKeyInfo

func (m *MyInfo) CreateNodeSignKeyInfo() error

func (*MyInfo) CreateSignKeyInfo

func (m *MyInfo) CreateSignKeyInfo() error

func (*MyInfo) GetBoard

func (m *MyInfo) GetBoard() pkgservice.Entity

func (*MyInfo) GetJoinRequest

func (m *MyInfo) GetJoinRequest(hash *common.Address) (*pkgservice.JoinRequest, error)

func (*MyInfo) GetLenNodes

func (m *MyInfo) GetLenNodes() int

func (*MyInfo) GetMasterKey

func (m *MyInfo) GetMasterKey() *ecdsa.PrivateKey

func (*MyInfo) GetMyKey

func (m *MyInfo) GetMyKey() *ecdsa.PrivateKey

func (*MyInfo) GetNodeKey

func (m *MyInfo) GetNodeKey() *ecdsa.PrivateKey

func (*MyInfo) GetNodeSignID

func (m *MyInfo) GetNodeSignID() *types.PttID

func (*MyInfo) GetProfile

func (m *MyInfo) GetProfile() pkgservice.Entity

func (*MyInfo) GetUpdateTS

func (m *MyInfo) GetUpdateTS() types.Timestamp

func (*MyInfo) GetUserNodeID

func (m *MyInfo) GetUserNodeID(id *types.PttID) (*discover.NodeID, error)

func (*MyInfo) GetValidateKey

func (m *MyInfo) GetValidateKey() *types.PttID

func (*MyInfo) HandleApproveJoin

func (m *MyInfo) HandleApproveJoin(dataBytes []byte, hash *common.Address, joinRequest *pkgservice.JoinRequest, peer *pkgservice.PttPeer) error

func (*MyInfo) Init

func (*MyInfo) InitPM

func (m *MyInfo) InitPM(ptt pkgservice.MyPtt, service pkgservice.Service) error

func (*MyInfo) InternalSign

func (m *MyInfo) InternalSign(oplog *pkgservice.BaseOplog) error

func (*MyInfo) IsValidInternalOplog

func (m *MyInfo) IsValidInternalOplog(signInfos []*pkgservice.SignInfo) (*types.PttID, uint32, bool)

func (*MyInfo) JoinEntityOpType

func (m *MyInfo) JoinEntityOpType(entity pkgservice.Entity) (pkgservice.OpType, error)

func (*MyInfo) Marshal

func (m *MyInfo) Marshal() ([]byte, error)

func (*MyInfo) MarshalKey

func (m *MyInfo) MarshalKey() ([]byte, error)

func (*MyInfo) MasterSign

func (m *MyInfo) MasterSign(oplog *pkgservice.BaseOplog) error

func (*MyInfo) MustSave

func (m *MyInfo) MustSave(isLocked bool) error

func (*MyInfo) MyMasterSign

func (m *MyInfo) MyMasterSign(oplog *pkgservice.BaseOplog) error

func (*MyInfo) MyPM

func (*MyInfo) NewOpKeyInfo

func (m *MyInfo) NewOpKeyInfo(entityID *types.PttID, setOpKeyObjDB func(k *pkgservice.KeyInfo)) (*pkgservice.KeyInfo, error)

func (*MyInfo) NodeSignKey

func (m *MyInfo) NodeSignKey() *pkgservice.KeyInfo

func (*MyInfo) Save

func (m *MyInfo) Save(isLocked bool) error

func (*MyInfo) SetUpdateTS

func (m *MyInfo) SetUpdateTS(ts types.Timestamp)

func (*MyInfo) Sign

func (m *MyInfo) Sign(oplog *pkgservice.BaseOplog) error

func (*MyInfo) SignBlock

func (m *MyInfo) SignBlock(block *pkgservice.Block) error

func (*MyInfo) SignKey

func (m *MyInfo) SignKey() *pkgservice.KeyInfo

func (*MyInfo) Unmarshal

func (m *MyInfo) Unmarshal(theBytes []byte) error

type MyNode

type MyNode struct {
	V        types.Version
	ID       *types.PttID
	CreateTS types.Timestamp `json:"CT"`
	UpdateTS types.Timestamp `json:"UT"`

	Status types.Status `json:"S"`

	LastSeen types.Timestamp `json:"L"`

	NodeName         []byte            `json:"N,omitempty"`
	NodeNameLogID    *types.PttID      `json:"nl,omitempty"`
	SyncNodeNameInfo *SyncNodeNameInfo `json:"sn,omitempty"`

	NodeID *discover.NodeID `json:"NID"`

	NodeType pkgservice.NodeType `json:"NT"`
	Weight   uint32              `json:"W"`

	LogID *types.PttID `json:"pl,omitempty"`

	RaftID uint64 `json:"R"`

	Peer *pkgservice.PttPeer `json:"-"`
}

func NewMyNode

func NewMyNode(ts types.Timestamp, myID *types.PttID, nodeID *discover.NodeID, weight uint32) (*MyNode, error)

func (*MyNode) DBPrefix

func (m *MyNode) DBPrefix() ([]byte, error)

func (*MyNode) Delete

func (m *MyNode) Delete(isLocked bool) error

func (*MyNode) DeleteRawKey

func (m *MyNode) DeleteRawKey(key []byte) error

func (*MyNode) Get

func (m *MyNode) Get(myID *types.PttID, nodeID *discover.NodeID) error

func (*MyNode) IntegrateSyncNodeNameInfo

func (m *MyNode) IntegrateSyncNodeNameInfo(info *SyncNodeNameInfo) (*types.PttID, error)

func (*MyNode) Marshal

func (m *MyNode) Marshal() ([]byte, error)

func (*MyNode) MarshalKey

func (m *MyNode) MarshalKey() ([]byte, error)

func (*MyNode) Save

func (m *MyNode) Save() ([]byte, error)

func (*MyNode) Unmarshal

func (m *MyNode) Unmarshal(theBytes []byte) error

type PrivateAPI

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

func NewPrivateAPI

func NewPrivateAPI(b *Backend) *PrivateAPI

func (*PrivateAPI) CountPeers

func (api *PrivateAPI) CountPeers(entityID string) (int, error)

func (*PrivateAPI) ForceRemoveNode

func (api *PrivateAPI) ForceRemoveNode(nodeID string) (bool, error)

func (*PrivateAPI) ForceSyncMeMerkle

func (api *PrivateAPI) ForceSyncMeMerkle(entityID string) (bool, error)

func (*PrivateAPI) GetBoard

func (api *PrivateAPI) GetBoard(entityID string) (*content.BackendGetBoard, error)

func (*PrivateAPI) GetBoardRequests

func (api *PrivateAPI) GetBoardRequests(entityID string) ([]*pkgservice.BackendJoinRequest, error)

GetBoardRequests get the friend-requests from me to the others.

func (*PrivateAPI) GetFriendRequests

func (api *PrivateAPI) GetFriendRequests(entityID string) ([]*pkgservice.BackendJoinRequest, error)

GetFriendRequests get the friend-requests from me to the others.

func (*PrivateAPI) GetJoinKeyInfos

func (api *PrivateAPI) GetJoinKeyInfos(entityID string) ([]*pkgservice.KeyInfo, error)

func (*PrivateAPI) GetMeOplogList

func (api *PrivateAPI) GetMeOplogList(logID string, limit int, listOrder pttdb.ListOrder) ([]*MeOplog, error)

func (*PrivateAPI) GetMeOplogMerkleNodeList

func (api *PrivateAPI) GetMeOplogMerkleNodeList(entityID string, level uint8, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.BackendMerkleNode, error)

func (*PrivateAPI) GetMeRequests

func (api *PrivateAPI) GetMeRequests(entityID string) ([]*pkgservice.BackendJoinRequest, error)

GetMeRequests get the me-requests from me to the others.

func (*PrivateAPI) GetMyBoard

func (api *PrivateAPI) GetMyBoard() (*content.BackendGetBoard, error)

func (*PrivateAPI) GetMyMasterOplogList

func (api *PrivateAPI) GetMyMasterOplogList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error)

func (*PrivateAPI) GetMyNodes

func (api *PrivateAPI) GetMyNodes() ([]*MyNode, error)

func (*PrivateAPI) GetOpKeyInfos

func (api *PrivateAPI) GetOpKeyInfos(entityID string) ([]*pkgservice.KeyInfo, error)

*********

  • Op *********

func (*PrivateAPI) GetOpKeyInfosFromDB

func (api *PrivateAPI) GetOpKeyInfosFromDB(entityID string) ([]*pkgservice.KeyInfo, error)

func (*PrivateAPI) GetOpKeyOplogList

func (api *PrivateAPI) GetOpKeyOplogList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.OpKeyOplog, error)

func (*PrivateAPI) GetPeers

func (api *PrivateAPI) GetPeers(entityID string) ([]*pkgservice.BackendPeer, error)

func (*PrivateAPI) GetPendingMeOplogInternalList

func (api *PrivateAPI) GetPendingMeOplogInternalList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*MeOplog, error)

func (*PrivateAPI) GetPendingMeOplogMasterList

func (api *PrivateAPI) GetPendingMeOplogMasterList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*MeOplog, error)

func (*PrivateAPI) GetPendingOpKeyOplogInternalList

func (api *PrivateAPI) GetPendingOpKeyOplogInternalList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.OpKeyOplog, error)

func (*PrivateAPI) GetPendingOpKeyOplogMasterList

func (api *PrivateAPI) GetPendingOpKeyOplogMasterList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.OpKeyOplog, error)

func (*PrivateAPI) GetRaftStatus

func (api *PrivateAPI) GetRaftStatus(id string) (*RaftStatus, error)

func (*PrivateAPI) GetRawMe

func (api *PrivateAPI) GetRawMe(entityID string) (*MyInfo, error)

func (*PrivateAPI) GetRawMeOplogList

func (api *PrivateAPI) GetRawMeOplogList(entityID string, logID string, limit int, listOrder pttdb.ListOrder) ([]*MeOplog, error)

func (*PrivateAPI) GetRawMyNodes

func (api *PrivateAPI) GetRawMyNodes(entityID string) ([]*MyNode, error)

func (*PrivateAPI) GetTotalWeight

func (api *PrivateAPI) GetTotalWeight(entityID string) (uint32, error)

func (*PrivateAPI) JoinBoard

func (api *PrivateAPI) JoinBoard(friendURL string) (*pkgservice.BackendJoinRequest, error)

func (*PrivateAPI) JoinFriend

func (api *PrivateAPI) JoinFriend(friendURL string) (*pkgservice.BackendJoinRequest, error)

func (*PrivateAPI) JoinMe

func (api *PrivateAPI) JoinMe(meURL string, myKey string, dummy bool) (*pkgservice.BackendJoinRequest, error)

func (*PrivateAPI) RefreshMyNodeSignKey

func (api *PrivateAPI) RefreshMyNodeSignKey() (*pkgservice.KeyInfo, error)

func (*PrivateAPI) RefreshMySignKey

func (api *PrivateAPI) RefreshMySignKey() (*pkgservice.KeyInfo, error)

func (*PrivateAPI) RemoveBoardRequests

func (api *PrivateAPI) RemoveBoardRequests(entityID string, hash []byte) (bool, error)

func (*PrivateAPI) RemoveFriendRequests

func (api *PrivateAPI) RemoveFriendRequests(entityID string, hash []byte) (bool, error)

func (*PrivateAPI) RemoveMeRequests

func (api *PrivateAPI) RemoveMeRequests(entityID string, hash []byte) (bool, error)

func (*PrivateAPI) RemoveNode

func (api *PrivateAPI) RemoveNode(nodeID string) (bool, error)

func (*PrivateAPI) RequestRaftLead

func (api *PrivateAPI) RequestRaftLead() (bool, error)

func (*PrivateAPI) Revoke

func (api *PrivateAPI) Revoke(myKey string) (bool, error)

func (*PrivateAPI) RevokeOpKey

func (api *PrivateAPI) RevokeOpKey(entityID string, keyID string, myKey string) (bool, error)

func (*PrivateAPI) SetMyImage

func (api *PrivateAPI) SetMyImage(imgStr string) (*account.UserImg, error)

func (*PrivateAPI) SetMyName

func (api *PrivateAPI) SetMyName(name []byte) (*account.UserName, error)

func (*PrivateAPI) SetMyNameCard

func (api *PrivateAPI) SetMyNameCard(nameCard []byte) (*account.NameCard, error)

func (*PrivateAPI) SetMyNodeName

func (api *PrivateAPI) SetMyNodeName(nodeID string, name []byte) (*MyNode, error)

func (*PrivateAPI) ShowMeURL

func (api *PrivateAPI) ShowMeURL() (*pkgservice.BackendJoinURL, error)

func (*PrivateAPI) ShowMyKey

func (api *PrivateAPI) ShowMyKey() (*types.PttID, error)

func (*PrivateAPI) ShowMyMasterKey

func (api *PrivateAPI) ShowMyMasterKey() ([]byte, error)

func (*PrivateAPI) ShowMyNodeKey

func (api *PrivateAPI) ShowMyNodeKey() ([]byte, error)

func (*PrivateAPI) ShowMyNodeSignKey

func (api *PrivateAPI) ShowMyNodeSignKey() (*pkgservice.KeyInfo, error)

func (*PrivateAPI) ShowMySignKey

func (api *PrivateAPI) ShowMySignKey() (*pkgservice.KeyInfo, error)

func (*PrivateAPI) ValidateMyKey

func (api *PrivateAPI) ValidateMyKey(key string) (bool, error)

func (*PrivateAPI) ValidateMyMasterKey

func (api *PrivateAPI) ValidateMyMasterKey(masterKeyBytes []byte) (bool, error)

func (*PrivateAPI) ValidateMyNodeKey

func (api *PrivateAPI) ValidateMyNodeKey(nodeKeyBytes []byte) (bool, error)

type ProcessMeInfo

type ProcessMeInfo struct {
	DeleteMeInfo map[types.PttID]*pkgservice.BaseOplog
	MetaInfo     map[types.PttID]*pkgservice.BaseOplog
	BoardInfo    map[types.PttID]*pkgservice.BaseOplog
	FriendInfo   map[types.PttID]*pkgservice.BaseOplog
}

func NewProcessMeInfo

func NewProcessMeInfo() *ProcessMeInfo

type ProtocolManager

type ProtocolManager struct {
	*pkgservice.BaseProtocolManager

	MyNodes             map[uint64]*MyNode
	MyNodeByNodeSignIDs map[types.PttID]*MyNode
	// contains filtered or unexported fields
}

func NewProtocolManager

func NewProtocolManager(myInfo *MyInfo, ptt pkgservice.MyPtt, svc pkgservice.Service) (*ProtocolManager, error)

func (*ProtocolManager) ApproveJoin

func (pm *ProtocolManager) ApproveJoin(joinEntity *pkgservice.JoinEntity, keyInfo *pkgservice.KeyInfo, peer *pkgservice.PttPeer) (*pkgservice.KeyInfo, interface{}, error)

func (*ProtocolManager) ApproveJoinFriend

func (pm *ProtocolManager) ApproveJoinFriend(joinEntity *pkgservice.JoinEntity, keyInfo *pkgservice.KeyInfo, peer *pkgservice.PttPeer) (*pkgservice.KeyInfo, interface{}, error)

func (*ProtocolManager) ApproveJoinMe

func (pm *ProtocolManager) ApproveJoinMe(joinEntity *pkgservice.JoinEntity, keyInfo *pkgservice.KeyInfo, peer *pkgservice.PttPeer) (*pkgservice.KeyInfo, interface{}, error)

ApproveJoinMe deals with procedure of approving-join-me:

  1. set peer-type as me
  2. propose raft.

func (*ProtocolManager) BroadcastMeOplog

func (pm *ProtocolManager) BroadcastMeOplog(oplog *MeOplog) error

func (*ProtocolManager) BroadcastMeOplogs

func (pm *ProtocolManager) BroadcastMeOplogs(opKeyLogs []*MeOplog) error

func (*ProtocolManager) CleanJoinFriendKey

func (pm *ProtocolManager) CleanJoinFriendKey()

func (*ProtocolManager) CleanRaftStorage

func (pm *ProtocolManager) CleanRaftStorage(isLocked bool) error

func (*ProtocolManager) CreateFullMe

func (pm *ProtocolManager) CreateFullMe(oplog *MasterOplog) error

func (*ProtocolManager) CreateJoinFriendKeyLoop

func (pm *ProtocolManager) CreateJoinFriendKeyLoop() error

func (*ProtocolManager) CreateMasterOplog

func (pm *ProtocolManager) CreateMasterOplog(raftIdx uint64, ts types.Timestamp, op pkgservice.OpType, data interface{}) (*MasterOplog, error)

func (*ProtocolManager) CreateMeOplog

func (pm *ProtocolManager) CreateMeOplog(objID *types.PttID, ts types.Timestamp, op pkgservice.OpType, data interface{}) (*MeOplog, error)

func (*ProtocolManager) CreateMyBoard

func (pm *ProtocolManager) CreateMyBoard(contentBackend *content.Backend) error

func (*ProtocolManager) CreateMyProfile

func (pm *ProtocolManager) CreateMyProfile(accountBackend *account.Backend) error

func (*ProtocolManager) DeleteMe

func (pm *ProtocolManager) DeleteMe() error

func (*ProtocolManager) EnsureRaftLead

func (pm *ProtocolManager) EnsureRaftLead() error

func (*ProtocolManager) ForceProposeRaftRemoveNode

func (pm *ProtocolManager) ForceProposeRaftRemoveNode(nodeID *discover.NodeID) error

func (*ProtocolManager) ForceSignMyOplog

func (pm *ProtocolManager) ForceSignMyOplog(oplog *pkgservice.BaseOplog) error

func (*ProtocolManager) ForceSyncMeMerkle

func (pm *ProtocolManager) ForceSyncMeMerkle() (bool, error)

func (*ProtocolManager) GetBoardRequests

func (pm *ProtocolManager) GetBoardRequests() ([]*pkgservice.JoinRequest, error)

func (*ProtocolManager) GetFriendRequests

func (pm *ProtocolManager) GetFriendRequests() ([]*pkgservice.JoinRequest, error)

func (*ProtocolManager) GetJoinFriendKey

func (pm *ProtocolManager) GetJoinFriendKey() (*pkgservice.KeyInfo, error)

func (*ProtocolManager) GetJoinFriendKeyFromHash

func (pm *ProtocolManager) GetJoinFriendKeyFromHash(hash *common.Address) (*pkgservice.KeyInfo, error)

func (*ProtocolManager) GetJoinKeyFromHash

func (pm *ProtocolManager) GetJoinKeyFromHash(hash *common.Address) (*pkgservice.KeyInfo, error)

func (*ProtocolManager) GetJoinRequest

func (pm *ProtocolManager) GetJoinRequest(hash *common.Address) (*pkgservice.JoinRequest, error)

func (*ProtocolManager) GetJoinType

func (pm *ProtocolManager) GetJoinType(hash *common.Address) (pkgservice.JoinType, error)

func (*ProtocolManager) GetMeOplogList

func (pm *ProtocolManager) GetMeOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*MeOplog, error)

GetMeOplogList gets the MeOplogs specifically from myEntity.

func (*ProtocolManager) GetMeOplogMerkleNodeList

func (pm *ProtocolManager) GetMeOplogMerkleNodeList(level pkgservice.MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*pkgservice.MerkleNode, error)

func (*ProtocolManager) GetMeRequests

func (pm *ProtocolManager) GetMeRequests() ([]*pkgservice.JoinRequest, error)

func (*ProtocolManager) GetMyMasterOplogList

func (pm *ProtocolManager) GetMyMasterOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*MasterOplog, error)

func (*ProtocolManager) GetMyNodeList

func (pm *ProtocolManager) GetMyNodeList(isLocked bool) []*MyNode

func (*ProtocolManager) GetPeerType

func (pm *ProtocolManager) GetPeerType(peer *pkgservice.PttPeer) pkgservice.PeerType

func (*ProtocolManager) GetRaftAppliedIndex

func (pm *ProtocolManager) GetRaftAppliedIndex(isLocked bool) uint64

func (*ProtocolManager) GetRaftConfState

func (pm *ProtocolManager) GetRaftConfState(isLocked bool) pb.ConfState

func (*ProtocolManager) GetRaftLastIndex

func (pm *ProtocolManager) GetRaftLastIndex(isLocked bool) uint64

func (*ProtocolManager) GetRaftLead

func (pm *ProtocolManager) GetRaftLead(isLocked bool) uint64

func (*ProtocolManager) GetRaftSnapshotIndex

func (pm *ProtocolManager) GetRaftSnapshotIndex(isLocked bool) uint64

func (*ProtocolManager) GetRaftStatus

func (pm *ProtocolManager) GetRaftStatus() (*RaftStatus, error)

func (*ProtocolManager) HandleAddMeOplog

func (pm *ProtocolManager) HandleAddMeOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleAddMeOplogs

func (pm *ProtocolManager) HandleAddMeOplogs(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleAddPendingMeOplog

func (pm *ProtocolManager) HandleAddPendingMeOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleAddPendingMeOplogs

func (pm *ProtocolManager) HandleAddPendingMeOplogs(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleApproveJoin

func (pm *ProtocolManager) HandleApproveJoin(dataBytes []byte, hash *common.Address, joinRequest *pkgservice.JoinRequest, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleApproveJoinBoard

func (pm *ProtocolManager) HandleApproveJoinBoard(dataBytes []byte, joinRequest *pkgservice.JoinRequest, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleApproveJoinFriend

func (pm *ProtocolManager) HandleApproveJoinFriend(dataBytes []byte, joinRequest *pkgservice.JoinRequest, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleApproveJoinMe

func (pm *ProtocolManager) HandleApproveJoinMe(dataBytes []byte, joinRequest *pkgservice.JoinRequest, peer *pkgservice.PttPeer) error

HandleApproveJoinMe deals with procedure of handling-approve-join-me:

func (*ProtocolManager) HandleEntityLog

func (pm *ProtocolManager) HandleEntityLog(
	oplog *pkgservice.BaseOplog,

	spm pkgservice.ServiceProtocolManager,
	opData *MeOpEntity,

	info *ProcessMeInfo,

	updateCreateEntityInfo func(oplog *pkgservice.BaseOplog, info *ProcessMeInfo),
) ([]*pkgservice.BaseOplog, error)

func (*ProtocolManager) HandleFailedMeOplog

func (pm *ProtocolManager) HandleFailedMeOplog(oplog *pkgservice.BaseOplog) (err error)

func (*ProtocolManager) HandleFailedValidMeOplog

func (pm *ProtocolManager) HandleFailedValidMeOplog(oplog *pkgservice.BaseOplog, processInfo pkgservice.ProcessInfo) (err error)

func (*ProtocolManager) HandleForceSyncMeOplog

func (pm *ProtocolManager) HandleForceSyncMeOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncMeOplogAck

func (pm *ProtocolManager) HandleForceSyncMeOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncMeOplogByMerkle

func (pm *ProtocolManager) HandleForceSyncMeOplogByMerkle(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncMeOplogByMerkleAck

func (pm *ProtocolManager) HandleForceSyncMeOplogByMerkleAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleForceSyncMeOplogByOplogAck

func (pm *ProtocolManager) HandleForceSyncMeOplogByOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleInitMeInfo

func (pm *ProtocolManager) HandleInitMeInfo(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleInitMeInfoAck

func (pm *ProtocolManager) HandleInitMeInfoAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleInitMeInfoSync

func (pm *ProtocolManager) HandleInitMeInfoSync(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleInternalSyncBoard

func (pm *ProtocolManager) HandleInternalSyncBoard(
	dataBytes []byte,
	peer *pkgservice.PttPeer,
) error

func (*ProtocolManager) HandleInternalSyncBoardAck

func (pm *ProtocolManager) HandleInternalSyncBoardAck(
	dataBytes []byte,
	peer *pkgservice.PttPeer,

) error

func (*ProtocolManager) HandleInternalSyncFriend

func (pm *ProtocolManager) HandleInternalSyncFriend(
	dataBytes []byte,
	peer *pkgservice.PttPeer,
) error

func (*ProtocolManager) HandleInternalSyncFriendAck

func (pm *ProtocolManager) HandleInternalSyncFriendAck(
	dataBytes []byte,
	peer *pkgservice.PttPeer,

) error

func (*ProtocolManager) HandleMeOplogs

func (pm *ProtocolManager) HandleMeOplogs(oplogs []*pkgservice.BaseOplog, peer *pkgservice.PttPeer, isUpdateSyncTime bool) error

func (*ProtocolManager) HandleMessage

func (pm *ProtocolManager) HandleMessage(op pkgservice.OpType, dataBytes []byte, peer *pkgservice.PttPeer) (err error)

func (*ProtocolManager) HandleNonRegisteredMessage

func (pm *ProtocolManager) HandleNonRegisteredMessage(op pkgservice.OpType, dataBytes []byte, peer *pkgservice.PttPeer) (err error)

func (*ProtocolManager) HandlePendingMeOplogs

func (pm *ProtocolManager) HandlePendingMeOplogs(oplogs []*pkgservice.BaseOplog, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleRevokeMyNode

func (pm *ProtocolManager) HandleRevokeMyNode(oplog *MasterOplog, isLockedEntity bool, isLockedNode bool) error

func (*ProtocolManager) HandleRevokeOtherNode

func (pm *ProtocolManager) HandleRevokeOtherNode(oplog *MasterOplog, node *MyNode, fromID *types.PttID) error

func (*ProtocolManager) HandleSendRaftMsgs

func (pm *ProtocolManager) HandleSendRaftMsgs(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncMeOplog

func (pm *ProtocolManager) HandleSyncMeOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncMeOplogAck

func (pm *ProtocolManager) HandleSyncMeOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncMeOplogInvalid

func (pm *ProtocolManager) HandleSyncMeOplogInvalid(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncNewMeOplog

func (pm *ProtocolManager) HandleSyncNewMeOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncNewMeOplogAck

func (pm *ProtocolManager) HandleSyncNewMeOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncPendingMeOplog

func (pm *ProtocolManager) HandleSyncPendingMeOplog(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) HandleSyncPendingMeOplogAck

func (pm *ProtocolManager) HandleSyncPendingMeOplogAck(dataBytes []byte, peer *pkgservice.PttPeer) error

func (*ProtocolManager) InitMeInfo

func (pm *ProtocolManager) InitMeInfo(peer *pkgservice.PttPeer) error

func (*ProtocolManager) InitMeInfoAck

func (pm *ProtocolManager) InitMeInfoAck(data *InitMeInfo, peer *pkgservice.PttPeer) error

func (*ProtocolManager) InitMeInfoLoop

func (pm *ProtocolManager) InitMeInfoLoop()

func (*ProtocolManager) InitMeInfoSync

func (pm *ProtocolManager) InitMeInfoSync(peer *pkgservice.PttPeer) error

func (*ProtocolManager) InternalSignMyOplog

func (pm *ProtocolManager) InternalSignMyOplog(oplog *pkgservice.BaseOplog) (bool, error)

func (*ProtocolManager) InternalSyncBoard

func (pm *ProtocolManager) InternalSyncBoard(
	oplog *pkgservice.BaseOplog,
	peer *pkgservice.PttPeer,
) error

func (*ProtocolManager) InternalSyncFriend

func (pm *ProtocolManager) InternalSyncFriend(
	oplog *pkgservice.BaseOplog,
	peer *pkgservice.PttPeer,
) error

func (*ProtocolManager) InternalSyncToAlive

func (pm *ProtocolManager) InternalSyncToAlive(oplog *MasterOplog, weight uint32) error

func (*ProtocolManager) IsImportantPeer

func (pm *ProtocolManager) IsImportantPeer(peer *pkgservice.PttPeer) bool

func (*ProtocolManager) IsJoinBoardRequests

func (pm *ProtocolManager) IsJoinBoardRequests(hash *common.Address) bool

func (*ProtocolManager) IsJoinFriendKeyHash

func (pm *ProtocolManager) IsJoinFriendKeyHash(hash *common.Address) bool

func (*ProtocolManager) IsJoinFriendRequests

func (pm *ProtocolManager) IsJoinFriendRequests(hash *common.Address) bool

func (*ProtocolManager) IsJoinMeKeyHash

func (pm *ProtocolManager) IsJoinMeKeyHash(hash *common.Address) bool

func (*ProtocolManager) IsJoinMeRequests

func (pm *ProtocolManager) IsJoinMeRequests(hash *common.Address) bool

func (*ProtocolManager) IsMaster

func (pm *ProtocolManager) IsMaster(id *types.PttID, isLocked bool) bool

func (*ProtocolManager) IsMember

func (pm *ProtocolManager) IsMember(id *types.PttID, isLocked bool) bool

func (*ProtocolManager) IsMemberPeer

func (pm *ProtocolManager) IsMemberPeer(peer *pkgservice.PttPeer) bool

func (*ProtocolManager) IsMyDevice

func (pm *ProtocolManager) IsMyDevice(peer *pkgservice.PttPeer) bool

func (*ProtocolManager) IsPendingPeer

func (pm *ProtocolManager) IsPendingPeer(peer *pkgservice.PttPeer) bool

func (*ProtocolManager) IsValidInternalOplog

func (pm *ProtocolManager) IsValidInternalOplog(signInfos []*pkgservice.SignInfo) (*types.PttID, uint32, bool)

func (*ProtocolManager) IsValidMyOplog

func (pm *ProtocolManager) IsValidMyOplog(signInfos []*pkgservice.SignInfo) (*types.PttID, uint32, bool)

func (*ProtocolManager) JoinBoard

func (pm *ProtocolManager) JoinBoard(joinRequest *pkgservice.JoinRequest) error

func (*ProtocolManager) JoinBoardLoop

func (pm *ProtocolManager) JoinBoardLoop()

func (*ProtocolManager) JoinFriend

func (pm *ProtocolManager) JoinFriend(joinRequest *pkgservice.JoinRequest) error

func (*ProtocolManager) JoinFriendKeyList

func (pm *ProtocolManager) JoinFriendKeyList() []*pkgservice.KeyInfo

func (*ProtocolManager) JoinFriendLoop

func (pm *ProtocolManager) JoinFriendLoop() error

func (*ProtocolManager) JoinMe

func (pm *ProtocolManager) JoinMe(joinRequest *pkgservice.JoinRequest, myKeyBytes []byte) error

func (*ProtocolManager) JoinMeLoop

func (pm *ProtocolManager) JoinMeLoop() error

func (*ProtocolManager) LoadMyNodes

func (pm *ProtocolManager) LoadMyNodes() error

func (*ProtocolManager) LoadPeers

func (pm *ProtocolManager) LoadPeers() error

func (*ProtocolManager) LoadRaftAppliedIndex

func (pm *ProtocolManager) LoadRaftAppliedIndex(isLocked bool) error

func (*ProtocolManager) LoadRaftConfState

func (pm *ProtocolManager) LoadRaftConfState(isLocked bool) error

func (*ProtocolManager) LoadRaftLastIndex

func (pm *ProtocolManager) LoadRaftLastIndex(isLocked bool) error

func (*ProtocolManager) LoadRaftSnapshotIndex

func (pm *ProtocolManager) LoadRaftSnapshotIndex(isLocked bool) error

func (*ProtocolManager) LockMyNodes

func (pm *ProtocolManager) LockMyNodes()

func (*ProtocolManager) MarshalRaftAppliedIndexKey

func (pm *ProtocolManager) MarshalRaftAppliedIndexKey() ([]byte, error)

func (*ProtocolManager) MarshalRaftConfStateKey

func (pm *ProtocolManager) MarshalRaftConfStateKey() ([]byte, error)

func (*ProtocolManager) MarshalRaftLastIndexKey

func (pm *ProtocolManager) MarshalRaftLastIndexKey() ([]byte, error)

func (*ProtocolManager) MarshalRaftSnapshotIndexKey

func (pm *ProtocolManager) MarshalRaftSnapshotIndexKey() ([]byte, error)

func (*ProtocolManager) Master0Hash

func (pm *ProtocolManager) Master0Hash() []byte

func (*ProtocolManager) MaybeTriggerRaftSnapshot

func (pm *ProtocolManager) MaybeTriggerRaftSnapshot() error

func (*ProtocolManager) MigrateMe

func (pm *ProtocolManager) MigrateMe(newMyInfo *MyInfo) error

func (*ProtocolManager) NewMeOplog

func (pm *ProtocolManager) NewMeOplog(objID *types.PttID, op pkgservice.OpType, opData pkgservice.OpData) (pkgservice.Oplog, error)

func (*ProtocolManager) ProposeRaftAddNode

func (pm *ProtocolManager) ProposeRaftAddNode(nodeID *discover.NodeID, weight uint32) error

func (*ProtocolManager) ProposeRaftRemoveNode

func (pm *ProtocolManager) ProposeRaftRemoveNode(nodeID *discover.NodeID) error

func (*ProtocolManager) ProposeRaftRequestLead

func (pm *ProtocolManager) ProposeRaftRequestLead() error

func (*ProtocolManager) PublishRaftEntries

func (pm *ProtocolManager) PublishRaftEntries(ents []pb.Entry) error

func (*ProtocolManager) PublishRaftSnapshot

func (pm *ProtocolManager) PublishRaftSnapshot(snap pb.Snapshot) error

func (*ProtocolManager) Quorum

func (pm *ProtocolManager) Quorum() uint32

func (*ProtocolManager) RLockMyNodes

func (pm *ProtocolManager) RLockMyNodes()

func (*ProtocolManager) RUnlockMyNodes

func (pm *ProtocolManager) RUnlockMyNodes()

func (*ProtocolManager) RegisterPeer

func (pm *ProtocolManager) RegisterPeer(peer *pkgservice.PttPeer, peerType pkgservice.PeerType, isLocked bool) error

func (*ProtocolManager) RegisterPendingPeer

func (pm *ProtocolManager) RegisterPendingPeer(peer *pkgservice.PttPeer, isLocked bool) error

func (*ProtocolManager) RemoveBoardRequests

func (pm *ProtocolManager) RemoveBoardRequests(hash []byte) (bool, error)

func (*ProtocolManager) RemoveFriendRequests

func (pm *ProtocolManager) RemoveFriendRequests(hash []byte) (bool, error)

func (*ProtocolManager) RemoveMeRequests

func (pm *ProtocolManager) RemoveMeRequests(hash []byte) (bool, error)

func (*ProtocolManager) RevokeNode

func (pm *ProtocolManager) RevokeNode(nodeID *discover.NodeID) error

RevokeNode intends to revoke a specific node

func (*ProtocolManager) SendRaftMsgs

func (pm *ProtocolManager) SendRaftMsgs(msgs []pb.Message) error

func (*ProtocolManager) ServeRaftChannels

func (pm *ProtocolManager) ServeRaftChannels() error

func (*ProtocolManager) ServeRaftProposal

func (pm *ProtocolManager) ServeRaftProposal()

func (*ProtocolManager) SetMasterDB

func (pm *ProtocolManager) SetMasterDB(oplog *pkgservice.BaseOplog)

func (*ProtocolManager) SetMeDB

func (pm *ProtocolManager) SetMeDB(oplog *pkgservice.BaseOplog)

func (*ProtocolManager) SetMeOplogIsSync

func (pm *ProtocolManager) SetMeOplogIsSync(oplog *MeOplog, isBroadcast bool) (bool, error)

func (*ProtocolManager) SetNewestEntityLog

func (pm *ProtocolManager) SetNewestEntityLog(
	oplog *pkgservice.BaseOplog,

	spm pkgservice.ServiceProtocolManager,
) (types.Bool, error)

func (*ProtocolManager) SetNewestMeOplog

func (pm *ProtocolManager) SetNewestMeOplog(oplog *pkgservice.BaseOplog) (err error)

func (*ProtocolManager) SetRaftAppliedIndex

func (pm *ProtocolManager) SetRaftAppliedIndex(idx uint64, isLocked bool) error

raft-applied-index

func (*ProtocolManager) SetRaftConfState

func (pm *ProtocolManager) SetRaftConfState(cs pb.ConfState, isLocked bool) error

func (*ProtocolManager) SetRaftLastIndex

func (pm *ProtocolManager) SetRaftLastIndex(idx uint64, isLocked bool) error

func (*ProtocolManager) SetRaftLead

func (pm *ProtocolManager) SetRaftLead(idx uint64, isLocked bool) error

func (*ProtocolManager) SetRaftSnapshotIndex

func (pm *ProtocolManager) SetRaftSnapshotIndex(idx uint64, isLocked bool) error

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start() error

func (*ProtocolManager) StartRaft

func (pm *ProtocolManager) StartRaft(peers []raft.Peer, isNew bool) error

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop() error

func (*ProtocolManager) StopRaft

func (pm *ProtocolManager) StopRaft() error

func (*ProtocolManager) Sync

func (pm *ProtocolManager) Sync(peer *pkgservice.PttPeer) error

func (*ProtocolManager) SyncJoinBoard

func (pm *ProtocolManager) SyncJoinBoard() error

func (*ProtocolManager) SyncJoinBoardLoop

func (pm *ProtocolManager) SyncJoinBoardLoop() error

func (*ProtocolManager) SyncJoinFriend

func (pm *ProtocolManager) SyncJoinFriend() error

func (*ProtocolManager) SyncJoinFriendLoop

func (pm *ProtocolManager) SyncJoinFriendLoop() error

func (*ProtocolManager) SyncJoinMe

func (pm *ProtocolManager) SyncJoinMe() error

func (*ProtocolManager) SyncJoinMeLoop

func (pm *ProtocolManager) SyncJoinMeLoop() error

func (*ProtocolManager) SyncPendingMeOplog

func (pm *ProtocolManager) SyncPendingMeOplog(peer *pkgservice.PttPeer) error

func (*ProtocolManager) UnlockMyNodes

func (pm *ProtocolManager) UnlockMyNodes()

func (*ProtocolManager) ValidateIntegrateSignMyOplog

func (pm *ProtocolManager) ValidateIntegrateSignMyOplog(oplog *pkgservice.BaseOplog, isLocked bool) (err error)

type PublicAPI

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

func NewPublicAPI

func NewPublicAPI(b *Backend) *PublicAPI

func (*PublicAPI) Get

func (api *PublicAPI) Get() (*BackendMyInfo, error)

func (*PublicAPI) GetMeList

func (api *PublicAPI) GetMeList() ([]*BackendMyInfo, error)

func (*PublicAPI) ShowURL

func (api *PublicAPI) ShowURL() (*pkgservice.BackendJoinURL, error)

type RaftStatus

type RaftStatus struct {
	Lead          uint64
	LastIndex     uint64       `json:"LI"`
	SnapshotIndex uint64       `json:"SI"`
	AppliedInex   uint64       `json:"AI"`
	ConfState     pb.ConfState `json:"CS"`
	HardState     pb.HardState `json:"HS"`
	RSLastIndex   uint64       `json:"li"`
}

type RaftStorage

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

func NewRaftStorage

func NewRaftStorage(isClean bool, myID *types.PttID) (*RaftStorage, error)

func NewRaftStorageWithClean

func NewRaftStorageWithClean(myID *types.PttID) (*RaftStorage, error)

func (*RaftStorage) Append

func (rs *RaftStorage) Append(ents []pb.Entry) error

func (*RaftStorage) ApplySnapshot

func (rs *RaftStorage) ApplySnapshot(snap pb.Snapshot) error

func (*RaftStorage) Compact

func (rs *RaftStorage) Compact(idx uint64, isLocked bool) error

func (*RaftStorage) CreateSnapshot

func (rs *RaftStorage) CreateSnapshot(i uint64, cs *pb.ConfState, data []byte) (pb.Snapshot, error)

func (*RaftStorage) Entries

func (rs *RaftStorage) Entries(startIdx uint64, endIdx uint64, maxSize uint64) ([]pb.Entry, error)

func (*RaftStorage) FirstIndex

func (rs *RaftStorage) FirstIndex() (uint64, error)

func (*RaftStorage) GetEntry

func (rs *RaftStorage) GetEntry(idx uint64) (pb.Entry, error)

func (*RaftStorage) GetIdxByKey

func (rs *RaftStorage) GetIdxByKey(key []byte) (uint64, error)

func (*RaftStorage) GetIter

func (rs *RaftStorage) GetIter(idx uint64) (iterator.Iterator, error)

func (*RaftStorage) GetPrevIter

func (rs *RaftStorage) GetPrevIter(idx uint64) (iterator.Iterator, error)

func (*RaftStorage) GetTermByIdx

func (rs *RaftStorage) GetTermByIdx(idx uint64) (uint64, error)

func (*RaftStorage) InitialState

func (rs *RaftStorage) InitialState() (pb.HardState, pb.ConfState, error)

func (*RaftStorage) LastIndex

func (rs *RaftStorage) LastIndex() (uint64, error)

func (*RaftStorage) LoadHardState

func (rs *RaftStorage) LoadHardState() (pb.HardState, error)

func (*RaftStorage) LoadSnapshot

func (rs *RaftStorage) LoadSnapshot() (pb.Snapshot, error)

func (*RaftStorage) Lock

func (rs *RaftStorage) Lock()

func (*RaftStorage) MarshalKey

func (rs *RaftStorage) MarshalKey(idx uint64) ([]byte, error)

func (*RaftStorage) MarshalKeyRaftHardState

func (rs *RaftStorage) MarshalKeyRaftHardState() ([]byte, error)

func (*RaftStorage) MarshalKeyRaftSnapshot

func (rs *RaftStorage) MarshalKeyRaftSnapshot() ([]byte, error)

func (*RaftStorage) SaveEntry

func (rs *RaftStorage) SaveEntry(ent pb.Entry, isLocked bool) error

func (*RaftStorage) SetHardState

func (rs *RaftStorage) SetHardState(st pb.HardState) error

func (*RaftStorage) Snapshot

func (rs *RaftStorage) Snapshot() (pb.Snapshot, error)

func (*RaftStorage) Term

func (rs *RaftStorage) Term(idx uint64) (uint64, error)

func (*RaftStorage) Unlock

func (rs *RaftStorage) Unlock()

type RequestRaftLead

type RequestRaftLead struct{}

type SendRaftMsgs

type SendRaftMsgs struct {
	Msgs []pb.Message `json:"M"`
}

type ServiceProtocolManager

type ServiceProtocolManager struct {
	*pkgservice.BaseServiceProtocolManager

	MyID   *types.PttID
	MyInfo *MyInfo
	// contains filtered or unexported fields
}

func NewServiceProtocolManager

func NewServiceProtocolManager(myID *types.PttID, ptt pkgservice.MyPtt, service pkgservice.Service, contentBackend *content.Backend) (*ServiceProtocolManager, error)

func (*ServiceProtocolManager) CreateMe

func (spm *ServiceProtocolManager) CreateMe(myID *types.PttID, myKey *ecdsa.PrivateKey, contentBackend *content.Backend) error

func (*ServiceProtocolManager) GetMeList

func (spm *ServiceProtocolManager) GetMeList(myID *types.PttID, contentBackend *content.Backend, startingID *types.PttID, limit int) (*MyInfo, []*MyInfo, error)

func (*ServiceProtocolManager) NewEmptyEntity

func (spm *ServiceProtocolManager) NewEmptyEntity() pkgservice.Entity

type SyncNodeNameInfo

type SyncNodeNameInfo struct {
	LogID    *types.PttID    `json:"pl,omitempty"`
	NodeName []byte          `json:"N,omitempty"`
	UpdateTS types.Timestamp `json:"UT"`
	Status   types.Status    `json:"S"`
}

Source Files

Jump to

Keyboard shortcuts

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