Documentation ¶
Index ¶
- Constants
- Variables
- func DBPrefix(dbPrefix []byte, id *types.PttID) ([]byte, error)
- func DiffMerkleKeys(myKeys [][]byte, theirKeys [][]byte) ([][]byte, [][]byte, error)
- func DiffMerkleTree(myNodes []*MerkleNode, theirNodes []*MerkleNode, ts types.Timestamp, ...) ([]*MerkleNode, []*MerkleNode, error)
- func DiffOplogKeys(myKeys [][]byte, theirKeys [][]byte) ([][]byte, [][]byte, error)
- func ErrResp(code error, format string, v ...interface{}) error
- func GenChallenge() []byte
- func GetMerkleName(merkle *Merkle, pm ProtocolManager) string
- func GetOplogIterWithOplog(oplog *BaseOplog, startID *types.PttID, listOrder pttdb.ListOrder, ...) (iterator.Iterator, error)
- func HandleFailedOplogs(oplogs []*BaseOplog, setDB func(oplog *BaseOplog), ...) error
- func HandleFailedValidOplogs(oplogs []*BaseOplog, peer *PttPeer, info ProcessInfo, ...) error
- func HandleOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool, pm ProtocolManager, ...) error
- func HandlePendingOplogs(oplogs []*BaseOplog, peer *PttPeer, pm ProtocolManager, info ProcessInfo, ...) error
- func IDInOplogSigns(id *types.PttID, signs []*SignInfo) bool
- func InitService(dataDir string) error
- func MarshalCode(code CodeType) ([]byte, error)
- func MarshalOp(op OpType) ([]byte, error)
- func MergeKeysInMerkleNodes(myNodes []*MerkleNode, theirNodes []*MerkleNode) ([][]byte, [][]byte, error)
- func NewObjectWithOplog(obj Object, oplog *BaseOplog)
- func NewPttIDWithMixedIDs(pttIDs []*types.PttID) (*types.PttID, error)
- func NewPttIDWithMyID(myID *types.PttID) (*types.PttID, error)
- func OplogKeyToIDBytes(key []byte) ([]byte, error)
- func OplogKeyToIdxKey(key []byte, dbIdxPrefix []byte) []byte
- func PMHandleMessageWrapper(pm ProtocolManager, hash *common.Address, encData []byte, peer *PttPeer) error
- func PMOplogMerkleTreeLoop(pm ProtocolManager, merkle *Merkle) error
- func PMSync(pm ProtocolManager) error
- func PrestartPM(pm ProtocolManager) error
- func ProtocolFailedEntityLog() error
- func ScrambleBuf(buf [][]byte) ([][]byte, error)
- func SetDeleteObjectWithOplog(obj Object, status types.Status, oplog *BaseOplog)
- func SetEntityWithOplog(entity Entity, status types.Status, oplog *BaseOplog) error
- func SetFailedObjectWithOplog(obj Object, oplog *BaseOplog, ts types.Timestamp)
- func SetLocale(locale Locale) error
- func SetNewEntityWithOplog(entity Entity, status types.Status, oplog *BaseOplog) error
- func SetNewObjectWithOplog(obj Object, oplog *BaseOplog)
- func SetPendingPersonSyncInfo(person Object, pendingStatus types.Status, oplog *BaseOplog) error
- func SetPttDB(myID *types.PttID, oplog *BaseOplog)
- func SetUpdateObjectWithOplog(obj Object, oplog *BaseOplog)
- func SignData(bytes []byte, keyInfo *KeyInfo) ([]byte, []byte, []byte, []byte, error)
- func StartPM(pm ProtocolManager) error
- func StopPM(pm ProtocolManager) error
- func TeardownService()
- func UnscrambleBuf(buf [][]byte) ([][]byte, error)
- func ValidateMerkleTree(myNodes []*MerkleNode, theirNodes []*MerkleNode, ts types.Timestamp, ...) (types.Timestamp, bool)
- func VerifyData(bytesWithSalt []byte, expectedHash []byte, sig []byte, pubKeyBytes []byte, ...) error
- type AddOplog
- type AddOplogs
- type ApproveJoin
- type ApproveJoinData
- type ApproveJoinEntity
- type ArticleBlock
- type Backend
- type BackendConfirmJoin
- type BackendCountPeers
- type BackendJoinRequest
- type BackendJoinURL
- type BackendMerkle
- type BackendMerkleNode
- type BackendPeer
- type BaseEntity
- func (e *BaseEntity) AddOwnerID(id *types.PttID)
- func (e *BaseEntity) DB() *pttdb.LDBBatch
- func (e *BaseEntity) DBLock() *types.LockMap
- func (e *BaseEntity) GetCreateTS() types.Timestamp
- func (e *BaseEntity) GetCreatorID() *types.PttID
- func (e *BaseEntity) GetEntityType() EntityType
- func (e *BaseEntity) GetID() *types.PttID
- func (e *BaseEntity) GetLogID() *types.PttID
- func (e *BaseEntity) GetMeLogID() *types.PttID
- func (e *BaseEntity) GetMeLogTS() types.Timestamp
- func (e *BaseEntity) GetOwnerIDs() []*types.PttID
- func (e *BaseEntity) GetStatus() types.Status
- func (e *BaseEntity) GetSyncInfo() SyncInfo
- func (e *BaseEntity) GetUpdateLogID() *types.PttID
- func (e *BaseEntity) GetUpdaterID() *types.PttID
- func (e *BaseEntity) IDString() string
- func (e *BaseEntity) Init(pm ProtocolManager, ptt Ptt, service Service)
- func (e *BaseEntity) IsOwner(id *types.PttID) bool
- func (e *BaseEntity) Lock() error
- func (e *BaseEntity) MustLock() error
- func (e *BaseEntity) Name() string
- func (e *BaseEntity) PM() ProtocolManager
- func (e *BaseEntity) Prestart() error
- func (e *BaseEntity) PrestartAndStart() error
- func (e *BaseEntity) Ptt() Ptt
- func (e *BaseEntity) RLock() error
- func (e *BaseEntity) RUnlock() error
- func (e *BaseEntity) RemoveOwnerID(id *types.PttID)
- func (e *BaseEntity) ResetJoinMeta()
- func (e *BaseEntity) ResetOwnerIDs()
- func (e *BaseEntity) Service() Service
- func (e *BaseEntity) SetCreateTS(ts types.Timestamp)
- func (e *BaseEntity) SetDB(db *pttdb.LDBBatch, dbLock *types.LockMap)
- func (e *BaseEntity) SetEntityType(t EntityType)
- func (e *BaseEntity) SetID(id *types.PttID)
- func (e *BaseEntity) SetJoinTS(ts types.Timestamp)
- func (e *BaseEntity) SetLogID(id *types.PttID)
- func (e *BaseEntity) SetMeLogID(id *types.PttID)
- func (e *BaseEntity) SetMeLogTS(ts types.Timestamp)
- func (e *BaseEntity) SetName(name string)
- func (e *BaseEntity) SetStatus(status types.Status)
- func (e *BaseEntity) SetSyncInfo(syncInfo SyncInfo)
- func (e *BaseEntity) SetUpdateLogID(id *types.PttID)
- func (e *BaseEntity) SetUpdaterID(id *types.PttID)
- func (e *BaseEntity) Start() error
- func (e *BaseEntity) Stop() error
- func (e *BaseEntity) Unlock() error
- type BaseMeteredMsgReadWriter
- type BaseObject
- func (o *BaseObject) CheckIsAllGood() types.Bool
- func (o *BaseObject) CloneDB(o2 *BaseObject)
- func (o *BaseObject) DB() *pttdb.LDBBatch
- func (o *BaseObject) DBLock() *types.LockMap
- func (o *BaseObject) Delete(isLocked bool) error
- func (o *BaseObject) DeleteByKey(key []byte, isLocked bool) error
- func (o *BaseObject) FullDBIdxPrefix() []byte
- func (o *BaseObject) FullDBPrefix() []byte
- func (o *BaseObject) GetBaseObject() *BaseObject
- func (o *BaseObject) GetBlockInfo() *BlockInfo
- func (o *BaseObject) GetCreateTS() types.Timestamp
- func (o *BaseObject) GetCreatorID() *types.PttID
- func (obj *BaseObject) GetCrossObjIterWithObj(startPrefix []byte, startID *types.PttID, listOrder pttdb.ListOrder, ...) (iterator.Iterator, error)
- func (o *BaseObject) GetEntityID() *types.PttID
- func (o *BaseObject) GetID() *types.PttID
- func (o *BaseObject) GetIsAllGood() types.Bool
- func (o *BaseObject) GetIsGood() types.Bool
- func (o *BaseObject) GetKey(id *types.PttID, isLocked bool) ([]byte, error)
- func (o *BaseObject) GetLogID() *types.PttID
- func (o *BaseObject) GetNewestLogID() *types.PttID
- func (obj *BaseObject) GetObjIdxIterWithObj(startID *types.PttID, listOrder pttdb.ListOrder, isLocked bool) (iterator.Iterator, error)
- func (obj *BaseObject) GetObjIterWithObj(startID *types.PttID, listOrder pttdb.ListOrder, isLocked bool) (iterator.Iterator, error)
- func (o *BaseObject) GetStatus() types.Status
- func (o *BaseObject) GetUpdateLogID() *types.PttID
- func (o *BaseObject) GetUpdaterID() *types.PttID
- func (o *BaseObject) GetValueByID(isLocked bool) ([]byte, error)
- func (o *BaseObject) IdxKey() ([]byte, error)
- func (o *BaseObject) IdxPrefix() []byte
- func (o *BaseObject) KeyToID(key []byte) (*types.PttID, error)
- func (o *BaseObject) Lock() error
- func (o *BaseObject) NewEmptyObj() *BaseObject
- func (o *BaseObject) RLock() error
- func (o *BaseObject) RUnlock() error
- func (o *BaseObject) RemoveMeta()
- func (o *BaseObject) SetBlockInfo(blockInfo *BlockInfo) error
- func (o *BaseObject) SetBlockInfoDB() func(blockInfo *BlockInfo, objID *types.PttID)
- func (o *BaseObject) SetCreateTS(ts types.Timestamp)
- func (o *BaseObject) SetCreatorID(id *types.PttID)
- func (o *BaseObject) SetDB(db *pttdb.LDBBatch, dbLock *types.LockMap, entityID *types.PttID, ...)
- func (o *BaseObject) SetEntityID(id *types.PttID)
- func (o *BaseObject) SetFullDBPrefix(fullDBPrefix []byte)
- func (o *BaseObject) SetID(id *types.PttID)
- func (o *BaseObject) SetIsAllGood(isAllGood types.Bool)
- func (o *BaseObject) SetIsGood(isGood types.Bool)
- func (o *BaseObject) SetLogID(id *types.PttID)
- func (o *BaseObject) SetMediaDB() func(media *Media)
- func (o *BaseObject) SetStatus(status types.Status)
- func (o *BaseObject) SetUpdateLogID(id *types.PttID)
- func (o *BaseObject) SetUpdaterID(id *types.PttID)
- func (o *BaseObject) SetVersion(v types.Version)
- func (o *BaseObject) Unlock() error
- type BaseOplog
- func ConcatLog(slices [][]*BaseOplog) ([]*BaseOplog, error)
- func GetOplogList(oplog *BaseOplog, startID *types.PttID, limit int, listOrder pttdb.ListOrder, ...) ([]*BaseOplog, error)
- func MasterOplogsToOplogs(typedLogs []*MasterOplog) []*BaseOplog
- func MemberOplogsToOplogs(typedLogs []*MemberOplog) []*BaseOplog
- func NewOplog(id *types.PttID, ts types.Timestamp, doerID *types.PttID, op OpType, ...) (*BaseOplog, error)
- func NewOplogForLoadData(data interface{}, db *pttdb.LDBBatch) *BaseOplog
- func OpKeyOplogsToOplogs(typedLogs []*OpKeyOplog) []*BaseOplog
- func ProcessInfoToBroadcastLogs(info map[types.PttID]*BaseOplog, broadcastLogs []*BaseOplog) []*BaseOplog
- func ProcessInfoToLogs(info map[types.PttID]*BaseOplog, op OpType) []*BaseOplog
- func PttOplogsToOplogs(typedLogs []*PttOplog) []*BaseOplog
- func (o *BaseOplog) CheckAlreadyExists() error
- func (o *BaseOplog) DBPrefix() []byte
- func (o *BaseOplog) DBPrefixInternal() []byte
- func (o *BaseOplog) DBPrefixMaster() []byte
- func (o *BaseOplog) Delete(isLocked bool) error
- func (o *BaseOplog) ForceSave(isLocked bool, merkle *Merkle) error
- func (o *BaseOplog) Get(id *types.PttID, isLocked bool) error
- func (o *BaseOplog) GetDB() *pttdb.LDBBatch
- func (o *BaseOplog) GetDBIdxPrefix() []byte
- func (o *BaseOplog) GetDBLock() *types.LockMap
- func (o *BaseOplog) GetDBMerklePrefix() []byte
- func (o *BaseOplog) GetDBPrefix() []byte
- func (o *BaseOplog) GetDBPrefixInternal() []byte
- func (o *BaseOplog) GetDBPrefixMaster() []byte
- func (o *BaseOplog) GetDBPrefxiID() *types.PttID
- func (o *BaseOplog) GetData(data interface{}) error
- func (o *BaseOplog) GetKey(id *types.PttID, isLocked bool) ([]byte, error)
- func (o *BaseOplog) IdxKey() ([]byte, error)
- func (o *BaseOplog) IdxPrefix() []byte
- func (o *BaseOplog) IntegrateExisting(isLocked bool, merkle *Merkle) (types.Bool, bool, error)
- func (o *BaseOplog) InternalSign(id *types.PttID, keyInfo *KeyInfo) error
- func (o *BaseOplog) Load(key []byte) error
- func (o *BaseOplog) Lock() error
- func (o *BaseOplog) Marshal() ([]byte, error)
- func (o *BaseOplog) MarshalKey(prefix []byte) ([]byte, error)
- func (o *BaseOplog) MarshalMerkleKey() ([]byte, error)
- func (o *BaseOplog) MasterSign(id *types.PttID, keyInfo *KeyInfo) error
- func (o *BaseOplog) Save(isLocked bool, merkle *Merkle) error
- func (o *BaseOplog) SaveCore() ([]byte, *pttdb.Index, []*pttdb.KeyVal, error)
- func (o *BaseOplog) SaveCorePending() ([]byte, *pttdb.Index, []*pttdb.KeyVal, error)
- func (o *BaseOplog) SelectExisting(isLocked bool, merkle *Merkle) (types.Bool, types.Bool, error)
- func (o *BaseOplog) SetDB(db *pttdb.LDBBatch, id *types.PttID, prefix []byte, idxPrefix []byte, ...)
- func (o *BaseOplog) SetMasterLogID(oplogID *types.PttID, weight uint32) error
- func (o *BaseOplog) SetPreLogID(id *types.PttID)
- func (o *BaseOplog) Sign(keyInfo *KeyInfo) error
- func (o *BaseOplog) SignsHash() ([]byte, error)
- func (o *BaseOplog) ToStatus() types.Status
- func (o *BaseOplog) Unlock() error
- func (o *BaseOplog) Unmarshal(data []byte) error
- func (o *BaseOplog) Verify() error
- type BaseProtocolManager
- func (pm *BaseProtocolManager) AddMaster(id *types.PttID, isForce bool) (*Master, *MasterOplog, error)
- func (pm *BaseProtocolManager) AddMember(id *types.PttID, isForce bool) (*Member, *MemberOplog, error)
- func (pm *BaseProtocolManager) AddPerson(id *types.PttID, addOp OpType, isForce bool, origPerson Object, opData OpData, ...) (Object, *BaseOplog, error)
- func (pm *BaseProtocolManager) ApproveJoin(joinEntity *JoinEntity, keyInfo *KeyInfo, peer *PttPeer) (*KeyInfo, interface{}, error)
- func (pm *BaseProtocolManager) BaseDeleteMedia(id *types.PttID, op OpType, merkle *Merkle, setLogDB func(oplog *BaseOplog), ...) error
- func (pm *BaseProtocolManager) BaseHandleDeleteMediaLogs(oplog *BaseOplog, info ProcessInfo, merkle *Merkle, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) BaseHandleFailedValidDeleteMediaLog(oplog *BaseOplog, info ProcessInfo, ...) error
- func (pm *BaseProtocolManager) BaseHandlePendingDeleteMediaLogs(oplog *BaseOplog, info ProcessInfo, merkle *Merkle, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) BroadcastMasterOplog(oplog *MasterOplog) error
- func (pm *BaseProtocolManager) BroadcastMasterOplogs(opKeyLogs []*MasterOplog) error
- func (pm *BaseProtocolManager) BroadcastMemberOplog(oplog *MemberOplog) error
- func (pm *BaseProtocolManager) BroadcastMemberOplogs(opKeyLogs []*MemberOplog) error
- func (pm *BaseProtocolManager) BroadcastOpKeyOplog(oplog *OpKeyOplog) error
- func (pm *BaseProtocolManager) BroadcastOpKeyOplogs(opKeyLogs []*OpKeyOplog) error
- func (pm *BaseProtocolManager) BroadcastOplog(oplog *BaseOplog, msg OpType, pendingMsg OpType) error
- func (pm *BaseProtocolManager) BroadcastOplogs(oplogs []*BaseOplog, msg OpType, pendingMsg OpType) error
- func (pm *BaseProtocolManager) CleanJoinKey()
- func (pm *BaseProtocolManager) CleanLog0(isRetainLog bool)
- func (pm *BaseProtocolManager) CleanMaster() error
- func (pm *BaseProtocolManager) CleanMasterOplog()
- func (pm *BaseProtocolManager) CleanMember(isRetainMe bool) error
- func (pm *BaseProtocolManager) CleanMemberOplog(isRetainLog bool)
- func (pm *BaseProtocolManager) CleanOpKey()
- func (pm *BaseProtocolManager) CleanOpKeyOplog()
- func (pm *BaseProtocolManager) CleanOplog(oplog *BaseOplog, merkle *Merkle)
- func (pm *BaseProtocolManager) CleanPeers()
- func (pm *BaseProtocolManager) ConnectMaster() error
- func (pm *BaseProtocolManager) CountPeers() (int, error)
- func (pm *BaseProtocolManager) CreateJoinKeyLoop() error
- func (pm *BaseProtocolManager) CreateObject(data CreateData, createOp OpType, merkle *Merkle, ...) (Object, error)
- func (pm *BaseProtocolManager) CreateOpKey() error
- func (pm *BaseProtocolManager) CreateOpKeyLoop() error
- func (pm *BaseProtocolManager) CreatePerson(id *types.PttID, createOp OpType, isForce bool, merkle *Merkle, ...) (Object, *BaseOplog, error)
- func (pm *BaseProtocolManager) DB() *pttdb.LDBBatch
- func (pm *BaseProtocolManager) DBObjLock() *types.LockMap
- func (pm *BaseProtocolManager) DBOpKey() *pttdb.LDBBatch
- func (pm *BaseProtocolManager) DBOpKeyIdxPrefix() []byte
- func (pm *BaseProtocolManager) DBOpKeyLock() *types.LockMap
- func (pm *BaseProtocolManager) DBOpKeyPrefix() []byte
- func (pm *BaseProtocolManager) DefaultPostdeleteEntity(opData OpData, isForce bool) error
- func (pm *BaseProtocolManager) Delete() error
- func (pm *BaseProtocolManager) DeleteEntity(deleteOp OpType, opData OpData, internalPendingStatus types.Status, ...) error
- func (pm *BaseProtocolManager) DeleteMember(id *types.PttID) (bool, error)
- func (pm *BaseProtocolManager) DeleteObject(id *types.PttID, deleteOp OpType, origObj Object, opData OpData, ...) error
- func (pm *BaseProtocolManager) DeletePerson(id *types.PttID, deleteOp OpType, origPerson Object, opData OpData, ...) error
- func (pm *BaseProtocolManager) Entity() Entity
- func (pm *BaseProtocolManager) EventMux() *event.TypeMux
- func (pm *BaseProtocolManager) ExpireOpKeyInfo(keyInfo *KeyInfo, isLocked bool) error
- func (pm *BaseProtocolManager) ExpireOpKeySeconds() int64
- func (pm *BaseProtocolManager) Fix138MasterLog() error
- func (pm *BaseProtocolManager) Fix190Merkle() error
- func (pm *BaseProtocolManager) ForceCreateObject(data CreateData, createOp OpType, merkle *Merkle, ...) (Object, error)
- func (pm *BaseProtocolManager) ForceCreateOpKey() error
- func (pm *BaseProtocolManager) ForceOpKey() chan struct{}
- func (pm *BaseProtocolManager) ForceReconstructMerkle() error
- func (pm *BaseProtocolManager) ForceSignOplog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) ForceSync() chan struct{}
- func (pm *BaseProtocolManager) ForceSyncCycle() time.Duration
- func (pm *BaseProtocolManager) ForceSyncMasterMerkle() (bool, error)
- func (pm *BaseProtocolManager) ForceSyncMedia(syncIDs []*ForceSyncID, peer *PttPeer, syncMsg OpType) error
- func (pm *BaseProtocolManager) ForceSyncMemberMerkle() (bool, error)
- func (pm *BaseProtocolManager) ForceSyncObject(syncIDs []*ForceSyncID, peer *PttPeer, syncMsg OpType) error
- func (pm *BaseProtocolManager) ForceSyncOplog(fromTS types.Timestamp, toTS types.Timestamp, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) ForceSyncOplogAck(fromTS types.Timestamp, toTS types.Timestamp, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) ForceSyncOplogByMerkle(myNewNode *MerkleNode, forceSyncOplogMsg OpType, merkle *Merkle, peer *PttPeer) error
- func (pm *BaseProtocolManager) ForceSyncOplogByMerkleAck(nodes []*MerkleNode, forceSyncOplogAckMsg OpType, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) ForceSyncOplogByOplogAck(theirNewNodes []*MerkleNode, forceSyncOplogByOplogAckMsg OpType, ...) error
- func (pm *BaseProtocolManager) FullBlockDBPrefix(prefix []byte) ([]byte, error)
- func (pm *BaseProtocolManager) FullCleanLog()
- func (pm *BaseProtocolManager) GetEntityLog() (*BaseOplog, error)
- func (pm *BaseProtocolManager) GetJoinKey() (*KeyInfo, error)
- func (pm *BaseProtocolManager) GetJoinKeyFromHash(hash *common.Address) (*KeyInfo, error)
- func (pm *BaseProtocolManager) GetJoinType(hash *common.Address) (JoinType, error)
- func (pm *BaseProtocolManager) GetMaster(id *types.PttID, isLocked bool) (*Master, error)
- func (pm *BaseProtocolManager) GetMasterList(startID *types.PttID, limit int, listOrder pttdb.ListOrder, isLocked bool) ([]*Master, error)
- func (pm *BaseProtocolManager) GetMasterListFromCache(isLocked bool) ([]*Master, error)
- func (pm *BaseProtocolManager) GetMasterOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*MasterOplog, error)
- func (pm *BaseProtocolManager) GetMasterOplogMerkleNodeList(level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*MerkleNode, error)
- func (pm *BaseProtocolManager) GetMasters() map[types.PttID]*Master
- func (pm *BaseProtocolManager) GetMedia(mediaID *types.PttID) (*Media, error)
- func (pm *BaseProtocolManager) GetMember(id *types.PttID, isLocked bool) (*Member, error)
- func (pm *BaseProtocolManager) GetMemberList(startID *types.PttID, limit int, listOrder pttdb.ListOrder, isLocked bool) ([]*Member, error)
- func (pm *BaseProtocolManager) GetMemberLogByMemberID(id *types.PttID, isLocked bool) (*MemberOplog, error)
- func (pm *BaseProtocolManager) GetMemberOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*MemberOplog, error)
- func (pm *BaseProtocolManager) GetMemberOplogMerkleNodeList(level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*MerkleNode, error)
- func (pm *BaseProtocolManager) GetNewestMasterLogID() *types.PttID
- func (pm *BaseProtocolManager) GetNewestOpKey(isLocked bool) (*KeyInfo, error)
- func (pm *BaseProtocolManager) GetOldestOpKey(isLocked bool) (*KeyInfo, error)
- func (pm *BaseProtocolManager) GetOpKeyFromHash(hash *common.Address, isLocked bool) (*KeyInfo, error)
- func (pm *BaseProtocolManager) GetOpKeyListFromDB() ([]*KeyInfo, error)
- func (pm *BaseProtocolManager) GetOpKeyOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*OpKeyOplog, error)
- func (pm *BaseProtocolManager) GetOplog0() *BaseOplog
- func (pm *BaseProtocolManager) GetOplogMerkleNodeList(merkle *Merkle, level MerkleTreeLevel, startKey []byte, limit int, ...) ([]*MerkleNode, error)
- func (pm *BaseProtocolManager) GetOwnerID(isLocked bool) *types.PttID
- func (pm *BaseProtocolManager) GetPeerType(peer *PttPeer) PeerType
- func (pm *BaseProtocolManager) GetPeers() ([]*PttPeer, error)
- func (pm *BaseProtocolManager) GetPendingOplogs(setDB func(oplog *BaseOplog), peer *PttPeer, isGetAll bool) ([]*BaseOplog, []*BaseOplog, error)
- func (pm *BaseProtocolManager) GetPendingPeerByUserID(id *types.PttID, isLocked bool) (*PttPeer, error)
- func (pm *BaseProtocolManager) GetToRenewOpKeySeconds() int
- func (pm *BaseProtocolManager) HandleAddMasterOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddMasterOplogs(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddMemberOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddMemberOplogs(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddOpKeyOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddOpKeyOplogs(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddOplog(dataBytes []byte, ...) error
- func (pm *BaseProtocolManager) HandleAddOplogs(dataBytes []byte, ...) error
- func (pm *BaseProtocolManager) HandleAddPendingMasterOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddPendingMasterOplogs(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddPendingMemberOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddPendingMemberOplogs(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddPendingOpKeyOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddPendingOpKeyOplogs(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleAddPendingOplog(dataBytes []byte, ...) error
- func (pm *BaseProtocolManager) HandleAddPendingOplogs(dataBytes []byte, ...) error
- func (pm *BaseProtocolManager) HandleCreateMediaLogs(oplog *BaseOplog, info ProcessInfo, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleCreateObjectLog(oplog *BaseOplog, obj Object, opData OpData, info ProcessInfo, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleCreatePersonLog(oplog *BaseOplog, person Object, opData OpData, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleDeleteEntityLog(oplog *BaseOplog, info ProcessInfo, opData OpData, status types.Status, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleDeleteObjectLog(oplog *BaseOplog, info ProcessInfo, obj Object, opData OpData, merkle *Merkle, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleDeletePersonLog(oplog *BaseOplog, info ProcessInfo, origPerson Object, opData OpData, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleEntityTerminal(status types.Status, entityLog *BaseOplog, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleFailedCreateMediaLog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) HandleFailedCreateObjectLog(oplog *BaseOplog, obj Object, ...) error
- func (pm *BaseProtocolManager) HandleFailedCreatePersonLog(oplog *BaseOplog, person Object, ...) error
- func (pm *BaseProtocolManager) HandleFailedDeleteEntityLog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) HandleFailedDeleteMediaLog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) HandleFailedDeleteObjectLog(oplog *BaseOplog, obj Object) error
- func (pm *BaseProtocolManager) HandleFailedDeletePersonLog(oplog *BaseOplog, person Object) error
- func (pm *BaseProtocolManager) HandleFailedMasterOplog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) HandleFailedMemberOplog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) HandleFailedOpKeyOplog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) HandleFailedPersonLog(oplog *BaseOplog, person Object) error
- func (pm *BaseProtocolManager) HandleFailedTransferPersonLog(oplog *BaseOplog, person Object) error
- func (pm *BaseProtocolManager) HandleFailedUpdateObjectLog(oplog *BaseOplog, obj Object) error
- func (pm *BaseProtocolManager) HandleFailedUpdatePersonLog(oplog *BaseOplog, origPerson Object) error
- func (pm *BaseProtocolManager) HandleFailedValidCreateMediaLog(oplog *BaseOplog, info ProcessInfo) error
- func (pm *BaseProtocolManager) HandleFailedValidCreateObjectLog(oplog *BaseOplog, obj Object, ...) error
- func (pm *BaseProtocolManager) HandleFailedValidCreatePersonLog(oplog *BaseOplog, person Object, ...) error
- func (pm *BaseProtocolManager) HandleFailedValidDeleteEntityLog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) HandleFailedValidDeleteObjectLog(oplog *BaseOplog, obj Object, info ProcessInfo, ...) error
- func (pm *BaseProtocolManager) HandleFailedValidDeletePersonLog(oplog *BaseOplog, origPerson Object) error
- func (pm *BaseProtocolManager) HandleFailedValidMasterOplog(oplog *BaseOplog, processInfo ProcessInfo) error
- func (pm *BaseProtocolManager) HandleFailedValidMemberOplog(oplog *BaseOplog, processInfo ProcessInfo) error
- func (pm *BaseProtocolManager) HandleFailedValidPersonLog(oplog *BaseOplog, person Object) error
- func (pm *BaseProtocolManager) HandleFailedValidTransferPersonLog(oplog *BaseOplog, origPerson Object) error
- func (pm *BaseProtocolManager) HandleFailedValidUpdateObjectLog(oplog *BaseOplog, obj Object, info ProcessInfo, ...) error
- func (pm *BaseProtocolManager) HandleFailedValidUpdatePersonLog(oplog *BaseOplog, origPerson Object) error
- func (pm *BaseProtocolManager) HandleForceSyncMasterOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMasterOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMasterOplogByMerkle(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMasterOplogByMerkleAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMasterOplogByOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMedia(dataBytes []byte, peer *PttPeer, syncAckMsg OpType) error
- func (pm *BaseProtocolManager) HandleForceSyncMediaAck(dataBytes []byte, peer *PttPeer, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) HandleForceSyncMemberOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMemberOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMemberOplogByMerkle(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMemberOplogByMerkleAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncMemberOplogByOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleForceSyncObject(dataBytes []byte, peer *PttPeer, obj Object, syncAckMsg OpType) error
- func (pm *BaseProtocolManager) HandleForceSyncObjectAck(obj Object, peer *PttPeer, origObj Object, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) HandleForceSyncOplog(dataBytes []byte, peer *PttPeer, merkle *Merkle, forceSyncOplogAckMsg OpType) error
- func (pm *BaseProtocolManager) HandleForceSyncOplogAck(dataBytes []byte, peer *PttPeer, merkle *Merkle, info ProcessInfo, ...) error
- func (pm *BaseProtocolManager) HandleForceSyncOplogByMerkle(dataBytes []byte, peer *PttPeer, forceSyncOplogAckMsg OpType, ...) error
- func (pm *BaseProtocolManager) HandleForceSyncOplogByMerkleAck(dataBytes []byte, peer *PttPeer, forceSyncOplogMsg OpType, merkle *Merkle) error
- func (pm *BaseProtocolManager) HandleForceSyncOplogByOplogAck(dataBytes []byte, peer *PttPeer, ...) error
- func (pm *BaseProtocolManager) HandleIdentifyPeer(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleIdentifyPeerAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleLog0s(logs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error
- func (pm *BaseProtocolManager) HandleMasterOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error
- func (pm *BaseProtocolManager) HandleMemberOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error
- func (pm *BaseProtocolManager) HandleMessage(op OpType, dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleNonRegisteredMessage(op OpType, dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleOpKeyOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error
- func (pm *BaseProtocolManager) HandlePendingCreateMediaLogs(oplog *BaseOplog, info ProcessInfo, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandlePendingCreateObjectLog(oplog *BaseOplog, obj Object, opData OpData, info ProcessInfo, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandlePendingCreatePersonLog(oplog *BaseOplog, person Object, opData OpData) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandlePendingDeleteEntityLog(oplog *BaseOplog, info ProcessInfo, internalPendingStatus types.Status, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandlePendingDeleteObjectLog(oplog *BaseOplog, info ProcessInfo, obj Object, opData OpData, merkle *Merkle, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandlePendingDeletePersonLog(oplog *BaseOplog, info ProcessInfo, origPerson Object, opData OpData, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandlePendingMasterOplogs(oplogs []*BaseOplog, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandlePendingMemberOplogs(oplogs []*BaseOplog, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandlePendingOpKeyOplogs(oplogs []*BaseOplog, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandlePendingTransferPersonLog(oplog *BaseOplog, origPerson Object, opData *PersonOpTransferPerson, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandlePendingUpdateObjectLog(oplog *BaseOplog, opData OpData, obj Object, info ProcessInfo, merkle *Merkle, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandlePendingUpdatePersonLog(oplog *BaseOplog, origPerson Object, opData OpData, merkle *Merkle, ...) (types.Bool, []*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleSyncBlock(dataBytes []byte, peer *PttPeer, obj Object, syncAckMsg OpType) error
- func (pm *BaseProtocolManager) HandleSyncCreateBlockAck(dataBytes []byte, peer *PttPeer, obj Object, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) HandleSyncCreateMedia(dataBytes []byte, peer *PttPeer, syncAckMsg OpType) error
- func (pm *BaseProtocolManager) HandleSyncCreateMediaAck(dataBytes []byte, peer *PttPeer, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) HandleSyncCreateMediaBlockAck(dataBytes []byte, peer *PttPeer, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) HandleSyncCreateObject(dataBytes []byte, peer *PttPeer, obj Object, syncAckMsg OpType) error
- func (pm *BaseProtocolManager) HandleSyncCreateObjectAck(obj Object, peer *PttPeer, origObj Object, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) HandleSyncCreateOpKey(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncCreateOpKeyAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncCreateOpKeyAckObj(opKey *KeyInfo, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncMasterOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncMasterOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncMasterOplogInvalid(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncMediaBlock(dataBytes []byte, peer *PttPeer, ackMsg OpType) error
- func (pm *BaseProtocolManager) HandleSyncMemberOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncMemberOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncMemberOplogInvalid(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncNewMasterOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncNewMasterOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncNewMemberOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncNewMemberOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncOpKeyOplog(dataBytes []byte, peer *PttPeer, syncMsg OpType) error
- func (pm *BaseProtocolManager) HandleSyncOplog(dataBytes []byte, peer *PttPeer, merkle *Merkle, forceSyncOplogMsg OpType, ...) error
- func (pm *BaseProtocolManager) HandleSyncOplogAck(dataBytes []byte, peer *PttPeer, merkle *Merkle, setDB func(oplog *BaseOplog), ...) error
- func (pm *BaseProtocolManager) HandleSyncOplogInvalid(dataBytes []byte, peer *PttPeer, merkle *Merkle, forceSyncOplogMsg OpType) error
- func (pm *BaseProtocolManager) HandleSyncOplogNewOplogs(dataBytes []byte, peer *PttPeer, setDB func(oplog *BaseOplog), ...) error
- func (pm *BaseProtocolManager) HandleSyncOplogNewOplogsAck(dataBytes []byte, peer *PttPeer, setDB func(oplog *BaseOplog), ...) error
- func (pm *BaseProtocolManager) HandleSyncPendingMasterOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncPendingMasterOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncPendingMemberOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncPendingMemberOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncPendingOpKeyOplog(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncPendingOpKeyOplogAck(dataBytes []byte, peer *PttPeer) error
- func (pm *BaseProtocolManager) HandleSyncPendingOplog(dataBytes []byte, peer *PttPeer, ...) error
- func (pm *BaseProtocolManager) HandleSyncPendingOplogAck(dataBytes []byte, peer *PttPeer, ...) error
- func (pm *BaseProtocolManager) HandleSyncUpdateBlockAck(dataBytes []byte, peer *PttPeer, obj Object, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) HandleSyncUpdateObject(dataBytes []byte, peer *PttPeer, obj Object, syncAckMsg OpType) error
- func (pm *BaseProtocolManager) HandleSyncUpdateObjectAck(obj Object, peer *PttPeer, origObj Object, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) HandleTransferPersonLog(oplog *BaseOplog, origPerson Object, opData *PersonOpTransferPerson, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleUpdateObjectLog(oplog *BaseOplog, opData OpData, obj Object, info ProcessInfo, merkle *Merkle, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) HandleUpdatePersonLog(oplog *BaseOplog, origPerson Object, opData OpData, merkle *Merkle, ...) ([]*BaseOplog, error)
- func (pm *BaseProtocolManager) IdentifyPeer(peer *PttPeer)
- func (pm *BaseProtocolManager) IdentifyPeerAck(data *IdentifyPeer, peer *PttPeer) error
- func (pm *BaseProtocolManager) IntegrateOplog(oplog *BaseOplog, isLocked bool, merkle *Merkle) (types.Bool, bool, error)
- func (pm *BaseProtocolManager) InternalSign(oplog *BaseOplog) (bool, error)
- func (pm *BaseProtocolManager) IsGoodID(id *types.PttID, nodeID *discover.NodeID) bool
- func (pm *BaseProtocolManager) IsImportantPeer(peer *PttPeer) bool
- func (pm *BaseProtocolManager) IsJoinKeyHash(hash *common.Address) bool
- func (pm *BaseProtocolManager) IsMaster(id *types.PttID, isLocked bool) bool
- func (pm *BaseProtocolManager) IsMember(id *types.PttID, isLocked bool) bool
- func (pm *BaseProtocolManager) IsMemberPeer(peer *PttPeer) bool
- func (pm *BaseProtocolManager) IsMyDevice(peer *PttPeer) bool
- func (pm *BaseProtocolManager) IsPendingMember(id *types.PttID, isLocked bool) bool
- func (pm *BaseProtocolManager) IsPendingPeer(peer *PttPeer) bool
- func (pm *BaseProtocolManager) IsStart() bool
- func (pm *BaseProtocolManager) IsSuspiciousID(id *types.PttID, nodeID *discover.NodeID) bool
- func (pm *BaseProtocolManager) IsValidOplog(signInfos []*SignInfo) (*types.PttID, uint32, bool)
- func (pm *BaseProtocolManager) JoinKeyList() []*KeyInfo
- func (pm *BaseProtocolManager) LeaveEntity() (bool, error)
- func (pm *BaseProtocolManager) LoadPeers() error
- func (pm *BaseProtocolManager) Log0Merkle() *Merkle
- func (pm *BaseProtocolManager) MasterLog0Hash() []byte
- func (pm *BaseProtocolManager) MasterMerkle() *Merkle
- func (pm *BaseProtocolManager) MaybePostcreateEntity(oplog *BaseOplog, isForceNot bool, postcreate func(entity Entity) error) error
- func (pm *BaseProtocolManager) MemberMerkle() *Merkle
- func (pm *BaseProtocolManager) MigrateMaster(id *types.PttID) error
- func (pm *BaseProtocolManager) MigrateMember(fromID *types.PttID, toID *types.PttID) error
- func (pm *BaseProtocolManager) MyMemberLog() *MemberOplog
- func (pm *BaseProtocolManager) NewMaster(id *types.PttID) (Object, OpData, error)
- func (pm *BaseProtocolManager) NewMasterOplog(keyID *types.PttID, op OpType, opData OpData) (Oplog, error)
- func (pm *BaseProtocolManager) NewMasterOplogWithTS(keyID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error)
- func (pm *BaseProtocolManager) NewMedia(theData CreateData) (Object, OpData, error)
- func (pm *BaseProtocolManager) NewMember(id *types.PttID) (Object, OpData, error)
- func (pm *BaseProtocolManager) NewMemberOplog(keyID *types.PttID, op OpType, opData OpData) (Oplog, error)
- func (pm *BaseProtocolManager) NewMemberOplogWithTS(keyID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error)
- func (pm *BaseProtocolManager) NewOpKey(data CreateData) (Object, OpData, error)
- func (pm *BaseProtocolManager) NewOpKeyOplog(keyID *types.PttID, op OpType, opData OpData) (Oplog, error)
- func (pm *BaseProtocolManager) NewOpKeyOplogWithTS(keyID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error)
- func (pm *BaseProtocolManager) NewPeerCh() chan *PttPeer
- func (pm *BaseProtocolManager) NoMorePeers() chan struct{}
- func (pm *BaseProtocolManager) OpKeyList() []*KeyInfo
- func (pm *BaseProtocolManager) OpKeys() map[common.Address]*KeyInfo
- func (pm *BaseProtocolManager) Peers() *PttPeerSet
- func (pm *BaseProtocolManager) PostdeleteEntity(opData OpData, isForce bool) error
- func (pm *BaseProtocolManager) PostprocessPendingDeleteOplog(oplog *BaseOplog, toBroadcastLogs []*BaseOplog) []*BaseOplog
- func (pm *BaseProtocolManager) Poststop() error
- func (pm *BaseProtocolManager) Prestart() error
- func (pm *BaseProtocolManager) Prestop() error
- func (pm *BaseProtocolManager) Ptt() Ptt
- func (pm *BaseProtocolManager) QuitSync() chan struct{}
- func (pm *BaseProtocolManager) RegisterMaster(master *Master, isLocked bool, isSkipPtt bool) error
- func (pm *BaseProtocolManager) RegisterMember(member *Member, isLocked bool) error
- func (pm *BaseProtocolManager) RegisterOpKey(keyInfo *KeyInfo, isLocked bool) error
- func (pm *BaseProtocolManager) RegisterPeer(peer *PttPeer, peerType PeerType, isLocked bool) (err error)
- func (pm *BaseProtocolManager) RegisterPendingPeer(peer *PttPeer, isLocked bool) error
- func (pm *BaseProtocolManager) RemoveMediaInfosByOplog(mediaInfos map[types.PttID]*BaseOplog, mediaIDs []*types.PttID, ...)
- func (pm *BaseProtocolManager) RemoveOpKey(keyInfo *KeyInfo, isLocked bool, isDeleteOplog bool, isDeleteDB bool) error
- func (pm *BaseProtocolManager) RemoveOpKeyFromHash(hash *common.Address, isLocked bool, isDeleteOplog bool, isDeleteDB bool) error
- func (pm *BaseProtocolManager) RenewOpKeySeconds() int64
- func (pm *BaseProtocolManager) RevokeOpKey(keyID *types.PttID) (bool, error)
- func (pm *BaseProtocolManager) SaveNewEntityWithOplog(oplog *BaseOplog, isLocked bool, isForce bool) error
- func (pm *BaseProtocolManager) SendDataToPeer(op OpType, data interface{}, peer *PttPeer) error
- func (pm *BaseProtocolManager) SendDataToPeerWithCode(code CodeType, op OpType, data interface{}, peer *PttPeer) error
- func (pm *BaseProtocolManager) SendDataToPeers(op OpType, data interface{}, peerList []*PttPeer) error
- func (pm *BaseProtocolManager) SetBlockInfoDB(blockInfo *BlockInfo, objID *types.PttID)
- func (pm *BaseProtocolManager) SetLog0DB(oplog *BaseOplog)
- func (pm *BaseProtocolManager) SetMasterDB(oplog *BaseOplog)
- func (pm *BaseProtocolManager) SetMasterLog0Hash(theBytes []byte) error
- func (pm *BaseProtocolManager) SetMasterObjDB(master *Master)
- func (pm *BaseProtocolManager) SetMasterOplogIsSync(oplog *MasterOplog, isBroadcast bool) (bool, error)
- func (pm *BaseProtocolManager) SetMediaDB(media *Media)
- func (pm *BaseProtocolManager) SetMemberDB(oplog *BaseOplog)
- func (pm *BaseProtocolManager) SetMemberObjDB(member *Member)
- func (pm *BaseProtocolManager) SetMemberOplogIsSync(oplog *MemberOplog, isBroadcast bool) (bool, error)
- func (pm *BaseProtocolManager) SetMemberSyncTime(ts types.Timestamp) error
- func (pm *BaseProtocolManager) SetNewestCreateMediaLog(oplog *BaseOplog) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestCreateObjectLog(oplog *BaseOplog, obj Object) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestDeleteEntityLog(oplog *BaseOplog) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestDeleteMediaLog(oplog *BaseOplog) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestDeleteObjectLog(oplog *BaseOplog, obj Object) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestDeletePersonLog(oplog *BaseOplog, person Object) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestEntityLog(oplog *BaseOplog) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestMasterLogID(id *types.PttID) error
- func (pm *BaseProtocolManager) SetNewestMasterOplog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) SetNewestMemberOplog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) SetNewestOpKeyOplog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) SetNewestPersonLog(oplog *BaseOplog, person Object) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestTransferPersonLog(oplog *BaseOplog, obj Object) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNewestUpdateObjectLog(oplog *BaseOplog, obj Object) (types.Bool, error)
- func (pm *BaseProtocolManager) SetNoMorePeers(noMorePeers chan struct{})
- func (pm *BaseProtocolManager) SetOpKeyDB(oplog *BaseOplog)
- func (pm *BaseProtocolManager) SetOpKeyObjDB(opKey *KeyInfo)
- func (pm *BaseProtocolManager) SetOpKeyOplogIsSync(oplog *OpKeyOplog, isBroadcast bool) (bool, error)
- func (pm *BaseProtocolManager) SetOplog0(oplog *BaseOplog)
- func (pm *BaseProtocolManager) SetOplogIDIsSync(logID *types.PttID) (*BaseOplog, error)
- func (pm *BaseProtocolManager) SetOplogIsSync(oplog *BaseOplog, isBroadcast bool, broadcastLog func(oplog *BaseOplog) error) (bool, error)
- func (pm *BaseProtocolManager) SetOwnerID(ownerID *types.PttID, isLocked bool)
- func (pm *BaseProtocolManager) SignOplog(oplog *BaseOplog) error
- func (pm *BaseProtocolManager) SplitContentBlocks(prefix []byte, objID *types.PttID, buf [][]byte, nFirstLineInBlock int) (*types.PttID, [][][]byte, error)
- func (pm *BaseProtocolManager) SplitMediaBlocks(objID *types.PttID, buf []byte) (*types.PttID, [][][]byte, error)
- func (pm *BaseProtocolManager) Start() error
- func (pm *BaseProtocolManager) Stop() error
- func (pm *BaseProtocolManager) Sync(peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncBlock(op OpType, syncBlockIDs []*SyncBlockID, peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncBlockAck(ackMsg OpType, blocks []*Block, peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncCreateOpKey(syncIDs []*SyncID, peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncMedia(op OpType, syncIDs []*SyncID, peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncObject(op OpType, syncIDs []*SyncID, peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncObjectAck(objs []Object, syncAckMsg OpType, peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncOpKeyOplog(peer *PttPeer, syncMsg OpType) error
- func (pm *BaseProtocolManager) SyncOplog(peer *PttPeer, merkle *Merkle, op OpType) error
- func (pm *BaseProtocolManager) SyncOplogAck(toSyncTime types.Timestamp, myToSyncTime types.Timestamp, merkle *Merkle, ...) error
- func (pm *BaseProtocolManager) SyncOplogInvalid(peer *PttPeer, theirSyncTS types.Timestamp, mySyncTS types.Timestamp, ...) error
- func (pm *BaseProtocolManager) SyncOplogInvalidByMerkle(myNewNodes []*MerkleNode, theirNewNodes []*MerkleNode, ...) error
- func (pm *BaseProtocolManager) SyncOplogNewOplogs(syncOplogAck *SyncOplogAck, myNewKeys [][]byte, theirNewKeys [][]byte, ...) error
- func (pm *BaseProtocolManager) SyncOplogNewOplogsAck(ts types.Timestamp, keys [][]byte, peer *PttPeer, setDB func(oplog *BaseOplog), ...) error
- func (pm *BaseProtocolManager) SyncPendingMasterOplog(peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncPendingMemberOplog(peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncPendingOpKeyOplog(peer *PttPeer) error
- func (pm *BaseProtocolManager) SyncPendingOplog(peer *PttPeer, setDB func(oplog *BaseOplog), ...) error
- func (pm *BaseProtocolManager) SyncPendingOplogAck(data *SyncPendingOplog, peer *PttPeer, syncAckMsg OpType, ...) error
- func (pm *BaseProtocolManager) SyncWG() *sync.WaitGroup
- func (pm *BaseProtocolManager) ToRenewOpKeyTS() (types.Timestamp, error)
- func (pm *BaseProtocolManager) TransferMaster(id *types.PttID) error
- func (pm *BaseProtocolManager) TransferPerson(fromID *types.PttID, toID *types.PttID, createOp OpType, origPerson Object, ...) error
- func (pm *BaseProtocolManager) TryCreateOpKeyInfo() error
- func (pm *BaseProtocolManager) UnregisterMaster(master *Master, isLocked bool) error
- func (pm *BaseProtocolManager) UnregisterMember(member *Member, isLock bool, isPostdeleteEntity bool) error
- func (pm *BaseProtocolManager) UnregisterPeer(peer *PttPeer, isForceReset bool, isForceNotReset bool, isPttLocked bool) error
- func (pm *BaseProtocolManager) UnregisterPeerByOtherUserID(id *types.PttID, isResetPeerType bool, isPttLocked bool) error
- func (pm *BaseProtocolManager) UpdateObject(id *types.PttID, data UpdateData, updateOp OpType, origObj Object, ...) error
- func (pm *BaseProtocolManager) UpdatePerson(id *types.PttID, addOp OpType, isForce bool, origPerson Object, opData OpData, ...) (Object, *BaseOplog, error)
- func (pm *BaseProtocolManager) ValidateIntegrateSign(oplog *BaseOplog, isLocked bool) error
- type BasePtt
- func (p *BasePtt) APIs() []rpc.API
- func (p *BasePtt) AddDial(nodeID *discover.NodeID, opKey *common.Address, peerType PeerType, ...) error
- func (p *BasePtt) AddJoinKey(hash *common.Address, entityID *types.PttID, isLocked bool) error
- func (p *BasePtt) AddNewPeer(peer *PttPeer) error
- func (p *BasePtt) AddOpKey(hash *common.Address, entityID *types.PttID, isLocked bool) error
- func (p *BasePtt) ApproveJoin(confirmKey []byte) error
- func (p *BasePtt) BEGetPeers() ([]*BackendPeer, error)
- func (p *BasePtt) BEGetPttOplogList(logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*PttOplog, error)
- func (p *BasePtt) CheckDialEntityAndIdentifyPeer(peer *PttPeer) error
- func (p *BasePtt) ClosePeers()
- func (p *BasePtt) CountEntities() (int, error)
- func (p *BasePtt) CountPeers() (*BackendCountPeers, error)
- func (p *BasePtt) DecryptData(ciphertext []byte, keyInfo *KeyInfo) (OpType, []byte, error)
- func (p *BasePtt) EncryptData(op OpType, data []byte, keyInfo *KeyInfo) ([]byte, error)
- func (p *BasePtt) EntityTerminal(entity Entity, pm ProtocolManager, peer *PttPeer) error
- func (p *BasePtt) ErrChan() *types.Chan
- func (p *BasePtt) FinishIdentifyPeer(peer *PttPeer, isLocked bool, isResetPeerType bool) error
- func (p *BasePtt) GenerateNodeInfo() func() interface{}
- func (p *BasePtt) GeneratePeerInfo() func(id discover.NodeID) interface{}
- func (p *BasePtt) GenerateProtocols() []p2p.Protocol
- func (p *BasePtt) GenerateRun(version uint) func(peer *p2p.Peer, rw p2p.MsgReadWriter) error
- func (p *BasePtt) GetConfirmJoins() ([]*BackendConfirmJoin, error)
- func (p *BasePtt) GetEntities() map[types.PttID]Entity
- func (p *BasePtt) GetGitCommit() (string, error)
- func (p *BasePtt) GetJoins() map[common.Address]*types.PttID
- func (p *BasePtt) GetLastAnnounceP2PTS() (types.Timestamp, error)
- func (p *BasePtt) GetMyEntity() MyEntity
- func (p *BasePtt) GetMyEntityFromMe(myID *types.PttID) Entity
- func (p *BasePtt) GetMyService() Service
- func (p *BasePtt) GetOps() map[common.Address]*types.PttID
- func (p *BasePtt) GetPeer(id *discover.NodeID, isLocked bool) *PttPeer
- func (p *BasePtt) GetPeerByUserID(id *types.PttID, isLocked bool) (*PttPeer, error)
- func (p *BasePtt) GetPttOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*PttOplog, error)
- func (p *BasePtt) GetPttOplogSeen() (types.Timestamp, error)
- func (p *BasePtt) GetVersion() (string, error)
- func (p *BasePtt) HandleApproveJoin(dataBytes []byte, hash *common.Address, joinRequest *JoinRequest, ...) error
- func (p *BasePtt) HandleCodeEntityDeleted(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeIdentifyPeer(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeIdentifyPeerFail(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeIdentifyPeerWithMyID(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeIdentifyPeerWithMyIDAck(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeIdentifyPeerWithMyIDChallenge(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeIdentifyPeerWithMyIDChallengeAck(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeJoin(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeJoinAck(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeOp(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeOpCheckMember(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeOpCheckMemberAck(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeOpFail(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeRequestOpKey(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeRequestOpKeyAck(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleCodeRequestOpKeyFail(hash *common.Address, encData []byte, peer *PttPeer) error
- func (p *BasePtt) HandleEntityTerminal(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleIdentifyPeerAck(entityID *types.PttID, data *IdentifyPeerAck, peer *PttPeer) error
- func (p *BasePtt) HandleIdentifyPeerFail(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleIdentifyPeerWithMyID(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleIdentifyPeerWithMyIDAck(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleIdentifyPeerWithMyIDChallenge(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleIdentifyPeerWithMyIDChallengeAck(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleJoin(dataBytes []byte, hash *common.Address, entity Entity, pm ProtocolManager, ...) error
- func (p *BasePtt) HandleJoinAckChallenge(dataBytes []byte, hash *common.Address, joinRequest *JoinRequest, ...) error
- func (p *BasePtt) HandleJoinEntity(dataBytes []byte, hash *common.Address, entity Entity, pm ProtocolManager, ...) error
- func (p *BasePtt) HandleMessage(code CodeType, data *PttData, peer *PttPeer) error
- func (p *BasePtt) HandleMessageWrapper(peer *PttPeer) error
- func (p *BasePtt) HandleOpCheckMember(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleOpCheckMemberAck(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleOpFail(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandlePeer(peer *PttPeer) error
- func (p *BasePtt) HandleRequestOpKey(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleRequestOpKeyAck(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) HandleRequestOpKeyFail(dataBytes []byte, peer *PttPeer) error
- func (p *BasePtt) IdentifyPeer(entityID *types.PttID, quitSync chan struct{}, peer *PttPeer, isForce bool) (*IdentifyPeer, error)
- func (p *BasePtt) IdentifyPeerAck(challenge *types.Salt, peer *PttPeer) (*IdentifyPeerAck, error)
- func (p *BasePtt) IdentifyPeerFail(hash *common.Address, peer *PttPeer) error
- func (p *BasePtt) IdentifyPeerWithMyID(peer *PttPeer) error
- func (p *BasePtt) IdentifyPeerWithMyIDAck(challenge *types.Salt, peer *PttPeer) error
- func (p *BasePtt) IdentifyPeerWithMyIDChallenge(userID *types.PttID, peer *PttPeer) error
- func (p *BasePtt) IdentifyPeerWithMyIDChallengeAck(data *IdentifyPeer, peer *PttPeer) error
- func (p *BasePtt) IsHubPeer(peer *PttPeer) bool
- func (p *BasePtt) JoinAckChallenge(keyInfo *KeyInfo, join *Join, peer *PttPeer, entity Entity) error
- func (p *BasePtt) JoinEntity(joinRequest *JoinRequest, joinAckChallenge *JoinAckChallenge, peer *PttPeer) error
- func (p *BasePtt) LockJoins()
- func (p *BasePtt) LockOps()
- func (p *BasePtt) MarkPttOplogSeen() (types.Timestamp, error)
- func (p *BasePtt) MarshalData(code CodeType, hash *common.Address, encData []byte) (*PttData, error)
- func (p *BasePtt) MarshalDataWithoutHash(code CodeType, encData []byte) (*PttData, error)
- func (p *BasePtt) MyNodeID() *discover.NodeID
- func (p *BasePtt) MyNodeKey() *ecdsa.PrivateKey
- func (p *BasePtt) MyNodeType() NodeType
- func (p *BasePtt) MyRaftID() uint64
- func (p *BasePtt) NewPeer(version uint, peer *p2p.Peer, rw p2p.MsgReadWriter) (*PttPeer, error)
- func (p *BasePtt) NoMorePeers() chan struct{}
- func (p *BasePtt) NodeInfo() interface{}
- func (p *BasePtt) NotifyNodeRestart() *types.Chan
- func (p *BasePtt) NotifyNodeStop() *types.Chan
- func (p *BasePtt) OpCheckMember(entityID *types.PttID, peer *PttPeer) error
- func (p *BasePtt) OpCheckMemberAck(entityID *types.PttID, memberLog *BaseOplog, peer *PttPeer) error
- func (p *BasePtt) OpFail(hash *common.Address, peer *PttPeer) error
- func (p *BasePtt) Prestart() error
- func (p *BasePtt) Protocols() []p2p.Protocol
- func (p *BasePtt) PttAPIs() []rpc.API
- func (p *BasePtt) RWInit(peer *PttPeer, version uint)
- func (p *BasePtt) RegisterEntity(e Entity, isLocked bool, isPeerLocked bool) error
- func (p *BasePtt) RegisterEntityPeerWithOtherUserID(e Entity, id *types.PttID, peerType PeerType, isLocked bool) error
- func (p *BasePtt) RegisterPeerToEntities(peer *PttPeer) error
- func (p *BasePtt) RegisterService(service Service) error
- func (p *BasePtt) RemoveJoinKey(hash *common.Address, entityID *types.PttID, isLocked bool) error
- func (p *BasePtt) RemoveOpHash(hash *common.Address) error
- func (p *BasePtt) RemoveOpKey(hash *common.Address, entityID *types.PttID, isLocked bool) error
- func (p *BasePtt) RemovePeer(peer *PttPeer, isLocked bool) error
- func (p *BasePtt) RequestOpKey(hash *common.Address, peer *PttPeer) error
- func (p *BasePtt) RequestOpKeyAck(entityID *types.PttID, peer *PttPeer) error
- func (p *BasePtt) RequestOpKeyByEntity(entity Entity, peer *PttPeer) error
- func (p *BasePtt) RequestOpKeyFail(entityID *types.PttID, peer *PttPeer) error
- func (p *BasePtt) ResetPeerType(peer *PttPeer, isLocked bool, isForceReset bool) error
- func (p *BasePtt) Restart() (bool, error)
- func (p *BasePtt) SendDataToPeer(code CodeType, data interface{}, peer *PttPeer) error
- func (p *BasePtt) Server() *p2p.Server
- func (p *BasePtt) SetMyEntity(myEntity PttMyEntity) error
- func (p *BasePtt) SetPeerType(peer *PttPeer, peerType PeerType, isForce bool, isLocked bool) error
- func (p *BasePtt) SetupPeer(peer *PttPeer, peerType PeerType, isLocked bool) error
- func (p *BasePtt) Shutdown() (bool, error)
- func (p *BasePtt) Start(server *p2p.Server) error
- func (p *BasePtt) Stop() error
- func (p *BasePtt) SyncWG() *sync.WaitGroup
- func (p *BasePtt) ToConfirmJoin(confirmKey []byte, entity Entity, joinEntity *JoinEntity, keyInfo *KeyInfo, ...) error
- func (p *BasePtt) TryJoin(challenge []byte, hash *common.Address, key *ecdsa.PrivateKey, ...) error
- func (p *BasePtt) UnlockJoins()
- func (p *BasePtt) UnlockOps()
- func (p *BasePtt) UnmarshalData(pttData *PttData) (CodeType, *common.Address, []byte, error)
- func (p *BasePtt) UnregisterEntity(e Entity, isLocked bool) error
- func (p *BasePtt) UnregisterPeerFromEntities(peer *PttPeer) error
- func (p *BasePtt) UnsetPeerType(peer *PttPeer, isLocked bool) error
- func (p *BasePtt) ValidatePeer(nodeID *discover.NodeID, userID *types.PttID, peerType PeerType, isLocked bool) error
- type BaseService
- func (svc *BaseService) APIs() []rpc.API
- func (svc *BaseService) CountPeers(entityIDBytes []byte) (int, error)
- func (svc *BaseService) EntityIDToEntity(entityIDBytes []byte) (Entity, error)
- func (svc *BaseService) EntityIDToPM(entityIDBytes []byte) (ProtocolManager, error)
- func (b *BaseService) ForceOpKey(entityIDBytes []byte) (bool, error)
- func (b *BaseService) ForceSync(entityIDBytes []byte) (bool, error)
- func (svc *BaseService) ForceSyncMasterMerkle(entityIDBytes []byte) (bool, error)
- func (svc *BaseService) ForceSyncMemberMerkle(entityIDBytes []byte) (bool, error)
- func (svc *BaseService) GetMasterList(entityIDBytes []byte, startIDBytes []byte, limit int, ...) ([]*Master, error)
- func (svc *BaseService) GetMasterListFromCache(entityIDBytes []byte) ([]*Master, error)
- func (svc *BaseService) GetMasterOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error)
- func (svc *BaseService) GetMasterOplogMerkleNodeList(entityIDBytes []byte, level MerkleTreeLevel, startKey []byte, limit int, ...) ([]*BackendMerkleNode, error)
- func (svc *BaseService) GetMemberList(entityIDBytes []byte, startIDBytes []byte, limit int, ...) ([]*Member, error)
- func (svc *BaseService) GetMemberOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error)
- func (svc *BaseService) GetMemberOplogMerkleNodeList(entityIDBytes []byte, level MerkleTreeLevel, startKey []byte, limit int, ...) ([]*BackendMerkleNode, error)
- func (b *BaseService) GetMyMemberLog(entityIDBytes []byte) (*BaseOplog, error)
- func (svc *BaseService) GetOpKeyOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error)
- func (svc *BaseService) GetOpKeys(entityIDBytes []byte) ([]*KeyInfo, error)
- func (svc *BaseService) GetOpKeysFromDB(entityIDBytes []byte) ([]*KeyInfo, error)
- func (svc *BaseService) GetPeers(entityIDBytes []byte) ([]*BackendPeer, error)
- func (svc *BaseService) GetPendingMasterOplogInternalList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error)
- func (svc *BaseService) GetPendingMasterOplogMasterList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error)
- func (svc *BaseService) GetPendingMemberOplogInternalList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error)
- func (svc *BaseService) GetPendingMemberOplogMasterList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error)
- func (svc *BaseService) GetPendingOpKeyOplogInternalList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error)
- func (svc *BaseService) GetPendingOpKeyOplogMasterList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error)
- func (b *BaseService) LeaveEntity(entityIDBytes []byte) (bool, error)
- func (svc *BaseService) Prestart() error
- func (svc *BaseService) Ptt() Ptt
- func (svc *BaseService) RevokeOpKey(entityIDBytes []byte, keyIDBytes []byte, myKey []byte) (bool, error)
- func (svc *BaseService) SPM() ServiceProtocolManager
- func (svc *BaseService) ShowValidateKey() (*types.PttID, error)
- func (svc *BaseService) Start() error
- func (svc *BaseService) Stop() error
- func (svc *BaseService) ValidateValidateKey(keyBytes []byte) (bool, error)
- type BaseServiceProtocolManager
- func (spm *BaseServiceProtocolManager) CreateEntity(data CreateData, createOp OpType, ...) (Entity, error)
- func (spm *BaseServiceProtocolManager) CreateJoinEntity(approveJoin *ApproveJoinEntity, peer *PttPeer, meLog *BaseOplog, isStart bool, ...) (Entity, error)
- func (spm *BaseServiceProtocolManager) DBObjLock() *types.LockMap
- func (spm *BaseServiceProtocolManager) Entities() map[types.PttID]Entity
- func (spm *BaseServiceProtocolManager) Entity(id *types.PttID) Entity
- func (spm *BaseServiceProtocolManager) GetDBLock() *types.LockMap
- func (spm *BaseServiceProtocolManager) GetDBLogLock() *types.LockMap
- func (spm *BaseServiceProtocolManager) Lock(id *types.PttID) error
- func (spm *BaseServiceProtocolManager) NewEmptyEntity() Entity
- func (spm *BaseServiceProtocolManager) Prestart() error
- func (b *BaseServiceProtocolManager) PrestartEntities() error
- func (spm *BaseServiceProtocolManager) Ptt() Ptt
- func (spm *BaseServiceProtocolManager) RLock(id *types.PttID) error
- func (spm *BaseServiceProtocolManager) RUnlock(id *types.PttID) error
- func (spm *BaseServiceProtocolManager) RegisterEntity(id *types.PttID, e Entity) error
- func (spm *BaseServiceProtocolManager) Service() Service
- func (spm *BaseServiceProtocolManager) Start() error
- func (b *BaseServiceProtocolManager) StartEntities() error
- func (spm *BaseServiceProtocolManager) Stop() error
- func (b *BaseServiceProtocolManager) StopEntities() error
- func (spm *BaseServiceProtocolManager) Unlock(id *types.PttID) error
- func (spm *BaseServiceProtocolManager) UnregisterEntity(id *types.PttID) error
- type BaseSyncInfo
- func (s *BaseSyncInfo) CheckIsAllGood() types.Bool
- func (s *BaseSyncInfo) FromOplog(status types.Status, oplog *BaseOplog, opData OpData) error
- func (s *BaseSyncInfo) GetBlockInfo() *BlockInfo
- func (s *BaseSyncInfo) GetIsAllGood() types.Bool
- func (s *BaseSyncInfo) GetIsGood() types.Bool
- func (s *BaseSyncInfo) GetLogID() *types.PttID
- func (s *BaseSyncInfo) GetStatus() types.Status
- func (s *BaseSyncInfo) GetUpdateTS() types.Timestamp
- func (s *BaseSyncInfo) GetUpdaterID() *types.PttID
- func (s *BaseSyncInfo) InitWithOplog(status types.Status, oplog *BaseOplog)
- func (s *BaseSyncInfo) SetBlockInfo(blockInfo *BlockInfo) error
- func (s *BaseSyncInfo) SetIsAllGood(isAllGood types.Bool)
- func (s *BaseSyncInfo) SetIsGood(isGood types.Bool)
- func (s *BaseSyncInfo) SetLogID(id *types.PttID)
- func (s *BaseSyncInfo) SetStatus(status types.Status)
- func (s *BaseSyncInfo) SetUpdateTS(ts types.Timestamp)
- func (s *BaseSyncInfo) SetUpdaterID(id *types.PttID)
- func (s *BaseSyncInfo) ToObject(obj Object) error
- type Block
- func (b *Block) GetIter(listOrder pttdb.ListOrder, isLocked bool) (iterator.Iterator, error)
- func (b *Block) Marshal() ([]byte, error)
- func (b *Block) MarshalKey() ([]byte, error)
- func (b *Block) Prefix() ([]byte, error)
- func (b *Block) RemoveAll() error
- func (b *Block) Save() error
- func (b *Block) SetDB(db *pttdb.LDBBatch, fullDBPrefix []byte, objID *types.PttID, id *types.PttID)
- func (b *Block) Sign(key *KeyInfo) error
- func (b *Block) Unmarshal(theBytes []byte) error
- func (b *Block) Verify(expectedHash []byte, creatorID *types.PttID) error
- type BlockInfo
- func (b *BlockInfo) GetBlockIterWithBlockInfo(isLocked bool) (iterator.Iterator, error)
- func (b *BlockInfo) GetIsAllGood() bool
- func (b *BlockInfo) GetIsGood(blockID uint32, subBlockID uint8) types.Bool
- func (b *BlockInfo) Init(nBlock int)
- func (b *BlockInfo) InitIsGood()
- func (b *BlockInfo) Remove(isLocked bool) error
- func (b *BlockInfo) ResetIsGood()
- func (b *BlockInfo) SaveBlocks(isLocked bool, blocks []*Block) error
- func (b *BlockInfo) SetBlockDB(block *Block)
- func (b *BlockInfo) SetDB(db *pttdb.LDBBatch, dbLock *types.LockMap, fullDBPrefix []byte, ...)
- func (b *BlockInfo) SetIsAllGood()
- func (b *BlockInfo) SetIsGood(blockID uint32, subBlockID uint8, isGood types.Bool)
- func (b *BlockInfo) VerifyBlock(block *Block) bool
- func (b *BlockInfo) VerifyBlocks(blocks []*Block) ([]*Block, []*Block)
- type CodeType
- type CommentType
- type Config
- type ConfirmJoin
- type ContentBlock
- type ContentType
- type Count
- func (c *Count) Add(item []byte)
- func (c *Count) AddWithIsNew(item []byte) bool
- func (c *Count) Count() uint64
- func (c *Count) Delete() error
- func (c *Count) Intersect(c2 *Count) (*Count, error)
- func (c *Count) Load() error
- func (c *Count) MarshalKey() ([]byte, error)
- func (c *Count) NewBits()
- func (c *Count) Save() error
- func (c *Count) SetBits(bits types.BitVector)
- func (c *Count) SetDB(db *pttdb.LDBBatch, dbPrefixID *types.PttID, dbID *types.PttID, ...)
- func (c *Count) SetHash()
- func (c *Count) Union(c2 *Count) (*Count, error)
- type CreateData
- type DialHistory
- type DialHistoryHeap
- type DialInfo
- type Entity
- type EntityDeleted
- type EntityType
- type ForceSyncID
- type ForceSyncObject
- type ForceSyncOplog
- type ForceSyncOplogByMerkle
- type ForceSyncOplogByMerkleAck
- type ForceSyncOplogByOplogAck
- type IdentifyPeer
- type IdentifyPeerAck
- type IdentifyPeerFail
- type IdentifyPeerWithMyID
- type IdentifyPeerWithMyIDChallengeAck
- type Join
- type JoinAckChallenge
- type JoinEntity
- type JoinRequest
- type JoinRequestEvent
- type JoinStatus
- type JoinType
- type KeyBIP32
- type KeyExtraInfo
- type KeyInfo
- func NewEmptyOpKey() *KeyInfo
- func NewJoinKeyInfo(entityID *types.PttID) (*KeyInfo, error)
- func NewOpKeyInfo(entityID *types.PttID, doerID *types.PttID, masterKey *ecdsa.PrivateKey) (*KeyInfo, error)
- func NewSignKeyInfo(doerID *types.PttID, masterKey *ecdsa.PrivateKey) (*KeyInfo, error)
- func ObjsToOpKeys(objs []Object) []*KeyInfo
- func (k *KeyInfo) GetByID(isLocked bool) error
- func (k *KeyInfo) GetNewObjByID(id *types.PttID, isLocked bool) (Object, error)
- func (k *KeyInfo) GetSyncInfo() SyncInfo
- func (k *KeyInfo) GetUpdateTS() types.Timestamp
- func (k *KeyInfo) Init(pm ProtocolManager) error
- func (k *KeyInfo) Marshal() ([]byte, error)
- func (k *KeyInfo) MarshalKey() ([]byte, error)
- func (k *KeyInfo) NewEmptyObj() Object
- func (k *KeyInfo) RemoveMeta()
- func (k *KeyInfo) Save(isLocked bool) error
- func (k *KeyInfo) SetSyncInfo(theSyncInfo SyncInfo) error
- func (k *KeyInfo) SetUpdateTS(ts types.Timestamp)
- func (k *KeyInfo) Unmarshal(data []byte) error
- type KeyType
- type LRUCount
- type Locale
- type Master
- func (m *Master) GetByID(isLocked bool) error
- func (m *Master) GetNewObjByID(id *types.PttID, isLocked bool) (Object, error)
- func (m *Master) GetSyncInfo() SyncInfo
- func (m *Master) GetUpdateTS() types.Timestamp
- func (m *Master) Marshal() ([]byte, error)
- func (m *Master) MarshalKey() ([]byte, error)
- func (m *Master) NewEmptyObj() Object
- func (m *Master) Save(isLocked bool) error
- func (m *Master) SetSyncInfo(theSyncInfo SyncInfo) error
- func (m *Master) SetUpdateTS(ts types.Timestamp)
- func (m *Master) Unmarshal(data []byte) error
- type MasterOpCreateMaster
- type MasterOplog
- type Media
- func (m *Media) DeleteAll(isLocked bool) error
- func (m *Media) GetBuf() error
- func (m *Media) GetByID(isLocked bool) error
- func (m *Media) GetNewObjByID(id *types.PttID, isLocked bool) (Object, error)
- func (m *Media) GetSyncInfo() SyncInfo
- func (m *Media) GetUpdateTS() types.Timestamp
- func (m *Media) Marshal() ([]byte, error)
- func (m *Media) MarshalKey() ([]byte, error)
- func (m *Media) NewEmptyObj() Object
- func (m *Media) Save(isLocked bool) error
- func (m *Media) SetBlockDB(block *Block)
- func (m *Media) SetSyncInfo(theSyncInfo SyncInfo) error
- func (m *Media) SetUpdateTS(ts types.Timestamp)
- func (m *Media) Unmarshal(data []byte) error
- type MediaData
- type MediaDataFile
- type MediaDataGIF
- type MediaDataJPEG
- type MediaDataPNG
- type MediaType
- type Member
- func (m *Member) GetByID(isLocked bool) error
- func (m *Member) GetNewObjByID(id *types.PttID, isLocked bool) (Object, error)
- func (m *Member) GetSyncInfo() SyncInfo
- func (m *Member) GetUpdateTS() types.Timestamp
- func (m *Member) Marshal() ([]byte, error)
- func (m *Member) MarshalKey() ([]byte, error)
- func (m *Member) NewEmptyObj() Object
- func (m *Member) Save(isLocked bool) error
- func (m *Member) SetSyncInfo(theSyncInfo SyncInfo) error
- func (m *Member) SetUpdateTS(ts types.Timestamp)
- func (m *Member) Unmarshal(data []byte) error
- type MemberOpAddMember
- type MemberOpDeleteMember
- type MemberOplog
- type Merkle
- func (m *Merkle) Clean()
- func (m *Merkle) DBPrefix() []byte
- func (m *Merkle) ForceSaveSyncTime(ts types.Timestamp) error
- func (m *Merkle) ForceSync() chan struct{}
- func (m *Merkle) GetAndResetToUpdateTSList() ([]int64, error)
- func (m *Merkle) GetChildKeys(level MerkleTreeLevel, ts types.Timestamp) ([][]byte, error)
- func (m *Merkle) GetChildNodes(level MerkleTreeLevel, ts types.Timestamp) ([]*MerkleNode, error)
- func (m *Merkle) GetFailSyncTime() (types.Timestamp, error)
- func (m *Merkle) GetGenerateTime() (types.Timestamp, error)
- func (m *Merkle) GetMerkleIter(level MerkleTreeLevel, ts types.Timestamp, nextTS types.Timestamp, ...) (iterator.Iterator, error)
- func (m *Merkle) GetMerkleIterByKey(startKey []byte, level MerkleTreeLevel, listOrder pttdb.ListOrder) (iterator.Iterator, error)
- func (m *Merkle) GetMerkleTreeList(ts types.Timestamp, isNow bool) ([]*MerkleNode, []*MerkleNode, error)
- func (m *Merkle) GetMerkleTreeListByLevel(level MerkleTreeLevel, ts types.Timestamp, nextTS types.Timestamp) ([]*MerkleNode, error)
- func (m *Merkle) GetMerkleTreeListCore(level MerkleTreeLevel, ts types.Timestamp, nextTS types.Timestamp) ([]*MerkleNode, error)
- func (m *Merkle) GetNodeByKey(key []byte) (*MerkleNode, error)
- func (m *Merkle) GetNodeByLevelTS(level MerkleTreeLevel, ts types.Timestamp) (*MerkleNode, error)
- func (m *Merkle) GetSyncTime() (types.Timestamp, error)
- func (m *Merkle) LoadToUpdateTSs() error
- func (m *Merkle) LoadUpdatingTSList() ([]int64, error)
- func (m *Merkle) MarshalFailSyncTimeKey() ([]byte, error)
- func (m *Merkle) MarshalGenerateTimeKey() ([]byte, error)
- func (m *Merkle) MarshalKey(level MerkleTreeLevel, ts types.Timestamp) ([]byte, error)
- func (m *Merkle) MarshalSyncTimeKey() ([]byte, error)
- func (m *Merkle) MarshalToUpdateTSKey(ts types.Timestamp) []byte
- func (m *Merkle) MarshalUpdatingKey() []byte
- func (m *Merkle) ResetUpdateTS() error
- func (m *Merkle) ResetUpdatingTSList() error
- func (m *Merkle) SaveFailSyncTime(ts types.Timestamp) error
- func (m *Merkle) SaveGenerateTime(ts types.Timestamp) error
- func (m *Merkle) SaveMerkleTree(ts types.Timestamp) error
- func (m *Merkle) SaveMerkleTreeCore(level MerkleTreeLevel, offsetTS types.Timestamp, nextTS types.Timestamp, ...) (types.Timestamp, error)
- func (m *Merkle) SaveSyncTime(ts types.Timestamp) error
- func (m *Merkle) SetUpdateTS(ts types.Timestamp) error
- func (m *Merkle) SetUpdateTS2(ts types.Timestamp, ts2 types.Timestamp) error
- func (m *Merkle) ToGenerateTime() types.Timestamp
- func (m *Merkle) ToSyncTime() (types.Timestamp, error)
- func (m *Merkle) TryForceSync(pm ProtocolManager) error
- type MerkleNode
- func (m *MerkleNode) ConstructUpdateTSAndLevelByKey(key []byte) error
- func (m *MerkleNode) Marshal() ([]byte, error)
- func (m *MerkleNode) MarshalJSON() ([]byte, error)
- func (m *MerkleNode) ToKey(merkle *Merkle) []byte
- func (m *MerkleNode) Unmarshal(b []byte) error
- func (m *MerkleNode) UnmarshalJSON(b []byte) error
- func (m *MerkleNode) UpdateTSToTS() types.Timestamp
- type MerkleTreeLevel
- type MeteredMsgReadWriter
- type MyEntity
- type MyProtocolManager
- type MyPtt
- type MyService
- type NodeType
- type Object
- func AliveObjects(theObjs []Object) []Object
- func GetObjList(obj Object, startID *types.PttID, limit int, listOrder pttdb.ListOrder, ...) ([]Object, error)
- func MastersToObjs(typedObjs []*Master) []Object
- func MediasToObjs(typedObjs []*Media) []Object
- func MembersToObjs(typedObjs []*Member) []Object
- func OpKeysToObjs(typedObjs []*KeyInfo) []Object
- type OpCheckMember
- type OpCheckMemberAck
- type OpClass
- type OpCreateMedia
- type OpData
- type OpDeleteMedia
- type OpFail
- type OpKeyFail
- type OpKeyOpCreateOpKey
- type OpKeyOpRevokeOpKey
- type OpKeyOplog
- type OpType
- type Oplog
- type PeerType
- type PersonOpTransferPerson
- type PrivateAPI
- func (api *PrivateAPI) CountEntities() (int, error)
- func (api *PrivateAPI) CountPeers() (*BackendCountPeers, error)
- func (api *PrivateAPI) GetConfirmJoins() ([]*BackendConfirmJoin, error)
- func (api *PrivateAPI) GetGitCommit() (string, error)
- func (api *PrivateAPI) GetJoins() (map[common.Address]*types.PttID, error)
- func (api *PrivateAPI) GetLastAnnounceP2PTS() (types.Timestamp, error)
- func (api *PrivateAPI) GetLocale() (Locale, error)
- func (api *PrivateAPI) GetOffsetSecond() (int64, error)
- func (api *PrivateAPI) GetOps() (map[common.Address]*types.PttID, error)
- func (api *PrivateAPI) GetPeers() ([]*BackendPeer, error)
- func (api *PrivateAPI) GetPttOplogList(logID string, limit int, listOrder pttdb.ListOrder) ([]*PttOplog, error)
- func (api *PrivateAPI) GetPttOplogSeen() (types.Timestamp, error)
- func (api *PrivateAPI) GetTimestamp() (types.Timestamp, error)
- func (api *PrivateAPI) GetVersion() (string, error)
- func (api *PrivateAPI) MarkPttOplogSeen() (types.Timestamp, error)
- func (api *PrivateAPI) Restart() (bool, error)
- func (api *PrivateAPI) SetLocale(locale Locale) (Locale, error)
- func (api *PrivateAPI) SetOffsetSecond(sec int64) (bool, error)
- func (api *PrivateAPI) Shutdown() (bool, error)
- type ProcessInfo
- type ProcessOpKeyInfo
- type ProcessPersonInfo
- type ProtocolManager
- type Ptt
- type PttData
- type PttEventData
- type PttMyEntity
- type PttNodeInfo
- type PttOpCreateArticle
- type PttOpCreateComment
- type PttOpCreateFriend
- type PttOpCreateMe
- type PttOpCreateReply
- type PttOpJoinBoard
- type PttOplog
- type PttPeer
- func (p *PttPeer) Broadcast() error
- func (p *PttPeer) FinishID(entityID *types.PttID)
- func (p *PttPeer) GetID() *discover.NodeID
- func (p *PttPeer) GetPeer() *p2p.Peer
- func (p *PttPeer) Handshake(networkID uint32) error
- func (p *PttPeer) Info() interface{}
- func (p *PttPeer) InitID(entityID *types.PttID, quitSync chan struct{}, isForce bool) (*types.Salt, error)
- func (p *PttPeer) RW() p2p.MsgReadWriter
- func (p *PttPeer) ReadStatus(networkID uint32) error
- func (p *PttPeer) ResetInitID()
- func (p *PttPeer) SendData(data *PttData) error
- func (p *PttPeer) String() string
- func (p *PttPeer) Version() uint
- type PttPeerInfo
- type PttPeerSet
- func (ps *PttPeerSet) Close(isLocked bool)
- func (ps *PttPeerSet) GetPeerWithPeerType(id *discover.NodeID, peerType PeerType, isLocked bool) *PttPeer
- func (ps *PttPeerSet) GetPendingPeerByUserID(id *types.PttID, isLocked bool) (*PttPeer, error)
- func (ps *PttPeerSet) ImportantPeerList(isLocked bool) []*PttPeer
- func (ps *PttPeerSet) ImportantPeers() map[discover.NodeID]*PttPeer
- func (ps *PttPeerSet) IsClosed() bool
- func (ps *PttPeerSet) IsPendingPeer(peer *PttPeer, isLocked bool) bool
- func (ps *PttPeerSet) Len(isLocked bool) int
- func (ps *PttPeerSet) Lock()
- func (ps *PttPeerSet) MePeerList(isLocked bool) []*PttPeer
- func (ps *PttPeerSet) MePeers(isLocked bool) map[discover.NodeID]*PttPeer
- func (ps *PttPeerSet) MemberPeerList(isLocked bool) []*PttPeer
- func (ps *PttPeerSet) MemberPeers() map[discover.NodeID]*PttPeer
- func (ps *PttPeerSet) Peer(id *discover.NodeID, isLocked bool) *PttPeer
- func (ps *PttPeerSet) PeerList(isLocked bool) []*PttPeer
- func (ps *PttPeerSet) PeersToPeerList(peers map[discover.NodeID]*PttPeer, isLocked bool) []*PttPeer
- func (ps *PttPeerSet) PendingPeerList(isLocked bool) []*PttPeer
- func (ps *PttPeerSet) RLock()
- func (ps *PttPeerSet) RUnlock()
- func (ps *PttPeerSet) Register(peer *PttPeer, peerType PeerType, isLocked bool) error
- func (ps *PttPeerSet) Unlock()
- func (ps *PttPeerSet) Unregister(peer *PttPeer, isLocked bool) error
- func (ps *PttPeerSet) UnregisterPeerByOtherUserID(id *types.PttID, isLocked bool) (*PttPeer, PeerType, error)
- type PttProtocolManager
- type PttService
- type PttStatus
- type RequestOpKey
- type RequestOpKeyAck
- type SendDataToPeerWithCodeEvent
- type SendDataToPeersEvent
- type Service
- type ServiceConstructor
- type ServiceContext
- type ServiceProtocolManager
- type SignInfo
- type SyncBlock
- type SyncBlockAck
- type SyncBlockID
- type SyncCreateOpKeyAck
- type SyncID
- type SyncInfo
- type SyncMasterOplog
- type SyncMediaAck
- type SyncMemberOplog
- type SyncObject
- type SyncObjectAck
- type SyncOpKeyOplog
- type SyncOplog
- type SyncOplogAck
- type SyncOplogAckInvalid
- type SyncOplogNewOplogs
- type SyncOplogNewOplogsAck
- type SyncPendingOplog
- type SyncPendingOplogAck
- type SyncPersonInfo
- type UpdateData
Constants ¶
const ( PathJoinMe = "/joinme" PathJoinFriend = "/joinfriend" PathJoinBoard = "/joinboard" )
const ( ProtocolMaxMsgSize = 20 * 1024 * 1024 // 20MB for video-streaming SizeOpType = 4 // optype uint32 SizeCodeType = 8 // codetype uint64 SizeChallenge = 16 HandshakeTimeout = 60 * time.Second IdentifyPeerTimeout = 10 * time.Second )
ptt-layer
const ( IntRenewJoinKeySeconds = 86400 // 1 day for now RenewJoinKeySeconds = time.Duration(IntRenewJoinKeySeconds) * time.Second )
join
const ( MaxIterDeriveKeyBIP32 = 10 SleepTimeOpKeyLock = 10 )
op-key
const ( MaxSyncObjectAck = 50 MaxSyncBlock = 50 )
object
const ( NSubBlock = 2 NLineInBlock = 20 NScrambleInBlock = 2 )
const ( NByteInBlock = 65535 MaxUploadMediaSize = 10485760 // 10MB MaxUploadImageWidth = 8192 MaxUploadImageHeight = 8192 )
media
const ( SleepTimePttLock = 10 SleepTimeLock = 10 MaxCountPttOplog = 2000 PPttOplog = 12 // 2^12 = 4096 )
db
const (
MaxSyncOplogAck = 200
)
oplog
const (
Ptt4 uint
)
protocol
Variables ¶
var ( ErrAlreadyPrestarted = errors.New("already prestarted") ErrAlreadyStarted = errors.New("already started") ErrToClose = errors.New("peer is to close") ErrClosed = errors.New("peer set is closed") ErrAlreadyRegistered = errors.New("peer is already registered") ErrNotRegistered = errors.New("peer is not registered") ErrPeerUserID = errors.New("peer user id") ErrEntityAlreadyRegistered = errors.New("entity is already registered") ErrEntityNotRegistered = errors.New("entity is not registered") ErrInit = errors.New("failed init") ErrQuota = errors.New("size exceeds quota") ErrNegativeSize = errors.New("size < 0") ErrInvalidKey = errors.New("invalid key") ErrMsgTooLarge = errors.New("msg too large") ErrFileTooLarge = errors.New("file too large") ErrInvalidMaster0 = errors.New("invalid master0") ErrServiceUnknown = errors.New("service unknown") ErrInvalidMsgCode = errors.New("invalid msg code") ErrInvalidMsg = errors.New("invalid msg") ErrNotSent = errors.New("not sent") ErrInvalidData = errors.New("invalid data") ErrInvalidObject = errors.New("invalid object") ErrTimeout = errors.New("timeout") ErrInvalidEntity = errors.New("invalid entity") ErrInvalidOp = errors.New("invalid op") ErrInvalidOplog = errors.New("invalid oplog") ErrOplogAlreadyExists = errors.New("oplog already exists") ErrSkipOplog = errors.New("skip oplog") ErrNewerOplog = errors.New("newer oplog") ErrInvalidPreLog = errors.New("invalid pre-log") ErrNoValidOplogs = errors.New("no valid oplogs") ErrInvalidKeyInfo = errors.New("invalid key info") ErrNotFound = errors.New("not found") ErrNoPeer = errors.New("no peer") ErrInvalidStatus = errors.New("invalid status") ErrBusy = errors.New("busy") ErrPeerRecentAdded = errors.New("peer recent added") ErrAlreadyMyNode = errors.New("already my node") ErrInvalidSyncInfo = errors.New("invalid sync info") ErrTooManyMasters = errors.New("too many masters") ErrInvalidBlock = errors.New("invalid block") ErrAlreadyPending = errors.New("already pending") ErrNotAlive = errors.New("not alive") ErrInvalidFunc = errors.New("invalid function") ErrInvalidMerkle = errors.New("invalid merkle") )
var ( ProtocolVersions = [1]uint{Ptt4} ProtocolName = "ptt4" ProtocolLengths = [1]uint64{uint64(NCodeType)} )
var ( DBMasterPrefix = []byte(".MAdb") DBMasterIdxPrefix = []byte(".MAix") DBMasterOplogPrefix = []byte(".MAlg") DBMasterIdxOplogPrefix = []byte(".MAig") DBMasterMerkleOplogPrefix = []byte(".MAmk") )
member
var ( DBMemberPrefix = []byte(".mbdb") DBMemberIdxPrefix = []byte(".mbix") DBMemberOplogPrefix = []byte(".mblg") DBMemberIdxOplogPrefix = []byte(".mbig") DBMemberMerkleOplogPrefix = []byte(".mbmk") )
member
var ( DBOpKeyPrefix = []byte(".okdb") DBOpKeyIdxPrefix = []byte(".okix") DBOpKeyIdx2Prefix = []byte(".oki2") DBOpKeyOplogPrefix = []byte(".oklg") DBOpKeyIdxOplogPrefix = []byte(".okig") )
var ( DBBlockInfoPrefix = []byte(".bidb") DBBlockInfoIdxPrefix = []byte(".biix") DBContentBlockPrefix = []byte(".bkdb") )
var ( DBMediaPrefix = []byte(".mddb") DBMediaIdxPrefix = []byte(".mdix") )
var ( DBNewestMasterLogIDPrefix = []byte(".nmld") DBMasterLog0HashPrefix = []byte(".ml0h") DBCountPttOplogPrefix = []byte(".ptct") DBPttOplogPrefix = []byte(".ptlg") // .ptlm, .ptli is used as well DBPttIdxOplogPrefix = []byte(".ptig") DBPttLockMap *types.LockMap DBLocalePrefix = []byte(".locl") DBPttLogSeenPrefix = []byte(".ptsn") )
var ( SizeMerkleTreeLevel = 1 // uint8 SizeMerkleTreeNChildren = 4 // uint32 NMerkleTreeMagicAlloc = 50 MerkleTreeOffsetAddr = SizeMerkleTreeLevel MerkleTreeOffsetTS = MerkleTreeOffsetAddr + common.AddressLength MerkleTreeKeyOffsetLevel = pttdb.SizeDBKeyPrefix + types.SizePttID MerkleTreeKeyOffsetUpdateTS = MerkleTreeKeyOffsetLevel + SizeMerkleTreeLevel DBMerkleGenerateTimePrefix = []byte(".mtgt") DBMerkleSyncTimePrefix = []byte(".mtst") DBMerkleFailSyncTimePrefix = []byte(".mtft") DBMerkleMetaPostfix = []byte("mt") DBMerkleToUpdatePostfix = []byte("Mt") DBMerkleUpdatingPostfix = []byte("MT") OffsetMerkleSyncTime int64 = 3600 // validate until 2-hr ago, and sync with data starting 2-hr ago. GenerateOplogMerkleTreeSeconds = 900 * time.Second // 15 mins ExpireGenerateOplogMerkleTreeSeconds int64 = 450 // 7.5 mins )
oplog-merkle-tree
var ( ExpireDialHistorySeconds int64 = 30 DialHistoryLoopInterval = 30 * time.Second )
dial-history
var ( IsE2E = false IsPrivateAsPublic = false )
misc
var (
DBFix190Prefix = []byte(".f04H") // 190 in base58
)
fix
var ( DefaultConfig = Config{ MaxPeers: 350, MaxHubPeers: 5, MaxImportantPeers: 100, MaxMemberPeers: 200, MaxPendingPeers: 50, MaxRandomPeers: 50, NodeType: NodeTypeDesktop, ExpireOplogSeconds: 180, IsE2E: false, IsPrivateAsPublic: false, } )
default config
var (
ExpireOplogSeconds = 300 // expire oplog circulation as 5 minutes for now.
)
oplog
Functions ¶
func DiffMerkleKeys ¶
func DiffMerkleTree ¶
func DiffMerkleTree( myNodes []*MerkleNode, theirNodes []*MerkleNode, ts types.Timestamp, pm ProtocolManager, merkle *Merkle, ) ([]*MerkleNode, []*MerkleNode, error)
func DiffOplogKeys ¶
func GenChallenge ¶
func GenChallenge() []byte
func GetMerkleName ¶
func GetMerkleName(merkle *Merkle, pm ProtocolManager) string
func GetOplogIterWithOplog ¶
func HandleFailedOplogs ¶
func HandleFailedValidOplogs ¶
func HandleFailedValidOplogs( oplogs []*BaseOplog, peer *PttPeer, info ProcessInfo, setDB func(oplog *BaseOplog), handleFailedValidOplog func(oplog *BaseOplog, info ProcessInfo) error, postprocessLogs func(info ProcessInfo, peer *PttPeer) error, ) error
func HandleOplogs ¶
func HandleOplogs( oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool, pm ProtocolManager, info ProcessInfo, merkle *Merkle, setDB func(oplog *BaseOplog), processLog func(oplog *BaseOplog, info ProcessInfo) ([]*BaseOplog, error), postprocessLogs func(i ProcessInfo, origLogs []*BaseOplog, p *PttPeer, isPending bool) error, ) error
HandleOplogs handles a list of Oplog.
- verify all the oplogs, return if any of the log is invalid.
- preset oplog (isSync as false and setDB)
- check pre-log-id
- integrate existing oplog. skip if already synced.
- process me-oplog.
- save me-oplog.
- broadcast me-oplogs.
- save sync-time.
func HandlePendingOplogs ¶
func HandlePendingOplogs( oplogs []*BaseOplog, peer *PttPeer, pm ProtocolManager, info ProcessInfo, merkle *Merkle, setDB func(oplog *BaseOplog), processPendingLog func(oplog *BaseOplog, i ProcessInfo) (types.Bool, []*BaseOplog, error), processLog func(oplog *BaseOplog, info ProcessInfo) ([]*BaseOplog, error), postprocessLogs func(i ProcessInfo, toBroadcastLogs []*BaseOplog, p *PttPeer, isPending bool) error, ) error
func InitService ¶
func MarshalCode ¶
func MergeKeysInMerkleNodes ¶
func MergeKeysInMerkleNodes(myNodes []*MerkleNode, theirNodes []*MerkleNode) ([][]byte, [][]byte, error)
Return: myNewKeys: new keys from from their nodes, theirNewKeys: new keys from my nodes
func NewObjectWithOplog ¶
func OplogKeyToIDBytes ¶
func OplogKeyToIdxKey ¶
func PMHandleMessageWrapper ¶
func PMOplogMerkleTreeLoop ¶
func PMOplogMerkleTreeLoop(pm ProtocolManager, merkle *Merkle) error
func PMSync ¶
func PMSync(pm ProtocolManager) error
func PrestartPM ¶
func PrestartPM(pm ProtocolManager) error
func ProtocolFailedEntityLog ¶
func ProtocolFailedEntityLog() error
func ScrambleBuf ¶
ScrambleBuf scrambles the buf.
- obtain the json-str to ensure that the 1st-char and the last-char are not 0
- do scramble on the json-str.
XXX TODO: better scrambleBuf
func SetEntityWithOplog ¶
func SetNewEntityWithOplog ¶
func SetNewObjectWithOplog ¶
func StartPM ¶
func StartPM(pm ProtocolManager) error
StartPM starts the pm
- go PMSync (require sync first to receive new-peer-ch)
- pm.Start
- go PMCreateOpKeyLoop
func StopPM ¶
func StopPM(pm ProtocolManager) error
func TeardownService ¶
func TeardownService()
func ValidateMerkleTree ¶
func ValidateMerkleTree( myNodes []*MerkleNode, theirNodes []*MerkleNode, ts types.Timestamp, pm ProtocolManager, merkle *Merkle, ) (types.Timestamp, bool)
func VerifyData ¶
Types ¶
type ApproveJoin ¶
type ApproveJoin struct { ID *types.PttID Name []byte `json:"N"` OpKeyBytes []byte `json:"K"` Data ApproveJoinData `json:"D"` }
type ApproveJoinData ¶
type ApproveJoinData interface{}
type ApproveJoinEntity ¶
type ArticleBlock ¶
type ArticleBlock struct { V types.Version ID *types.PttID ArticleID *types.PttID `json:"AID"` RefID *types.PttID `json:"RID"` ContentType ContentType `json:"ct"` CommentType CommentType `json:"mt"` BlockID uint32 `json:"BID"` Status types.Status `json:"S"` CreateTS types.Timestamp `json:"CT"` UpdateTS types.Timestamp `json:"UT"` CreatorID *types.PttID `json:"CID"` UpdaterID *types.PttID `json:"UID"` Buf [][]byte `json:"B"` }
func NewArticleBlock ¶
func NewArticleBlock() (*ArticleBlock, error)
type Backend ¶
type Backend interface { GetMasterOplogList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error) GetPendingMasterOplogMasterList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error) GetPendingMasterOplogInternalList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error) GetMasterOplogMerkleNodeList(idBytes []byte, level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*BackendMerkleNode, error) // master GetMasterListFromCache(idBytes []byte) ([]*Master, error) GetMasterList(idBytes []byte, startIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*Master, error) GetMemberOplogList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error) GetPendingMemberOplogMasterList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error) GetPendingMemberOplogInternalList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error) GetMemberOplogMerkleNodeList(idBytes []byte, level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*BackendMerkleNode, error) GetMemberList(idBytes []byte, startIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*Master, error) GetOpKeyOplogList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error) GetPendingOpKeyOplogMasterList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error) GetPendingOpKeyOplogInternalList(idBytes []byte, logID []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error) ShowValidateKey() (*types.PttID, error) ValidateValidateKey(keyBytes []byte) (bool, error) GetOpKeyInfos([]*KeyInfo, error) RevokeOpKey(keyIDBytes []byte, myKeyBytes []byte) (bool, error) GetOpKeyInfosFromDB() ([]*KeyInfo, error) // peers CountPeers() (int, error) GetPeers() ([]*BackendPeer, error) }
type BackendConfirmJoin ¶
type BackendCountPeers ¶
type BackendJoinRequest ¶
type BackendJoinRequest struct { CreatorID *types.PttID `json:"C"` NodeID *discover.NodeID `json:"n"` Hash []byte `json:"H"` Name []byte `json:"N"` Status JoinStatus `json:"S"` }
func JoinRequestToBackendJoinRequest ¶
func JoinRequestToBackendJoinRequest(joinRequest *JoinRequest) *BackendJoinRequest
type BackendJoinURL ¶
type BackendMerkle ¶
type BackendMerkle struct { LastGenerateTS types.Timestamp `json:"LG"` BusyGenerateTS types.Timestamp `json:"BG"` LastSyncTS types.Timestamp `json:"LS"` LastFailSyncTS types.Timestamp `json:"LF"` GenerateSeconds time.Duration `json:"G"` ExpireGenerateSeconds int64 `json:"E"` }
func MerkleToBackendMerkle ¶
func MerkleToBackendMerkle(m *Merkle) *BackendMerkle
type BackendMerkleNode ¶
type BackendMerkleNode MerkleNode
func MerkleNodeToBackendMerkleNode ¶
func MerkleNodeToBackendMerkleNode(m *MerkleNode) *BackendMerkleNode
type BackendPeer ¶
type BackendPeer struct { NodeID *discover.NodeID `json:"ID"` PeerType PeerType `json:"T"` UserID *types.PttID `json:"UID"` Addrs []string `json:"A"` }
func PeerToBackendPeer ¶
func PeerToBackendPeer(peer *PttPeer) *BackendPeer
type BaseEntity ¶
type BaseEntity struct { V types.Version ID *types.PttID CreateTS types.Timestamp `json:"CT"` CreatorID *types.PttID `json:"CID"` UpdaterID *types.PttID `json:"UID"` JoinTS types.Timestamp `json:"JT"` LogID *types.PttID `json:"l,omitempty"` UpdateLogID *types.PttID `json:"u,omitempty"` Status types.Status `json:"S"` OwnerIDs []*types.PttID `json:"o,omitempty"` MeLogID *types.PttID `json:"m,omitempty"` MeLogTS types.Timestamp `json:"mt"` EntityType EntityType `json:"e"` SyncInfo SyncInfo // contains filtered or unexported fields }
func NewBaseEntity ¶
func (*BaseEntity) AddOwnerID ¶
func (e *BaseEntity) AddOwnerID(id *types.PttID)
func (*BaseEntity) DB ¶
func (e *BaseEntity) DB() *pttdb.LDBBatch
func (*BaseEntity) DBLock ¶
func (e *BaseEntity) DBLock() *types.LockMap
func (*BaseEntity) GetCreateTS ¶
func (e *BaseEntity) GetCreateTS() types.Timestamp
func (*BaseEntity) GetCreatorID ¶
func (e *BaseEntity) GetCreatorID() *types.PttID
func (*BaseEntity) GetEntityType ¶
func (e *BaseEntity) GetEntityType() EntityType
func (*BaseEntity) GetLogID ¶
func (e *BaseEntity) GetLogID() *types.PttID
func (*BaseEntity) GetMeLogID ¶
func (e *BaseEntity) GetMeLogID() *types.PttID
func (*BaseEntity) GetMeLogTS ¶
func (e *BaseEntity) GetMeLogTS() types.Timestamp
func (*BaseEntity) GetOwnerIDs ¶
func (e *BaseEntity) GetOwnerIDs() []*types.PttID
func (*BaseEntity) GetStatus ¶
func (e *BaseEntity) GetStatus() types.Status
func (*BaseEntity) GetSyncInfo ¶
func (e *BaseEntity) GetSyncInfo() SyncInfo
func (*BaseEntity) GetUpdateLogID ¶
func (e *BaseEntity) GetUpdateLogID() *types.PttID
func (*BaseEntity) GetUpdaterID ¶
func (e *BaseEntity) GetUpdaterID() *types.PttID
func (*BaseEntity) IDString ¶
func (e *BaseEntity) IDString() string
func (*BaseEntity) Init ¶
func (e *BaseEntity) Init(pm ProtocolManager, ptt Ptt, service Service)
func (*BaseEntity) Lock ¶
func (e *BaseEntity) Lock() error
func (*BaseEntity) MustLock ¶
func (e *BaseEntity) MustLock() error
func (*BaseEntity) Name ¶
func (e *BaseEntity) Name() string
func (*BaseEntity) PM ¶
func (e *BaseEntity) PM() ProtocolManager
func (*BaseEntity) Prestart ¶
func (e *BaseEntity) Prestart() error
func (*BaseEntity) PrestartAndStart ¶
func (e *BaseEntity) PrestartAndStart() error
func (*BaseEntity) Ptt ¶
func (e *BaseEntity) Ptt() Ptt
func (*BaseEntity) RLock ¶
func (e *BaseEntity) RLock() error
func (*BaseEntity) RUnlock ¶
func (e *BaseEntity) RUnlock() error
func (*BaseEntity) RemoveOwnerID ¶
func (e *BaseEntity) RemoveOwnerID(id *types.PttID)
func (*BaseEntity) ResetJoinMeta ¶
func (e *BaseEntity) ResetJoinMeta()
func (*BaseEntity) ResetOwnerIDs ¶
func (e *BaseEntity) ResetOwnerIDs()
func (*BaseEntity) Service ¶
func (e *BaseEntity) Service() Service
func (*BaseEntity) SetCreateTS ¶
func (e *BaseEntity) SetCreateTS(ts types.Timestamp)
func (*BaseEntity) SetEntityType ¶
func (e *BaseEntity) SetEntityType(t EntityType)
func (*BaseEntity) SetID ¶
func (e *BaseEntity) SetID(id *types.PttID)
func (*BaseEntity) SetJoinTS ¶
func (e *BaseEntity) SetJoinTS(ts types.Timestamp)
func (*BaseEntity) SetLogID ¶
func (e *BaseEntity) SetLogID(id *types.PttID)
func (*BaseEntity) SetMeLogID ¶
func (e *BaseEntity) SetMeLogID(id *types.PttID)
func (*BaseEntity) SetMeLogTS ¶
func (e *BaseEntity) SetMeLogTS(ts types.Timestamp)
func (*BaseEntity) SetName ¶
func (e *BaseEntity) SetName(name string)
func (*BaseEntity) SetStatus ¶
func (e *BaseEntity) SetStatus(status types.Status)
func (*BaseEntity) SetSyncInfo ¶
func (e *BaseEntity) SetSyncInfo(syncInfo SyncInfo)
func (*BaseEntity) SetUpdateLogID ¶
func (e *BaseEntity) SetUpdateLogID(id *types.PttID)
func (*BaseEntity) SetUpdaterID ¶
func (e *BaseEntity) SetUpdaterID(id *types.PttID)
func (*BaseEntity) Start ¶
func (e *BaseEntity) Start() error
func (*BaseEntity) Stop ¶
func (e *BaseEntity) Stop() error
func (*BaseEntity) Unlock ¶
func (e *BaseEntity) Unlock() error
type BaseMeteredMsgReadWriter ¶
type BaseMeteredMsgReadWriter struct { p2p.MsgReadWriter // contains filtered or unexported fields }
func (*BaseMeteredMsgReadWriter) Init ¶
func (rw *BaseMeteredMsgReadWriter) Init(version uint) error
func (*BaseMeteredMsgReadWriter) ReadMsg ¶
func (rw *BaseMeteredMsgReadWriter) ReadMsg() (p2p.Msg, error)
func (*BaseMeteredMsgReadWriter) Version ¶
func (rw *BaseMeteredMsgReadWriter) Version() uint
type BaseObject ¶
type BaseObject struct { V types.Version ID *types.PttID CreateTS types.Timestamp `json:"CT"` CreatorID *types.PttID `json:"CID"` UpdaterID *types.PttID `json:"UID"` EntityID *types.PttID `json:"e,omitempty"` LogID *types.PttID `json:"l,omitempty"` UpdateLogID *types.PttID `json:"u,omitempty"` Status types.Status `json:"S"` IsGood types.Bool `json:"g"` IsAllGood types.Bool `json:"a"` BlockInfo *BlockInfo `json:"b,omitempty"` // contains filtered or unexported fields }
func (*BaseObject) CheckIsAllGood ¶
func (o *BaseObject) CheckIsAllGood() types.Bool
func (*BaseObject) CloneDB ¶
func (o *BaseObject) CloneDB(o2 *BaseObject)
func (*BaseObject) DB ¶
func (o *BaseObject) DB() *pttdb.LDBBatch
func (*BaseObject) DBLock ¶
func (o *BaseObject) DBLock() *types.LockMap
func (*BaseObject) Delete ¶
func (o *BaseObject) Delete( isLocked bool, ) error
func (*BaseObject) DeleteByKey ¶
func (o *BaseObject) DeleteByKey(key []byte, isLocked bool) error
func (*BaseObject) FullDBIdxPrefix ¶
func (o *BaseObject) FullDBIdxPrefix() []byte
func (*BaseObject) FullDBPrefix ¶
func (o *BaseObject) FullDBPrefix() []byte
func (*BaseObject) GetBaseObject ¶
func (o *BaseObject) GetBaseObject() *BaseObject
func (*BaseObject) GetBlockInfo ¶
func (o *BaseObject) GetBlockInfo() *BlockInfo
func (*BaseObject) GetCreateTS ¶
func (o *BaseObject) GetCreateTS() types.Timestamp
func (*BaseObject) GetCreatorID ¶
func (o *BaseObject) GetCreatorID() *types.PttID
func (*BaseObject) GetCrossObjIterWithObj ¶
func (*BaseObject) GetEntityID ¶
func (o *BaseObject) GetEntityID() *types.PttID
func (*BaseObject) GetID ¶
func (o *BaseObject) GetID() *types.PttID
func (*BaseObject) GetIsAllGood ¶
func (o *BaseObject) GetIsAllGood() types.Bool
func (*BaseObject) GetIsGood ¶
func (o *BaseObject) GetIsGood() types.Bool
func (*BaseObject) GetLogID ¶
func (o *BaseObject) GetLogID() *types.PttID
func (*BaseObject) GetNewestLogID ¶
func (o *BaseObject) GetNewestLogID() *types.PttID
func (*BaseObject) GetObjIdxIterWithObj ¶
func (*BaseObject) GetObjIterWithObj ¶
func (*BaseObject) GetStatus ¶
func (o *BaseObject) GetStatus() types.Status
func (*BaseObject) GetUpdateLogID ¶
func (o *BaseObject) GetUpdateLogID() *types.PttID
func (*BaseObject) GetUpdaterID ¶
func (o *BaseObject) GetUpdaterID() *types.PttID
func (*BaseObject) GetValueByID ¶
func (o *BaseObject) GetValueByID(isLocked bool) ([]byte, error)
func (*BaseObject) IdxKey ¶
func (o *BaseObject) IdxKey() ([]byte, error)
func (*BaseObject) IdxPrefix ¶
func (o *BaseObject) IdxPrefix() []byte
func (*BaseObject) Lock ¶
func (o *BaseObject) Lock() error
func (*BaseObject) NewEmptyObj ¶
func (o *BaseObject) NewEmptyObj() *BaseObject
func (*BaseObject) RLock ¶
func (o *BaseObject) RLock() error
func (*BaseObject) RUnlock ¶
func (o *BaseObject) RUnlock() error
func (*BaseObject) RemoveMeta ¶
func (o *BaseObject) RemoveMeta()
func (*BaseObject) SetBlockInfo ¶
func (o *BaseObject) SetBlockInfo(blockInfo *BlockInfo) error
func (*BaseObject) SetBlockInfoDB ¶
func (o *BaseObject) SetBlockInfoDB() func(blockInfo *BlockInfo, objID *types.PttID)
func (*BaseObject) SetCreateTS ¶
func (o *BaseObject) SetCreateTS(ts types.Timestamp)
func (*BaseObject) SetCreatorID ¶
func (o *BaseObject) SetCreatorID(id *types.PttID)
func (*BaseObject) SetEntityID ¶
func (o *BaseObject) SetEntityID(id *types.PttID)
func (*BaseObject) SetFullDBPrefix ¶
func (o *BaseObject) SetFullDBPrefix(fullDBPrefix []byte)
func (*BaseObject) SetID ¶
func (o *BaseObject) SetID(id *types.PttID)
func (*BaseObject) SetIsAllGood ¶
func (o *BaseObject) SetIsAllGood(isAllGood types.Bool)
func (*BaseObject) SetIsGood ¶
func (o *BaseObject) SetIsGood(isGood types.Bool)
func (*BaseObject) SetLogID ¶
func (o *BaseObject) SetLogID(id *types.PttID)
func (*BaseObject) SetMediaDB ¶
func (o *BaseObject) SetMediaDB() func(media *Media)
func (*BaseObject) SetStatus ¶
func (o *BaseObject) SetStatus(status types.Status)
func (*BaseObject) SetUpdateLogID ¶
func (o *BaseObject) SetUpdateLogID(id *types.PttID)
func (*BaseObject) SetUpdaterID ¶
func (o *BaseObject) SetUpdaterID(id *types.PttID)
func (*BaseObject) SetVersion ¶
func (o *BaseObject) SetVersion(v types.Version)
func (*BaseObject) Unlock ¶
func (o *BaseObject) Unlock() error
type BaseOplog ¶
type BaseOplog struct { V types.Version ID *types.PttID CreatorID *types.PttID `json:"CID"` CreateTS types.Timestamp `json:"CT"` ObjID *types.PttID `json:"OID"` Op OpType `json:"O"` PreLogID *types.PttID `json:"p,omitempty"` Data OpData `json:"D,omitempty"` CreatorHash []byte `json:"cH,omitempty"` Salt types.Salt `json:"s,omitempty"` Sig []byte `json:"S,omitempty"` Pubkey []byte `json:"K,omitempty"` KeyExtra *KeyExtraInfo `json:"k,omitempty"` // to remove when doing sign UpdateTS types.Timestamp `json:"UT"` Hash []byte `json:"H,omitempty"` MasterLogID *types.PttID `json:"mID,omitempty"` MasterSigns []*SignInfo `json:"m,omitempty"` InternalSigns []*SignInfo `json:"i,omitempty"` IsSync types.Bool `json:"y"` // not distribute IsNewer types.Bool `json:"n,omitempty"` // for p2p, should be empty in save / sign Extra interface{} `json:"e,omitempty"` // contains filtered or unexported fields }
func GetOplogList ¶
func MasterOplogsToOplogs ¶
func MasterOplogsToOplogs(typedLogs []*MasterOplog) []*BaseOplog
func MemberOplogsToOplogs ¶
func MemberOplogsToOplogs(typedLogs []*MemberOplog) []*BaseOplog
func NewOplogForLoadData ¶
func OpKeyOplogsToOplogs ¶
func OpKeyOplogsToOplogs(typedLogs []*OpKeyOplog) []*BaseOplog
func ProcessInfoToLogs ¶
func PttOplogsToOplogs ¶
func (*BaseOplog) CheckAlreadyExists ¶
func (*BaseOplog) GetDBIdxPrefix ¶
func (*BaseOplog) GetDBMerklePrefix ¶
func (*BaseOplog) GetDBPrefix ¶
func (*BaseOplog) GetDBPrefixInternal ¶
func (*BaseOplog) GetDBPrefixMaster ¶
func (*BaseOplog) GetDBPrefxiID ¶
func (*BaseOplog) IntegrateExisting ¶
IntegrateExisting integrates with existing oplog. Return: is-to-re-sign, error
func (*BaseOplog) InternalSign ¶
func (*BaseOplog) MarshalKey ¶
MarshalKey: prefixID:TS:OplogID:Op
func (*BaseOplog) MarshalMerkleKey ¶
MarshalKey: prefixID:TS:OplogID:Op
func (*BaseOplog) MasterSign ¶
func (*BaseOplog) SaveCorePending ¶
func (*BaseOplog) SelectExisting ¶
SelectExisting determines whether we select the new oplog or the original oplog when the oplog is valid. Not integrating the signs.
Return: origIsSync, isToBroadcast, err
func (*BaseOplog) SetMasterLogID ¶
func (*BaseOplog) SetPreLogID ¶
type BaseProtocolManager ¶
type BaseProtocolManager struct {
// contains filtered or unexported fields
}
func NewBaseProtocolManager ¶
func NewBaseProtocolManager( ptt Ptt, renewOpKeySeconds int64, expireOpKeySeconds int64, maxSyncRandomSeconds int, minSyncRandomSeconds int, maxMasters int, log0Merkle *Merkle, internalSign func(oplog *BaseOplog) (bool, error), forceSignOplog func(oplog *BaseOplog) error, isValidOplog func(signInfos []*SignInfo) (*types.PttID, uint32, bool), validateIntegrateSign func(oplog *BaseOplog, isLocked bool) error, setLog0DB func(oplog *BaseOplog), handleLog0s func(logs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error, isMaster func(id *types.PttID, isLocked bool) bool, isMember func(id *types.PttID, isLocked bool) bool, getPeerType func(peer *PttPeer) PeerType, isMyDevice func(peer *PttPeer) bool, isImportantPeer func(peer *PttPeer) bool, isMemberPeer func(peer *PttPeer) bool, isPendingPeer func(peer *PttPeer) bool, postsyncMemberOplog func(peer *PttPeer) error, theDelete func() error, postdelete func(opData OpData, isForce bool) error, e Entity, svc Service, db *pttdb.LDBBatch, ) (*BaseProtocolManager, error)
func (*BaseProtocolManager) AddMaster ¶
func (pm *BaseProtocolManager) AddMaster(id *types.PttID, isForce bool) (*Master, *MasterOplog, error)
func (*BaseProtocolManager) AddMember ¶
func (pm *BaseProtocolManager) AddMember(id *types.PttID, isForce bool) (*Member, *MemberOplog, error)
func (*BaseProtocolManager) AddPerson ¶
func (pm *BaseProtocolManager) AddPerson( id *types.PttID, addOp OpType, isForce bool, origPerson Object, opData OpData, merkle *Merkle, newPerson func(id *types.PttID) (Object, OpData, error), newOplogWithTS func(objID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error), broadcastLog func(oplog *BaseOplog) error, postcreate func(obj Object, oplog *BaseOplog) error, setLogDB func(oplog *BaseOplog), newOplog func(objID *types.PttID, op OpType, opData OpData) (Oplog, error), ) (Object, *BaseOplog, error)
func (*BaseProtocolManager) ApproveJoin ¶
func (pm *BaseProtocolManager) ApproveJoin( joinEntity *JoinEntity, keyInfo *KeyInfo, peer *PttPeer, ) (*KeyInfo, interface{}, error)
Required variables in joinEntity: ID
func (*BaseProtocolManager) BaseDeleteMedia ¶
func (*BaseProtocolManager) BaseHandleDeleteMediaLogs ¶
func (pm *BaseProtocolManager) BaseHandleDeleteMediaLogs( oplog *BaseOplog, info ProcessInfo, merkle *Merkle, setLogDB func(oplog *BaseOplog), updateDeleteInfo func(obj Object, oplog *BaseOplog, info ProcessInfo) error, ) ([]*BaseOplog, error)
func (*BaseProtocolManager) BaseHandleFailedValidDeleteMediaLog ¶
func (pm *BaseProtocolManager) BaseHandleFailedValidDeleteMediaLog( oplog *BaseOplog, info ProcessInfo, updateDeleteInfo func(obj Object, oplog *BaseOplog, info ProcessInfo) error, ) error
func (*BaseProtocolManager) BaseHandlePendingDeleteMediaLogs ¶
func (pm *BaseProtocolManager) BaseHandlePendingDeleteMediaLogs( oplog *BaseOplog, info ProcessInfo, merkle *Merkle, setLogDB func(oplog *BaseOplog), updateDeleteInfo func(obj Object, oplog *BaseOplog, info ProcessInfo) error, ) (types.Bool, []*BaseOplog, error)
func (*BaseProtocolManager) BroadcastMasterOplog ¶
func (pm *BaseProtocolManager) BroadcastMasterOplog(oplog *MasterOplog) error
func (*BaseProtocolManager) BroadcastMasterOplogs ¶
func (pm *BaseProtocolManager) BroadcastMasterOplogs(opKeyLogs []*MasterOplog) error
func (*BaseProtocolManager) BroadcastMemberOplog ¶
func (pm *BaseProtocolManager) BroadcastMemberOplog(oplog *MemberOplog) error
func (*BaseProtocolManager) BroadcastMemberOplogs ¶
func (pm *BaseProtocolManager) BroadcastMemberOplogs(opKeyLogs []*MemberOplog) error
func (*BaseProtocolManager) BroadcastOpKeyOplog ¶
func (pm *BaseProtocolManager) BroadcastOpKeyOplog(oplog *OpKeyOplog) error
func (*BaseProtocolManager) BroadcastOpKeyOplogs ¶
func (pm *BaseProtocolManager) BroadcastOpKeyOplogs(opKeyLogs []*OpKeyOplog) error
func (*BaseProtocolManager) BroadcastOplog ¶
func (pm *BaseProtocolManager) BroadcastOplog(oplog *BaseOplog, msg OpType, pendingMsg OpType) error
func (*BaseProtocolManager) BroadcastOplogs ¶
func (pm *BaseProtocolManager) BroadcastOplogs(oplogs []*BaseOplog, msg OpType, pendingMsg OpType) error
func (*BaseProtocolManager) CleanJoinKey ¶
func (pm *BaseProtocolManager) CleanJoinKey()
func (*BaseProtocolManager) CleanLog0 ¶
func (pm *BaseProtocolManager) CleanLog0(isRetainLog bool)
func (*BaseProtocolManager) CleanMaster ¶
func (pm *BaseProtocolManager) CleanMaster() error
func (*BaseProtocolManager) CleanMasterOplog ¶
func (pm *BaseProtocolManager) CleanMasterOplog()
func (*BaseProtocolManager) CleanMember ¶
func (pm *BaseProtocolManager) CleanMember(isRetainMe bool) error
func (*BaseProtocolManager) CleanMemberOplog ¶
func (pm *BaseProtocolManager) CleanMemberOplog(isRetainLog bool)
func (*BaseProtocolManager) CleanOpKey ¶
func (pm *BaseProtocolManager) CleanOpKey()
func (*BaseProtocolManager) CleanOpKeyOplog ¶
func (pm *BaseProtocolManager) CleanOpKeyOplog()
func (*BaseProtocolManager) CleanOplog ¶
func (pm *BaseProtocolManager) CleanOplog(oplog *BaseOplog, merkle *Merkle)
func (*BaseProtocolManager) CleanPeers ¶
func (pm *BaseProtocolManager) CleanPeers()
func (*BaseProtocolManager) ConnectMaster ¶
func (pm *BaseProtocolManager) ConnectMaster() error
func (*BaseProtocolManager) CountPeers ¶
func (pm *BaseProtocolManager) CountPeers() (int, error)
func (*BaseProtocolManager) CreateJoinKeyLoop ¶
func (pm *BaseProtocolManager) CreateJoinKeyLoop() error
func (*BaseProtocolManager) CreateObject ¶
func (pm *BaseProtocolManager) CreateObject( data CreateData, createOp OpType, merkle *Merkle, newObj func(data CreateData) (Object, OpData, error), newOplogWithTS func(objID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error), increate func(obj Object, data CreateData, oplog *BaseOplog, opData OpData) error, setLogDB func(oplog *BaseOplog), broadcastLogs func(oplogs []*BaseOplog) error, broadcastLog func(oplog *BaseOplog) error, postcreate func(obj Object, oplog *BaseOplog) error, ) (Object, error)
CreateObject creates the object. The status of the object may be internal-pending, pending, or alive.
func (*BaseProtocolManager) CreateOpKey ¶
func (pm *BaseProtocolManager) CreateOpKey() error
**
- CreateObject **
func (*BaseProtocolManager) CreateOpKeyLoop ¶
func (pm *BaseProtocolManager) CreateOpKeyLoop() error
func (*BaseProtocolManager) CreatePerson ¶
func (pm *BaseProtocolManager) CreatePerson( id *types.PttID, createOp OpType, isForce bool, merkle *Merkle, newPerson func(id *types.PttID) (Object, OpData, error), newOplogWithTS func(objID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error), broadcastLog func(oplog *BaseOplog) error, postcreatePerson func(obj Object, oplog *BaseOplog) error, ) (Object, *BaseOplog, error)
CreatePerson creates person (master / member). To promote the framework, people are immediately set as valid (type as alive, oplog as valid) after CreatePerson.
- new person
- new oplog
- set synced (is-all-good).
- sign oplog
- save object
- oplog-save
- broadcast-log
func (*BaseProtocolManager) DB ¶
func (pm *BaseProtocolManager) DB() *pttdb.LDBBatch
func (*BaseProtocolManager) DBObjLock ¶
func (pm *BaseProtocolManager) DBObjLock() *types.LockMap
func (*BaseProtocolManager) DBOpKey ¶
func (pm *BaseProtocolManager) DBOpKey() *pttdb.LDBBatch
func (*BaseProtocolManager) DBOpKeyIdxPrefix ¶
func (pm *BaseProtocolManager) DBOpKeyIdxPrefix() []byte
func (*BaseProtocolManager) DBOpKeyLock ¶
func (pm *BaseProtocolManager) DBOpKeyLock() *types.LockMap
func (*BaseProtocolManager) DBOpKeyPrefix ¶
func (pm *BaseProtocolManager) DBOpKeyPrefix() []byte
func (*BaseProtocolManager) DefaultPostdeleteEntity ¶
func (pm *BaseProtocolManager) DefaultPostdeleteEntity(opData OpData, isForce bool) error
func (*BaseProtocolManager) Delete ¶
func (pm *BaseProtocolManager) Delete() error
func (*BaseProtocolManager) DeleteEntity ¶
func (pm *BaseProtocolManager) DeleteEntity( deleteOp OpType, opData OpData, internalPendingStatus types.Status, pendingStatus types.Status, status types.Status, merkle *Merkle, newOplog func(objID *types.PttID, op OpType, opData OpData) (Oplog, error), setPendingDeleteSyncInfo func(entity Entity, status types.Status, oplog *BaseOplog) error, broadcastLog func(oplog *BaseOplog) error, postdelete func(opData OpData, isForce bool) error, ) error
func (*BaseProtocolManager) DeleteMember ¶
func (pm *BaseProtocolManager) DeleteMember( id *types.PttID, ) (bool, error)
func (*BaseProtocolManager) DeleteObject ¶
func (pm *BaseProtocolManager) DeleteObject( id *types.PttID, deleteOp OpType, origObj Object, opData OpData, merkle *Merkle, setLogDB func(oplog *BaseOplog), newOplog func(objID *types.PttID, op OpType, opData OpData) (Oplog, error), indelete func(origObj Object, opData OpData, oplog *BaseOplog) (*BlockInfo, error), setPendingDeleteSyncInfo func(origObj Object, status types.Status, oplog *BaseOplog) error, broadcastLog func(oplog *BaseOplog) error, postdelete func(id *types.PttID, oplog *BaseOplog, opData OpData, origObj Object, blockInfo *BlockInfo) error, ) error
func (*BaseProtocolManager) DeletePerson ¶
func (pm *BaseProtocolManager) DeletePerson( id *types.PttID, deleteOp OpType, origPerson Object, opData OpData, internalPendingStatus types.Status, pendingStatus types.Status, status types.Status, merkle *Merkle, setLogDB func(oplog *BaseOplog), newOplog func(objID *types.PttID, op OpType, opData OpData) (Oplog, error), broadcastLog func(oplog *BaseOplog) error, postdelete func(id *types.PttID, oplog *BaseOplog, origPerson Object, opData OpData) error, ) error
func (*BaseProtocolManager) Entity ¶
func (pm *BaseProtocolManager) Entity() Entity
func (*BaseProtocolManager) EventMux ¶
func (pm *BaseProtocolManager) EventMux() *event.TypeMux
func (*BaseProtocolManager) ExpireOpKeyInfo ¶
func (pm *BaseProtocolManager) ExpireOpKeyInfo(keyInfo *KeyInfo, isLocked bool) error
func (*BaseProtocolManager) ExpireOpKeySeconds ¶
func (pm *BaseProtocolManager) ExpireOpKeySeconds() int64
func (*BaseProtocolManager) Fix138MasterLog ¶
func (pm *BaseProtocolManager) Fix138MasterLog() error
func (*BaseProtocolManager) Fix190Merkle ¶
func (pm *BaseProtocolManager) Fix190Merkle() error
func (*BaseProtocolManager) ForceCreateObject ¶
func (pm *BaseProtocolManager) ForceCreateObject( data CreateData, createOp OpType, merkle *Merkle, newObj func(data CreateData) (Object, OpData, error), newOplogWithTS func(objID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error), increate func(obj Object, data CreateData, oplog *BaseOplog, opData OpData) error, setLogDB func(oplog *BaseOplog), broadcastLogs func(oplogs []*BaseOplog) error, broadcastLog func(oplog *BaseOplog) error, postcreate func(obj Object, oplog *BaseOplog) error, ) (Object, error)
ForceCreateObject creates the object and forcely makes the object as valid (oplog as valid-log, and the object as alive.)
func (*BaseProtocolManager) ForceCreateOpKey ¶
func (pm *BaseProtocolManager) ForceCreateOpKey() error
func (*BaseProtocolManager) ForceOpKey ¶
func (pm *BaseProtocolManager) ForceOpKey() chan struct{}
func (*BaseProtocolManager) ForceReconstructMerkle ¶
func (pm *BaseProtocolManager) ForceReconstructMerkle() error
func (*BaseProtocolManager) ForceSignOplog ¶
func (pm *BaseProtocolManager) ForceSignOplog(oplog *BaseOplog) error
func (*BaseProtocolManager) ForceSync ¶
func (pm *BaseProtocolManager) ForceSync() chan struct{}
func (*BaseProtocolManager) ForceSyncCycle ¶
func (pm *BaseProtocolManager) ForceSyncCycle() time.Duration
func (*BaseProtocolManager) ForceSyncMasterMerkle ¶
func (pm *BaseProtocolManager) ForceSyncMasterMerkle() (bool, error)
func (*BaseProtocolManager) ForceSyncMedia ¶
func (pm *BaseProtocolManager) ForceSyncMedia( syncIDs []*ForceSyncID, peer *PttPeer, syncMsg OpType, ) error
func (*BaseProtocolManager) ForceSyncMemberMerkle ¶
func (pm *BaseProtocolManager) ForceSyncMemberMerkle() (bool, error)
func (*BaseProtocolManager) ForceSyncObject ¶
func (pm *BaseProtocolManager) ForceSyncObject( syncIDs []*ForceSyncID, peer *PttPeer, syncMsg OpType, ) error
func (*BaseProtocolManager) ForceSyncOplog ¶
func (*BaseProtocolManager) ForceSyncOplogAck ¶
func (*BaseProtocolManager) ForceSyncOplogByMerkle ¶
func (pm *BaseProtocolManager) ForceSyncOplogByMerkle( myNewNode *MerkleNode, forceSyncOplogMsg OpType, merkle *Merkle, peer *PttPeer, ) error
func (*BaseProtocolManager) ForceSyncOplogByMerkleAck ¶
func (pm *BaseProtocolManager) ForceSyncOplogByMerkleAck( nodes []*MerkleNode, forceSyncOplogAckMsg OpType, merkle *Merkle, peer *PttPeer, ) error
func (*BaseProtocolManager) ForceSyncOplogByOplogAck ¶
func (pm *BaseProtocolManager) ForceSyncOplogByOplogAck( theirNewNodes []*MerkleNode, forceSyncOplogByOplogAckMsg OpType, setDB func(oplog *BaseOplog), setNewestOplog func(log *BaseOplog) error, peer *PttPeer, merkle *Merkle, ) error
func (*BaseProtocolManager) FullBlockDBPrefix ¶
func (pm *BaseProtocolManager) FullBlockDBPrefix(prefix []byte) ([]byte, error)
func (*BaseProtocolManager) FullCleanLog ¶
func (pm *BaseProtocolManager) FullCleanLog()
func (*BaseProtocolManager) GetEntityLog ¶
func (pm *BaseProtocolManager) GetEntityLog() (*BaseOplog, error)
func (*BaseProtocolManager) GetJoinKey ¶
func (pm *BaseProtocolManager) GetJoinKey() (*KeyInfo, error)
func (*BaseProtocolManager) GetJoinKeyFromHash ¶
func (pm *BaseProtocolManager) GetJoinKeyFromHash(hash *common.Address) (*KeyInfo, error)
func (*BaseProtocolManager) GetJoinType ¶
func (pm *BaseProtocolManager) GetJoinType(hash *common.Address) (JoinType, error)
func (*BaseProtocolManager) GetMasterList ¶
func (*BaseProtocolManager) GetMasterListFromCache ¶
func (pm *BaseProtocolManager) GetMasterListFromCache(isLocked bool) ([]*Master, error)
func (*BaseProtocolManager) GetMasterOplogList ¶
func (pm *BaseProtocolManager) GetMasterOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*MasterOplog, error)
GetMasterOplogList gets the MasterOplogs.
func (*BaseProtocolManager) GetMasterOplogMerkleNodeList ¶
func (pm *BaseProtocolManager) GetMasterOplogMerkleNodeList(level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*MerkleNode, error)
func (*BaseProtocolManager) GetMasters ¶
func (pm *BaseProtocolManager) GetMasters() map[types.PttID]*Master
func (*BaseProtocolManager) GetMedia ¶
func (pm *BaseProtocolManager) GetMedia(mediaID *types.PttID) (*Media, error)
func (*BaseProtocolManager) GetMemberList ¶
func (*BaseProtocolManager) GetMemberLogByMemberID ¶
func (pm *BaseProtocolManager) GetMemberLogByMemberID(id *types.PttID, isLocked bool) (*MemberOplog, error)
func (*BaseProtocolManager) GetMemberOplogList ¶
func (pm *BaseProtocolManager) GetMemberOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*MemberOplog, error)
GetMemberOplogList gets the MemberOplogs.
func (*BaseProtocolManager) GetMemberOplogMerkleNodeList ¶
func (pm *BaseProtocolManager) GetMemberOplogMerkleNodeList(level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*MerkleNode, error)
func (*BaseProtocolManager) GetNewestMasterLogID ¶
func (pm *BaseProtocolManager) GetNewestMasterLogID() *types.PttID
func (*BaseProtocolManager) GetNewestOpKey ¶
func (pm *BaseProtocolManager) GetNewestOpKey(isLocked bool) (*KeyInfo, error)
func (*BaseProtocolManager) GetOldestOpKey ¶
func (pm *BaseProtocolManager) GetOldestOpKey(isLocked bool) (*KeyInfo, error)
func (*BaseProtocolManager) GetOpKeyFromHash ¶
func (*BaseProtocolManager) GetOpKeyListFromDB ¶
func (pm *BaseProtocolManager) GetOpKeyListFromDB() ([]*KeyInfo, error)
func (*BaseProtocolManager) GetOpKeyOplogList ¶
func (pm *BaseProtocolManager) GetOpKeyOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*OpKeyOplog, error)
GetOpKeyOplogList gets the OpKeyOplogs.
func (*BaseProtocolManager) GetOplog0 ¶
func (pm *BaseProtocolManager) GetOplog0() *BaseOplog
func (*BaseProtocolManager) GetOplogMerkleNodeList ¶
func (pm *BaseProtocolManager) GetOplogMerkleNodeList(merkle *Merkle, level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*MerkleNode, error)
func (*BaseProtocolManager) GetOwnerID ¶
func (pm *BaseProtocolManager) GetOwnerID(isLocked bool) *types.PttID
func (*BaseProtocolManager) GetPeerType ¶
func (pm *BaseProtocolManager) GetPeerType(peer *PttPeer) PeerType
func (*BaseProtocolManager) GetPeers ¶
func (pm *BaseProtocolManager) GetPeers() ([]*PttPeer, error)
func (*BaseProtocolManager) GetPendingOplogs ¶
func (*BaseProtocolManager) GetPendingPeerByUserID ¶
func (*BaseProtocolManager) GetToRenewOpKeySeconds ¶
func (pm *BaseProtocolManager) GetToRenewOpKeySeconds() int
func (*BaseProtocolManager) HandleAddMasterOplog ¶
func (pm *BaseProtocolManager) HandleAddMasterOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddMasterOplogs ¶
func (pm *BaseProtocolManager) HandleAddMasterOplogs(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddMemberOplog ¶
func (pm *BaseProtocolManager) HandleAddMemberOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddMemberOplogs ¶
func (pm *BaseProtocolManager) HandleAddMemberOplogs(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddOpKeyOplog ¶
func (pm *BaseProtocolManager) HandleAddOpKeyOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddOpKeyOplogs ¶
func (pm *BaseProtocolManager) HandleAddOpKeyOplogs(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddOplog ¶
func (*BaseProtocolManager) HandleAddOplogs ¶
func (*BaseProtocolManager) HandleAddPendingMasterOplog ¶
func (pm *BaseProtocolManager) HandleAddPendingMasterOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddPendingMasterOplogs ¶
func (pm *BaseProtocolManager) HandleAddPendingMasterOplogs(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddPendingMemberOplog ¶
func (pm *BaseProtocolManager) HandleAddPendingMemberOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddPendingMemberOplogs ¶
func (pm *BaseProtocolManager) HandleAddPendingMemberOplogs(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddPendingOpKeyOplog ¶
func (pm *BaseProtocolManager) HandleAddPendingOpKeyOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddPendingOpKeyOplogs ¶
func (pm *BaseProtocolManager) HandleAddPendingOpKeyOplogs(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleAddPendingOplog ¶
func (*BaseProtocolManager) HandleAddPendingOplogs ¶
func (*BaseProtocolManager) HandleCreateMediaLogs ¶
func (pm *BaseProtocolManager) HandleCreateMediaLogs( oplog *BaseOplog, info ProcessInfo, existsInInfo func(oplog *BaseOplog, info ProcessInfo) (bool, error), updateCreateInfo func(obj Object, oplog *BaseOplog, opData OpData, info ProcessInfo) error, ) ([]*BaseOplog, error)
func (*BaseProtocolManager) HandleCreateObjectLog ¶
func (pm *BaseProtocolManager) HandleCreateObjectLog( oplog *BaseOplog, obj Object, opData OpData, info ProcessInfo, existsInInfo func(oplog *BaseOplog, info ProcessInfo) (bool, error), newObjWithOplog func(oplog *BaseOplog, opData OpData) Object, postcreate func(obj Object, oplog *BaseOplog) error, updateCreateInfo func(obj Object, oplog *BaseOplog, opData OpData, info ProcessInfo) error, ) ([]*BaseOplog, error)
HandleCreateObjectLog handles valid create-object log
func (*BaseProtocolManager) HandleCreatePersonLog ¶
func (pm *BaseProtocolManager) HandleCreatePersonLog( oplog *BaseOplog, person Object, opData OpData, postcreate func(obj Object, oplog *BaseOplog) error, ) ([]*BaseOplog, error)
HandleCreatePersonLog handles valid create-person log.
- lock person
- check whether the person exists. (should always be ErrNotFound)
- new person.
- set is-all-sync
- save object with oplog.
func (*BaseProtocolManager) HandleDeleteEntityLog ¶
func (pm *BaseProtocolManager) HandleDeleteEntityLog( oplog *BaseOplog, info ProcessInfo, opData OpData, status types.Status, merkle *Merkle, setLogDB func(oplog *BaseOplog), postdelete func(opData OpData, isForce bool) error, updateDeleteInfo func(oplog *BaseOplog, info ProcessInfo) error, ) ([]*BaseOplog, error)
func (*BaseProtocolManager) HandleDeleteObjectLog ¶
func (pm *BaseProtocolManager) HandleDeleteObjectLog( oplog *BaseOplog, info ProcessInfo, obj Object, opData OpData, merkle *Merkle, setLogDB func(oplog *BaseOplog), removeMediaInfoByBlockInfo func(blockInfo *BlockInfo, info ProcessInfo, oplog *BaseOplog), postdelete func(id *types.PttID, oplog *BaseOplog, opData OpData, origObj Object, blockInfo *BlockInfo) error, updateDeleteInfo func(obj Object, oplog *BaseOplog, info ProcessInfo) error, ) ([]*BaseOplog, error)
func (*BaseProtocolManager) HandleDeletePersonLog ¶
func (pm *BaseProtocolManager) HandleDeletePersonLog( oplog *BaseOplog, info ProcessInfo, origPerson Object, opData OpData, status types.Status, merkle *Merkle, setLogDB func(oplog *BaseOplog), postdelete func(id *types.PttID, oplog *BaseOplog, origPerson Object, opData OpData) error, updateDeleteInfo func(obj Object, oplog *BaseOplog, info ProcessInfo) error, ) ([]*BaseOplog, error)
func (*BaseProtocolManager) HandleEntityTerminal ¶
func (*BaseProtocolManager) HandleFailedCreateMediaLog ¶
func (pm *BaseProtocolManager) HandleFailedCreateMediaLog(oplog *BaseOplog) error
func (*BaseProtocolManager) HandleFailedCreateObjectLog ¶
func (pm *BaseProtocolManager) HandleFailedCreateObjectLog( oplog *BaseOplog, obj Object, prefailed func(obj Object, oplog *BaseOplog) error, ) error
HandleFailedCreateObjectLog handles failed create-object log.
- lock-obj.
- get obj, and return if unable to get the obj (already deleted)
- check validity.
- prefailed
- if not my object: remove blocks and the object.
- if my object: only set the status as failed.
func (*BaseProtocolManager) HandleFailedCreatePersonLog ¶
func (pm *BaseProtocolManager) HandleFailedCreatePersonLog( oplog *BaseOplog, person Object, prefailed func(obj Object, oplog *BaseOplog) error, ) error
HandleFailedCreatePersonLog handles failed create-person log (should never happen)
func (*BaseProtocolManager) HandleFailedDeleteEntityLog ¶
func (pm *BaseProtocolManager) HandleFailedDeleteEntityLog( oplog *BaseOplog, ) error
func (*BaseProtocolManager) HandleFailedDeleteMediaLog ¶
func (pm *BaseProtocolManager) HandleFailedDeleteMediaLog(oplog *BaseOplog) error
func (*BaseProtocolManager) HandleFailedDeleteObjectLog ¶
func (pm *BaseProtocolManager) HandleFailedDeleteObjectLog( oplog *BaseOplog, obj Object, ) error
func (*BaseProtocolManager) HandleFailedDeletePersonLog ¶
func (pm *BaseProtocolManager) HandleFailedDeletePersonLog( oplog *BaseOplog, person Object, ) error
func (*BaseProtocolManager) HandleFailedMasterOplog ¶
func (pm *BaseProtocolManager) HandleFailedMasterOplog(oplog *BaseOplog) error
func (*BaseProtocolManager) HandleFailedMemberOplog ¶
func (pm *BaseProtocolManager) HandleFailedMemberOplog(oplog *BaseOplog) error
func (*BaseProtocolManager) HandleFailedOpKeyOplog ¶
func (pm *BaseProtocolManager) HandleFailedOpKeyOplog(oplog *BaseOplog) error
func (*BaseProtocolManager) HandleFailedPersonLog ¶
func (pm *BaseProtocolManager) HandleFailedPersonLog( oplog *BaseOplog, person Object, ) error
func (*BaseProtocolManager) HandleFailedTransferPersonLog ¶
func (pm *BaseProtocolManager) HandleFailedTransferPersonLog( oplog *BaseOplog, person Object, ) error
func (*BaseProtocolManager) HandleFailedUpdateObjectLog ¶
func (pm *BaseProtocolManager) HandleFailedUpdateObjectLog( oplog *BaseOplog, obj Object, ) error
HandleFailedBoardOplogUpdateArticle handles failed update-article-oplog
- get article
- check validity
- handle fails
func (*BaseProtocolManager) HandleFailedUpdatePersonLog ¶
func (pm *BaseProtocolManager) HandleFailedUpdatePersonLog( oplog *BaseOplog, origPerson Object, ) error
func (*BaseProtocolManager) HandleFailedValidCreateMediaLog ¶
func (pm *BaseProtocolManager) HandleFailedValidCreateMediaLog(oplog *BaseOplog, info ProcessInfo) error
func (*BaseProtocolManager) HandleFailedValidCreateObjectLog ¶
func (pm *BaseProtocolManager) HandleFailedValidCreateObjectLog( oplog *BaseOplog, obj Object, prefailed func(obj Object, oplog *BaseOplog) error, ) error
HandleFailedCreateObjectLog handles failed create-object log.
- lock-obj.
- get obj, and return if unable to get the obj (already deleted)
- check validity.
- prefailed
- if not my object: remove blocks and the object.
- if my object: only set the status as failed.
func (*BaseProtocolManager) HandleFailedValidCreatePersonLog ¶
func (*BaseProtocolManager) HandleFailedValidDeleteEntityLog ¶
func (pm *BaseProtocolManager) HandleFailedValidDeleteEntityLog( oplog *BaseOplog, ) error
func (*BaseProtocolManager) HandleFailedValidDeleteObjectLog ¶
func (pm *BaseProtocolManager) HandleFailedValidDeleteObjectLog( oplog *BaseOplog, obj Object, info ProcessInfo, updateDeleteInfo func(obj Object, oplog *BaseOplog, info ProcessInfo) error, ) error
func (*BaseProtocolManager) HandleFailedValidDeletePersonLog ¶
func (pm *BaseProtocolManager) HandleFailedValidDeletePersonLog( oplog *BaseOplog, origPerson Object, ) error
func (*BaseProtocolManager) HandleFailedValidMasterOplog ¶
func (pm *BaseProtocolManager) HandleFailedValidMasterOplog(oplog *BaseOplog, processInfo ProcessInfo) error
func (*BaseProtocolManager) HandleFailedValidMemberOplog ¶
func (pm *BaseProtocolManager) HandleFailedValidMemberOplog(oplog *BaseOplog, processInfo ProcessInfo) error
func (*BaseProtocolManager) HandleFailedValidPersonLog ¶
func (pm *BaseProtocolManager) HandleFailedValidPersonLog( oplog *BaseOplog, person Object, ) error
func (*BaseProtocolManager) HandleFailedValidTransferPersonLog ¶
func (pm *BaseProtocolManager) HandleFailedValidTransferPersonLog( oplog *BaseOplog, origPerson Object, ) error
func (*BaseProtocolManager) HandleFailedValidUpdateObjectLog ¶
func (pm *BaseProtocolManager) HandleFailedValidUpdateObjectLog( oplog *BaseOplog, obj Object, info ProcessInfo, updateUpdateInfo func(obj Object, oplog *BaseOplog, opData OpData, origSyncInfo SyncInfo, info ProcessInfo) error, ) error
HandleFailedBoardOplogUpdateArticle handles failed update-article-oplog
- get article
- check validity
- handle fails
func (*BaseProtocolManager) HandleFailedValidUpdatePersonLog ¶
func (pm *BaseProtocolManager) HandleFailedValidUpdatePersonLog( oplog *BaseOplog, origPerson Object, ) error
func (*BaseProtocolManager) HandleForceSyncMasterOplog ¶
func (pm *BaseProtocolManager) HandleForceSyncMasterOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMasterOplogAck ¶
func (pm *BaseProtocolManager) HandleForceSyncMasterOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMasterOplogByMerkle ¶
func (pm *BaseProtocolManager) HandleForceSyncMasterOplogByMerkle(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMasterOplogByMerkleAck ¶
func (pm *BaseProtocolManager) HandleForceSyncMasterOplogByMerkleAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMasterOplogByOplogAck ¶
func (pm *BaseProtocolManager) HandleForceSyncMasterOplogByOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMedia ¶
func (pm *BaseProtocolManager) HandleForceSyncMedia( dataBytes []byte, peer *PttPeer, syncAckMsg OpType, ) error
func (*BaseProtocolManager) HandleForceSyncMediaAck ¶
func (*BaseProtocolManager) HandleForceSyncMemberOplog ¶
func (pm *BaseProtocolManager) HandleForceSyncMemberOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMemberOplogAck ¶
func (pm *BaseProtocolManager) HandleForceSyncMemberOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMemberOplogByMerkle ¶
func (pm *BaseProtocolManager) HandleForceSyncMemberOplogByMerkle(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMemberOplogByMerkleAck ¶
func (pm *BaseProtocolManager) HandleForceSyncMemberOplogByMerkleAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncMemberOplogByOplogAck ¶
func (pm *BaseProtocolManager) HandleForceSyncMemberOplogByOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleForceSyncObject ¶
func (*BaseProtocolManager) HandleForceSyncObjectAck ¶
func (*BaseProtocolManager) HandleForceSyncOplog ¶
func (*BaseProtocolManager) HandleForceSyncOplogAck ¶
func (pm *BaseProtocolManager) HandleForceSyncOplogAck( dataBytes []byte, peer *PttPeer, merkle *Merkle, info ProcessInfo, setDB func(oplog *BaseOplog), handleFailedValidOplog func(oplog *BaseOplog, info ProcessInfo) error, setNewestOplog func(log *BaseOplog) error, postprocessLogs func(info ProcessInfo, peer *PttPeer) error, newLogsMsg OpType, ) error
func (*BaseProtocolManager) HandleForceSyncOplogByMerkle ¶
func (*BaseProtocolManager) HandleForceSyncOplogByMerkleAck ¶
func (*BaseProtocolManager) HandleForceSyncOplogByOplogAck ¶
func (*BaseProtocolManager) HandleIdentifyPeer ¶
func (pm *BaseProtocolManager) HandleIdentifyPeer(dataBytes []byte, peer *PttPeer) error
HandleIdentifyPeer handles IdentifyPeer (acker)
func (*BaseProtocolManager) HandleIdentifyPeerAck ¶
func (pm *BaseProtocolManager) HandleIdentifyPeerAck(dataBytes []byte, peer *PttPeer) error
HandleIdentifyPeerAck handles IdentifyPeerAck
- if we've already know the user-id: return.
- try to cancel peer waiting for identification.
- have ptt to do FinishIdentifyPeer
func (*BaseProtocolManager) HandleLog0s ¶
func (pm *BaseProtocolManager) HandleLog0s(logs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error
func (*BaseProtocolManager) HandleMasterOplogs ¶
func (pm *BaseProtocolManager) HandleMasterOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error
func (*BaseProtocolManager) HandleMemberOplogs ¶
func (pm *BaseProtocolManager) HandleMemberOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error
func (*BaseProtocolManager) HandleMessage ¶
func (pm *BaseProtocolManager) HandleMessage(op OpType, dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleNonRegisteredMessage ¶
func (pm *BaseProtocolManager) HandleNonRegisteredMessage(op OpType, dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleOpKeyOplogs ¶
func (pm *BaseProtocolManager) HandleOpKeyOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error
func (*BaseProtocolManager) HandlePendingCreateMediaLogs ¶
func (pm *BaseProtocolManager) HandlePendingCreateMediaLogs( oplog *BaseOplog, info ProcessInfo, existsInInfo func(oplog *BaseOplog, info ProcessInfo) (bool, error), updateCreateInfo func(obj Object, oplog *BaseOplog, opData OpData, info ProcessInfo) error, ) (types.Bool, []*BaseOplog, error)
func (*BaseProtocolManager) HandlePendingCreateObjectLog ¶
func (pm *BaseProtocolManager) HandlePendingCreateObjectLog( oplog *BaseOplog, obj Object, opData OpData, info ProcessInfo, existsInInfo func(oplog *BaseOplog, info ProcessInfo) (bool, error), newObjWithOplog func(oplog *BaseOplog, opData OpData) Object, postcreate func(obj Object, oplog *BaseOplog) error, updateCreateInfo func(obj Object, oplog *BaseOplog, opData OpData, info ProcessInfo) error, ) (types.Bool, []*BaseOplog, error)
HandlePendingCreateObjectLog handles pending create-object log
func (*BaseProtocolManager) HandlePendingCreatePersonLog ¶
func (pm *BaseProtocolManager) HandlePendingCreatePersonLog( oplog *BaseOplog, person Object, opData OpData, ) (types.Bool, []*BaseOplog, error)
HandlePendingCreateObjectLog handles pending create-person log (should never happen)
func (*BaseProtocolManager) HandlePendingDeleteEntityLog ¶
func (pm *BaseProtocolManager) HandlePendingDeleteEntityLog( oplog *BaseOplog, info ProcessInfo, internalPendingStatus types.Status, pendingStatus types.Status, op OpType, opData OpData, merkle *Merkle, setLogDB func(oplog *BaseOplog), setPendingDeleteSyncInfo func(entity Entity, status types.Status, oplog *BaseOplog) error, updateDeleteInfo func(oplog *BaseOplog, info ProcessInfo) error, ) (types.Bool, []*BaseOplog, error)
func (*BaseProtocolManager) HandlePendingDeleteObjectLog ¶
func (pm *BaseProtocolManager) HandlePendingDeleteObjectLog( oplog *BaseOplog, info ProcessInfo, obj Object, opData OpData, merkle *Merkle, setLogDB func(oplog *BaseOplog), removeMediaInfoByBlockInfo func(blockInfo *BlockInfo, info ProcessInfo, oplog *BaseOplog), setPendingDeleteSyncInfo func(origObj Object, status types.Status, oplog *BaseOplog) error, updateDeleteInfo func(obj Object, oplog *BaseOplog, info ProcessInfo) error, ) (types.Bool, []*BaseOplog, error)
func (*BaseProtocolManager) HandlePendingDeletePersonLog ¶
func (pm *BaseProtocolManager) HandlePendingDeletePersonLog( oplog *BaseOplog, info ProcessInfo, origPerson Object, opData OpData, internalPendingStatus types.Status, pendingStatus types.Status, merkle *Merkle, setLogDB func(oplog *BaseOplog), updateDeleteInfo func(person Object, oplog *BaseOplog, info ProcessInfo) error, ) (types.Bool, []*BaseOplog, error)
func (*BaseProtocolManager) HandlePendingMasterOplogs ¶
func (pm *BaseProtocolManager) HandlePendingMasterOplogs(oplogs []*BaseOplog, peer *PttPeer) error
func (*BaseProtocolManager) HandlePendingMemberOplogs ¶
func (pm *BaseProtocolManager) HandlePendingMemberOplogs(oplogs []*BaseOplog, peer *PttPeer) error
func (*BaseProtocolManager) HandlePendingOpKeyOplogs ¶
func (pm *BaseProtocolManager) HandlePendingOpKeyOplogs(oplogs []*BaseOplog, peer *PttPeer) error
func (*BaseProtocolManager) HandlePendingTransferPersonLog ¶
func (pm *BaseProtocolManager) HandlePendingTransferPersonLog( oplog *BaseOplog, origPerson Object, opData *PersonOpTransferPerson, merkle *Merkle, statusInternalTransfer types.Status, statusPendingTransfer types.Status, statusTransferred types.Status, setLogDB func(oplog *BaseOplog), ) (types.Bool, []*BaseOplog, error)
func (*BaseProtocolManager) HandlePendingUpdateObjectLog ¶
func (pm *BaseProtocolManager) HandlePendingUpdateObjectLog( oplog *BaseOplog, opData OpData, obj Object, info ProcessInfo, merkle *Merkle, syncInfoFromOplog func(oplog *BaseOplog, opData OpData) (SyncInfo, error), setLogDB func(oplog *BaseOplog), removeMediaInfoByBlockInfo func(blockInfo *BlockInfo, info ProcessInfo, oplog *BaseOplog), postUpdate func(obj Object, oplog *BaseOplog) error, updateUpdateInfo func(obj Object, oplog *BaseOplog, opData OpData, origSyncInfo SyncInfo, info ProcessInfo) error, ) (types.Bool, []*BaseOplog, error)
func (*BaseProtocolManager) HandlePendingUpdatePersonLog ¶
func (*BaseProtocolManager) HandleSyncBlock ¶
func (*BaseProtocolManager) HandleSyncCreateBlockAck ¶
func (*BaseProtocolManager) HandleSyncCreateMedia ¶
func (pm *BaseProtocolManager) HandleSyncCreateMedia(dataBytes []byte, peer *PttPeer, syncAckMsg OpType) error
func (*BaseProtocolManager) HandleSyncCreateMediaAck ¶
func (*BaseProtocolManager) HandleSyncCreateMediaBlockAck ¶
func (*BaseProtocolManager) HandleSyncCreateObject ¶
func (*BaseProtocolManager) HandleSyncCreateObjectAck ¶
func (pm *BaseProtocolManager) HandleSyncCreateObjectAck( obj Object, peer *PttPeer, origObj Object, merkle *Merkle, setLogDB func(oplog *BaseOplog), updateCreateObject func(toObj Object, fromObj Object) error, postcreate func(obj Object, oplog *BaseOplog) error, broadcastLog func(oplog *BaseOplog) error, ) error
HandleSyncCreateObjectAck
We don't need to have updaateCreateObject as member-function of obj because we copy only the public members.
func (*BaseProtocolManager) HandleSyncCreateOpKey ¶
func (pm *BaseProtocolManager) HandleSyncCreateOpKey(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncCreateOpKeyAck ¶
func (pm *BaseProtocolManager) HandleSyncCreateOpKeyAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncCreateOpKeyAckObj ¶
func (pm *BaseProtocolManager) HandleSyncCreateOpKeyAckObj(opKey *KeyInfo, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncMasterOplog ¶
func (pm *BaseProtocolManager) HandleSyncMasterOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncMasterOplogAck ¶
func (pm *BaseProtocolManager) HandleSyncMasterOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncMasterOplogInvalid ¶
func (pm *BaseProtocolManager) HandleSyncMasterOplogInvalid(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncMediaBlock ¶
func (pm *BaseProtocolManager) HandleSyncMediaBlock( dataBytes []byte, peer *PttPeer, ackMsg OpType, ) error
func (*BaseProtocolManager) HandleSyncMemberOplog ¶
func (pm *BaseProtocolManager) HandleSyncMemberOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncMemberOplogAck ¶
func (pm *BaseProtocolManager) HandleSyncMemberOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncMemberOplogInvalid ¶
func (pm *BaseProtocolManager) HandleSyncMemberOplogInvalid(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncNewMasterOplog ¶
func (pm *BaseProtocolManager) HandleSyncNewMasterOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncNewMasterOplogAck ¶
func (pm *BaseProtocolManager) HandleSyncNewMasterOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncNewMemberOplog ¶
func (pm *BaseProtocolManager) HandleSyncNewMemberOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncNewMemberOplogAck ¶
func (pm *BaseProtocolManager) HandleSyncNewMemberOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncOpKeyOplog ¶
func (pm *BaseProtocolManager) HandleSyncOpKeyOplog(dataBytes []byte, peer *PttPeer, syncMsg OpType) error
func (*BaseProtocolManager) HandleSyncOplog ¶
func (pm *BaseProtocolManager) HandleSyncOplog( dataBytes []byte, peer *PttPeer, merkle *Merkle, forceSyncOplogMsg OpType, forceSyncOplogAckMsg OpType, invalidOplogMsg OpType, syncOplogAckMsg OpType, ) error
HandleSyncOplog: I received sync-oplog. (MerkleTreeList should be within the packet-limit.)
- get my merkle-tree-list.
- validate merkle tree
- SyncOplogAck
func (*BaseProtocolManager) HandleSyncOplogAck ¶
func (*BaseProtocolManager) HandleSyncOplogInvalid ¶
func (pm *BaseProtocolManager) HandleSyncOplogInvalid( dataBytes []byte, peer *PttPeer, merkle *Merkle, forceSyncOplogMsg OpType, ) error
HandleSyncOplogAckInvalid: I (the requester) received the msg that my oplogs are invalid.
- if the peer is PeerTypeMe or the peer is master: do Resync
- if I am the master (asked from non-master): invalid op
- (The peer is not the master) 3.1. if I am connecting to the master => get the master-peer and resync with the master.
- Try to connect to the master.
func (*BaseProtocolManager) HandleSyncOplogNewOplogs ¶
func (*BaseProtocolManager) HandleSyncOplogNewOplogsAck ¶
func (*BaseProtocolManager) HandleSyncPendingMasterOplog ¶
func (pm *BaseProtocolManager) HandleSyncPendingMasterOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncPendingMasterOplogAck ¶
func (pm *BaseProtocolManager) HandleSyncPendingMasterOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncPendingMemberOplog ¶
func (pm *BaseProtocolManager) HandleSyncPendingMemberOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncPendingMemberOplogAck ¶
func (pm *BaseProtocolManager) HandleSyncPendingMemberOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncPendingOpKeyOplog ¶
func (pm *BaseProtocolManager) HandleSyncPendingOpKeyOplog(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncPendingOpKeyOplogAck ¶
func (pm *BaseProtocolManager) HandleSyncPendingOpKeyOplogAck(dataBytes []byte, peer *PttPeer) error
func (*BaseProtocolManager) HandleSyncPendingOplog ¶
func (*BaseProtocolManager) HandleSyncPendingOplogAck ¶
func (*BaseProtocolManager) HandleSyncUpdateBlockAck ¶
func (*BaseProtocolManager) HandleSyncUpdateObject ¶
func (*BaseProtocolManager) HandleSyncUpdateObjectAck ¶
func (pm *BaseProtocolManager) HandleSyncUpdateObjectAck( obj Object, peer *PttPeer, origObj Object, merkle *Merkle, setLogDB func(oplog *BaseOplog), updateSyncInfo func(toSyncInfo SyncInfo, fromObj Object, oplog *BaseOplog) error, postupdate func(obj Object, oplog *BaseOplog) error, broadcastLog func(oplog *BaseOplog) error, ) error
func (*BaseProtocolManager) HandleTransferPersonLog ¶
func (pm *BaseProtocolManager) HandleTransferPersonLog( oplog *BaseOplog, origPerson Object, opData *PersonOpTransferPerson, merkle *Merkle, statusTransferred types.Status, setLogDB func(oplog *BaseOplog), posttransfer func(fromID *types.PttID, toID *types.PttID, person Object, oplog *BaseOplog, opData OpData) error, ) ([]*BaseOplog, error)
func (*BaseProtocolManager) HandleUpdateObjectLog ¶
func (pm *BaseProtocolManager) HandleUpdateObjectLog( oplog *BaseOplog, opData OpData, obj Object, info ProcessInfo, merkle *Merkle, syncInfoFromOplog func(oplog *BaseOplog, opData OpData) (SyncInfo, error), setLogDB func(oplog *BaseOplog), removeMediaInfoByBlockInfo func(blockInfo *BlockInfo, info ProcessInfo, oplog *BaseOplog), postupdate func(obj Object, oplog *BaseOplog) error, updateUpdateInfo func(obj Object, oplog *BaseOplog, opData OpData, origSyncInfo SyncInfo, info ProcessInfo) error, ) ([]*BaseOplog, error)
func (*BaseProtocolManager) HandleUpdatePersonLog ¶
func (*BaseProtocolManager) IdentifyPeer ¶
func (pm *BaseProtocolManager) IdentifyPeer(peer *PttPeer)
IdentifyPeer identifies the peer by providing the op-key of the pm (requester)
- generate salt
- initialize info in peer
- send data to peer
func (*BaseProtocolManager) IdentifyPeerAck ¶
func (pm *BaseProtocolManager) IdentifyPeerAck(data *IdentifyPeer, peer *PttPeer) error
IdentifyPeerAck acks IdentifyPeer. We need to pass to ptt to hide the sign-key of myEntity.
- return my data
- if we do not know the peer, do identify peer process.
func (*BaseProtocolManager) IntegrateOplog ¶
func (*BaseProtocolManager) InternalSign ¶
func (pm *BaseProtocolManager) InternalSign(oplog *BaseOplog) (bool, error)
func (*BaseProtocolManager) IsImportantPeer ¶
func (pm *BaseProtocolManager) IsImportantPeer(peer *PttPeer) bool
func (*BaseProtocolManager) IsJoinKeyHash ¶
func (pm *BaseProtocolManager) IsJoinKeyHash(hash *common.Address) bool
func (*BaseProtocolManager) IsMaster ¶
func (pm *BaseProtocolManager) IsMaster(id *types.PttID, isLocked bool) bool
func (*BaseProtocolManager) IsMember ¶
func (pm *BaseProtocolManager) IsMember(id *types.PttID, isLocked bool) bool
func (*BaseProtocolManager) IsMemberPeer ¶
func (pm *BaseProtocolManager) IsMemberPeer(peer *PttPeer) bool
func (*BaseProtocolManager) IsMyDevice ¶
func (pm *BaseProtocolManager) IsMyDevice(peer *PttPeer) bool
func (*BaseProtocolManager) IsPendingMember ¶
func (pm *BaseProtocolManager) IsPendingMember(id *types.PttID, isLocked bool) bool
func (*BaseProtocolManager) IsPendingPeer ¶
func (pm *BaseProtocolManager) IsPendingPeer(peer *PttPeer) bool
func (*BaseProtocolManager) IsStart ¶
func (pm *BaseProtocolManager) IsStart() bool
func (*BaseProtocolManager) IsSuspiciousID ¶
func (*BaseProtocolManager) IsValidOplog ¶
func (*BaseProtocolManager) JoinKeyList ¶
func (pm *BaseProtocolManager) JoinKeyList() []*KeyInfo
func (*BaseProtocolManager) LeaveEntity ¶
func (pm *BaseProtocolManager) LeaveEntity() (bool, error)
func (*BaseProtocolManager) LoadPeers ¶
func (pm *BaseProtocolManager) LoadPeers() error
func (*BaseProtocolManager) Log0Merkle ¶
func (pm *BaseProtocolManager) Log0Merkle() *Merkle
func (*BaseProtocolManager) MasterLog0Hash ¶
func (pm *BaseProtocolManager) MasterLog0Hash() []byte
func (*BaseProtocolManager) MasterMerkle ¶
func (pm *BaseProtocolManager) MasterMerkle() *Merkle
func (*BaseProtocolManager) MaybePostcreateEntity ¶
func (pm *BaseProtocolManager) MaybePostcreateEntity( oplog *BaseOplog, isForceNot bool, postcreate func(entity Entity) error, ) error
MaybePostcreateEntity checks the whether to do postcreate and does postcreate of the entity.
func (*BaseProtocolManager) MemberMerkle ¶
func (pm *BaseProtocolManager) MemberMerkle() *Merkle
func (*BaseProtocolManager) MigrateMaster ¶
func (pm *BaseProtocolManager) MigrateMaster(id *types.PttID) error
func (*BaseProtocolManager) MigrateMember ¶
func (*BaseProtocolManager) MyMemberLog ¶
func (pm *BaseProtocolManager) MyMemberLog() *MemberOplog
func (*BaseProtocolManager) NewMasterOplog ¶
func (*BaseProtocolManager) NewMasterOplogWithTS ¶
func (*BaseProtocolManager) NewMedia ¶
func (pm *BaseProtocolManager) NewMedia(theData CreateData) (Object, OpData, error)
func (*BaseProtocolManager) NewMemberOplog ¶
func (*BaseProtocolManager) NewMemberOplogWithTS ¶
func (*BaseProtocolManager) NewOpKey ¶
func (pm *BaseProtocolManager) NewOpKey(data CreateData) (Object, OpData, error)
func (*BaseProtocolManager) NewOpKeyOplog ¶
func (*BaseProtocolManager) NewOpKeyOplogWithTS ¶
func (*BaseProtocolManager) NewPeerCh ¶
func (pm *BaseProtocolManager) NewPeerCh() chan *PttPeer
func (*BaseProtocolManager) NoMorePeers ¶
func (pm *BaseProtocolManager) NoMorePeers() chan struct{}
func (*BaseProtocolManager) OpKeyList ¶
func (pm *BaseProtocolManager) OpKeyList() []*KeyInfo
func (*BaseProtocolManager) OpKeys ¶
func (pm *BaseProtocolManager) OpKeys() map[common.Address]*KeyInfo
func (*BaseProtocolManager) Peers ¶
func (pm *BaseProtocolManager) Peers() *PttPeerSet
func (*BaseProtocolManager) PostdeleteEntity ¶
func (pm *BaseProtocolManager) PostdeleteEntity(opData OpData, isForce bool) error
PostdeleteEntity deals with postdeleting entity.
Especially used in UnregisterMember and posttransferMember (with nil opData) and RevokeNode
func (*BaseProtocolManager) PostprocessPendingDeleteOplog ¶
func (pm *BaseProtocolManager) PostprocessPendingDeleteOplog(oplog *BaseOplog, toBroadcastLogs []*BaseOplog) []*BaseOplog
func (*BaseProtocolManager) Poststop ¶
func (pm *BaseProtocolManager) Poststop() error
func (*BaseProtocolManager) Prestart ¶
func (pm *BaseProtocolManager) Prestart() error
func (*BaseProtocolManager) Prestop ¶
func (pm *BaseProtocolManager) Prestop() error
func (*BaseProtocolManager) Ptt ¶
func (pm *BaseProtocolManager) Ptt() Ptt
func (*BaseProtocolManager) QuitSync ¶
func (pm *BaseProtocolManager) QuitSync() chan struct{}
func (*BaseProtocolManager) RegisterMaster ¶
func (pm *BaseProtocolManager) RegisterMaster(master *Master, isLocked bool, isSkipPtt bool) error
func (*BaseProtocolManager) RegisterMember ¶
func (pm *BaseProtocolManager) RegisterMember(member *Member, isLocked bool) error
func (*BaseProtocolManager) RegisterOpKey ¶
func (pm *BaseProtocolManager) RegisterOpKey(keyInfo *KeyInfo, isLocked bool) error
func (*BaseProtocolManager) RegisterPeer ¶
func (pm *BaseProtocolManager) RegisterPeer(peer *PttPeer, peerType PeerType, isLocked bool) (err error)
func (*BaseProtocolManager) RegisterPendingPeer ¶
func (pm *BaseProtocolManager) RegisterPendingPeer(peer *PttPeer, isLocked bool) error
func (*BaseProtocolManager) RemoveMediaInfosByOplog ¶
func (*BaseProtocolManager) RemoveOpKey ¶
func (*BaseProtocolManager) RemoveOpKeyFromHash ¶
func (*BaseProtocolManager) RenewOpKeySeconds ¶
func (pm *BaseProtocolManager) RenewOpKeySeconds() int64
func (*BaseProtocolManager) RevokeOpKey ¶
func (pm *BaseProtocolManager) RevokeOpKey(keyID *types.PttID) (bool, error)
func (*BaseProtocolManager) SaveNewEntityWithOplog ¶
func (pm *BaseProtocolManager) SaveNewEntityWithOplog(oplog *BaseOplog, isLocked bool, isForce bool) error
SaveNewEntityWithOplog sets and saves the status/UT of the newly created entity based on the oplog.
func (*BaseProtocolManager) SendDataToPeer ¶
func (pm *BaseProtocolManager) SendDataToPeer(op OpType, data interface{}, peer *PttPeer) error
func (*BaseProtocolManager) SendDataToPeerWithCode ¶
func (pm *BaseProtocolManager) SendDataToPeerWithCode(code CodeType, op OpType, data interface{}, peer *PttPeer) error
func (*BaseProtocolManager) SendDataToPeers ¶
func (pm *BaseProtocolManager) SendDataToPeers(op OpType, data interface{}, peerList []*PttPeer) error
func (*BaseProtocolManager) SetBlockInfoDB ¶
func (pm *BaseProtocolManager) SetBlockInfoDB(blockInfo *BlockInfo, objID *types.PttID)
func (*BaseProtocolManager) SetLog0DB ¶
func (pm *BaseProtocolManager) SetLog0DB(oplog *BaseOplog)
func (*BaseProtocolManager) SetMasterDB ¶
func (pm *BaseProtocolManager) SetMasterDB(oplog *BaseOplog)
func (*BaseProtocolManager) SetMasterLog0Hash ¶
func (pm *BaseProtocolManager) SetMasterLog0Hash(theBytes []byte) error
func (*BaseProtocolManager) SetMasterObjDB ¶
func (pm *BaseProtocolManager) SetMasterObjDB(master *Master)
func (*BaseProtocolManager) SetMasterOplogIsSync ¶
func (pm *BaseProtocolManager) SetMasterOplogIsSync(oplog *MasterOplog, isBroadcast bool) (bool, error)
func (*BaseProtocolManager) SetMediaDB ¶
func (pm *BaseProtocolManager) SetMediaDB(media *Media)
func (*BaseProtocolManager) SetMemberDB ¶
func (pm *BaseProtocolManager) SetMemberDB(oplog *BaseOplog)
func (*BaseProtocolManager) SetMemberObjDB ¶
func (pm *BaseProtocolManager) SetMemberObjDB(member *Member)
func (*BaseProtocolManager) SetMemberOplogIsSync ¶
func (pm *BaseProtocolManager) SetMemberOplogIsSync(oplog *MemberOplog, isBroadcast bool) (bool, error)
func (*BaseProtocolManager) SetMemberSyncTime ¶
func (pm *BaseProtocolManager) SetMemberSyncTime(ts types.Timestamp) error
func (*BaseProtocolManager) SetNewestCreateMediaLog ¶
func (pm *BaseProtocolManager) SetNewestCreateMediaLog(oplog *BaseOplog) (types.Bool, error)
func (*BaseProtocolManager) SetNewestCreateObjectLog ¶
func (pm *BaseProtocolManager) SetNewestCreateObjectLog( oplog *BaseOplog, obj Object, ) (types.Bool, error)
SetNewestCreateObjectLog sets newest create-object log.
- lock.
- get data.
- cmp 3.1. obj.UpdateLogID exists. 3.2. cmp obj.LogID and oplog.ID
func (*BaseProtocolManager) SetNewestDeleteEntityLog ¶
func (pm *BaseProtocolManager) SetNewestDeleteEntityLog( oplog *BaseOplog, ) (types.Bool, error)
SetNewestDeleteEntityLog sets the newest delete entity log. Utilizing SetNewestEntityLog as the underlying mechanism.
func (*BaseProtocolManager) SetNewestDeleteMediaLog ¶
func (pm *BaseProtocolManager) SetNewestDeleteMediaLog(oplog *BaseOplog) (types.Bool, error)
func (*BaseProtocolManager) SetNewestDeleteObjectLog ¶
func (*BaseProtocolManager) SetNewestDeletePersonLog ¶
func (pm *BaseProtocolManager) SetNewestDeletePersonLog( oplog *BaseOplog, person Object, ) (types.Bool, error)
SetNewestDeletePersonLog sets the newest delete person log. Utilizing SetNewestPersonLog as the underlying mechanism.
func (*BaseProtocolManager) SetNewestEntityLog ¶
func (pm *BaseProtocolManager) SetNewestEntityLog( oplog *BaseOplog, ) (types.Bool, error)
SetNewestEntityLog sets the newest entity log. Because of the nature of entity log, we just need to compare whether the oplog.ID is the same as entity.LogID
func (*BaseProtocolManager) SetNewestMasterLogID ¶
func (pm *BaseProtocolManager) SetNewestMasterLogID(id *types.PttID) error
func (*BaseProtocolManager) SetNewestMasterOplog ¶
func (pm *BaseProtocolManager) SetNewestMasterOplog(oplog *BaseOplog) error
func (*BaseProtocolManager) SetNewestMemberOplog ¶
func (pm *BaseProtocolManager) SetNewestMemberOplog(oplog *BaseOplog) error
func (*BaseProtocolManager) SetNewestOpKeyOplog ¶
func (pm *BaseProtocolManager) SetNewestOpKeyOplog(oplog *BaseOplog) error
func (*BaseProtocolManager) SetNewestPersonLog ¶
func (pm *BaseProtocolManager) SetNewestPersonLog( oplog *BaseOplog, person Object, ) (types.Bool, error)
SetNewestPersonLog sets the newest person log. Because of the nature of person log, we just need to compare whether the oplog.ID is the same as person.LogID.
func (*BaseProtocolManager) SetNewestTransferPersonLog ¶
func (pm *BaseProtocolManager) SetNewestTransferPersonLog( oplog *BaseOplog, obj Object, ) (types.Bool, error)
SetNewestTransferPersonLog sets the newest transfer person log. Utilizing SetNewestPersonLog as the underlying mechanism.
func (*BaseProtocolManager) SetNewestUpdateObjectLog ¶
func (pm *BaseProtocolManager) SetNewestUpdateObjectLog( oplog *BaseOplog, obj Object, ) (types.Bool, error)
SetNewestBoardOplogUpdateArticle set newestLogID in UpdateArticle
- get article.
- if Status > failed: return LogID
- return UpdateLogID
func (*BaseProtocolManager) SetNoMorePeers ¶
func (pm *BaseProtocolManager) SetNoMorePeers(noMorePeers chan struct{})
func (*BaseProtocolManager) SetOpKeyDB ¶
func (pm *BaseProtocolManager) SetOpKeyDB(oplog *BaseOplog)
func (*BaseProtocolManager) SetOpKeyObjDB ¶
func (pm *BaseProtocolManager) SetOpKeyObjDB(opKey *KeyInfo)
func (*BaseProtocolManager) SetOpKeyOplogIsSync ¶
func (pm *BaseProtocolManager) SetOpKeyOplogIsSync(oplog *OpKeyOplog, isBroadcast bool) (bool, error)
func (*BaseProtocolManager) SetOplog0 ¶
func (pm *BaseProtocolManager) SetOplog0(oplog *BaseOplog)
func (*BaseProtocolManager) SetOplogIDIsSync ¶
func (pm *BaseProtocolManager) SetOplogIDIsSync( logID *types.PttID, ) (*BaseOplog, error)
func (*BaseProtocolManager) SetOplogIsSync ¶
func (*BaseProtocolManager) SetOwnerID ¶
func (pm *BaseProtocolManager) SetOwnerID(ownerID *types.PttID, isLocked bool)
func (*BaseProtocolManager) SignOplog ¶
func (pm *BaseProtocolManager) SignOplog(oplog *BaseOplog) error
func (*BaseProtocolManager) SplitContentBlocks ¶
func (*BaseProtocolManager) SplitMediaBlocks ¶
func (*BaseProtocolManager) Start ¶
func (pm *BaseProtocolManager) Start() error
func (*BaseProtocolManager) Stop ¶
func (pm *BaseProtocolManager) Stop() error
func (*BaseProtocolManager) Sync ¶
func (pm *BaseProtocolManager) Sync(peer *PttPeer) error
func (*BaseProtocolManager) SyncBlock ¶
func (pm *BaseProtocolManager) SyncBlock(op OpType, syncBlockIDs []*SyncBlockID, peer *PttPeer) error
func (*BaseProtocolManager) SyncBlockAck ¶
func (pm *BaseProtocolManager) SyncBlockAck(ackMsg OpType, blocks []*Block, peer *PttPeer) error
func (*BaseProtocolManager) SyncCreateOpKey ¶
func (pm *BaseProtocolManager) SyncCreateOpKey(syncIDs []*SyncID, peer *PttPeer) error
func (*BaseProtocolManager) SyncMedia ¶
func (pm *BaseProtocolManager) SyncMedia(op OpType, syncIDs []*SyncID, peer *PttPeer) error
func (*BaseProtocolManager) SyncObject ¶
func (pm *BaseProtocolManager) SyncObject(op OpType, syncIDs []*SyncID, peer *PttPeer) error
func (*BaseProtocolManager) SyncObjectAck ¶
func (pm *BaseProtocolManager) SyncObjectAck(objs []Object, syncAckMsg OpType, peer *PttPeer) error
func (*BaseProtocolManager) SyncOpKeyOplog ¶
func (pm *BaseProtocolManager) SyncOpKeyOplog(peer *PttPeer, syncMsg OpType) error
func (*BaseProtocolManager) SyncOplog ¶
func (pm *BaseProtocolManager) SyncOplog(peer *PttPeer, merkle *Merkle, op OpType) error
SyncOplog: I initiate sync-oplog.
Expected merkle-tree-list length: 24 (hour) + 31 (day) + 12 (month) + n (year) (should be within the packet-limit)
func (*BaseProtocolManager) SyncOplogAck ¶
func (pm *BaseProtocolManager) SyncOplogAck( toSyncTime types.Timestamp, myToSyncTime types.Timestamp, merkle *Merkle, forceSyncOplogAckMsg OpType, syncOplogAckMsg OpType, peer *PttPeer, ) error
SyncOplogAck: sending SyncOplogAck. Passed validating the oplogs until toSyncTime.
=> get the merkleNodes with level as MerkleTreeLevelNow from offsetHoursTS to now (blocked). => Send the merkleNodes to the peer.
func (*BaseProtocolManager) SyncOplogInvalid ¶
func (pm *BaseProtocolManager) SyncOplogInvalid( peer *PttPeer, theirSyncTS types.Timestamp, mySyncTS types.Timestamp, fromSyncTS types.Timestamp, toSyncTS types.Timestamp, merkle *Merkle, forceSyncOplogMsg OpType, invalidOplogMsg OpType, ) error
SyncOplogAckInvalid: I (The receiver) Issuing that the sync-oplog is invalid (ValidateMerkleTree).
- check isToSyncPeer (The peer is considered as valid and I need to sync with them.)
- if isToSyncPeer: ResyncOplog (with resyncOp. I become the requester.)
- Send invalidOp to the peer (notify it that the oplog is invalid. the peer needs to do some action and resync the oplog.)
func (*BaseProtocolManager) SyncOplogInvalidByMerkle ¶
func (pm *BaseProtocolManager) SyncOplogInvalidByMerkle( myNewNodes []*MerkleNode, theirNewNodes []*MerkleNode, forceSyncOplogMsg OpType, forceSyncOplogAckMsg OpType, merkle *Merkle, peer *PttPeer, ) error
func (*BaseProtocolManager) SyncOplogNewOplogs ¶
func (pm *BaseProtocolManager) SyncOplogNewOplogs( syncOplogAck *SyncOplogAck, myNewKeys [][]byte, theirNewKeys [][]byte, peer *PttPeer, merkle *Merkle, myLastNode *MerkleNode, setDB func(oplog *BaseOplog), setNewestOplog func(log *BaseOplog) error, postsync func(peer *PttPeer) error, newLogsMsg OpType, ) error
func (*BaseProtocolManager) SyncOplogNewOplogsAck ¶
func (*BaseProtocolManager) SyncPendingMasterOplog ¶
func (pm *BaseProtocolManager) SyncPendingMasterOplog(peer *PttPeer) error
func (*BaseProtocolManager) SyncPendingMemberOplog ¶
func (pm *BaseProtocolManager) SyncPendingMemberOplog(peer *PttPeer) error
func (*BaseProtocolManager) SyncPendingOpKeyOplog ¶
func (pm *BaseProtocolManager) SyncPendingOpKeyOplog(peer *PttPeer) error
func (*BaseProtocolManager) SyncPendingOplog ¶
func (*BaseProtocolManager) SyncPendingOplogAck ¶
func (*BaseProtocolManager) SyncWG ¶
func (pm *BaseProtocolManager) SyncWG() *sync.WaitGroup
func (*BaseProtocolManager) ToRenewOpKeyTS ¶
func (pm *BaseProtocolManager) ToRenewOpKeyTS() (types.Timestamp, error)
func (*BaseProtocolManager) TransferMaster ¶
func (pm *BaseProtocolManager) TransferMaster(id *types.PttID) error
func (*BaseProtocolManager) TransferPerson ¶
func (pm *BaseProtocolManager) TransferPerson( fromID *types.PttID, toID *types.PttID, createOp OpType, origPerson Object, opData *PersonOpTransferPerson, merkle *Merkle, statusInternalTransfer types.Status, statusPendingTransfer types.Status, statusTransferred types.Status, setLogDB func(oplog *BaseOplog), newOplog func(objID *types.PttID, op OpType, opData OpData) (Oplog, error), signOplog func(oplog *BaseOplog, fromID *types.PttID, toID *types.PttID) error, setTransferPersonWithOplog func(person Object, oplog *BaseOplog) error, broadcastLog func(oplog *BaseOplog) error, posttransfer func(fromID *types.PttID, toID *types.PttID, person Object, oplog *BaseOplog, opData OpData) error, ) error
func (*BaseProtocolManager) TryCreateOpKeyInfo ¶
func (pm *BaseProtocolManager) TryCreateOpKeyInfo() error
func (*BaseProtocolManager) UnregisterMaster ¶
func (pm *BaseProtocolManager) UnregisterMaster(master *Master, isLocked bool) error
func (*BaseProtocolManager) UnregisterMember ¶
func (pm *BaseProtocolManager) UnregisterMember(member *Member, isLock bool, isPostdeleteEntity bool) error
UnregisterMember unregisters member. Possibly already did postdeleteEntity.
func (*BaseProtocolManager) UnregisterPeer ¶
func (*BaseProtocolManager) UnregisterPeerByOtherUserID ¶
func (*BaseProtocolManager) UpdateObject ¶
func (pm *BaseProtocolManager) UpdateObject( id *types.PttID, data UpdateData, updateOp OpType, origObj Object, opData OpData, merkle *Merkle, setLogDB func(oplog *BaseOplog), newOplog func(objID *types.PttID, op OpType, opData OpData) (Oplog, error), inupdate func(obj Object, data UpdateData, oplog *BaseOplog, opData OpData) (SyncInfo, error), removeMediaInfoByBlockInfo func(blockInfo *BlockInfo, info ProcessInfo, oplog *BaseOplog), broadcastLog func(oplog *BaseOplog) error, postupdate func(obj Object, oplog *BaseOplog) error, ) error
func (*BaseProtocolManager) UpdatePerson ¶
func (pm *BaseProtocolManager) UpdatePerson( id *types.PttID, addOp OpType, isForce bool, origPerson Object, opData OpData, merkle *Merkle, setLogDB func(oplog *BaseOplog), newOplog func(objID *types.PttID, op OpType, opData OpData) (Oplog, error), broadcastLog func(oplog *BaseOplog) error, postupdate func(obj Object, oplog *BaseOplog) error, ) (Object, *BaseOplog, error)
func (*BaseProtocolManager) ValidateIntegrateSign ¶
func (pm *BaseProtocolManager) ValidateIntegrateSign(oplog *BaseOplog, isLocked bool) error
type BasePtt ¶
type BasePtt struct {
// contains filtered or unexported fields
}
func NewPtt ¶
func NewPtt(ctx *ServiceContext, cfg *Config, myNodeID *discover.NodeID, myNodeKey *ecdsa.PrivateKey) (*BasePtt, error)
func (*BasePtt) AddJoinKey ¶
func (*BasePtt) AddNewPeer ¶
AddPeer adds a new peer. expected no user-id.
- validate peer as random.
- set peer type as random.
- check dial-entity
- if there is a corresponding entity for dial: identify peer.
func (*BasePtt) ApproveJoin ¶
ApproveJoin approves join (invitor)
func (*BasePtt) BEGetPeers ¶
func (p *BasePtt) BEGetPeers() ([]*BackendPeer, error)
func (*BasePtt) BEGetPttOplogList ¶
func (*BasePtt) CheckDialEntityAndIdentifyPeer ¶
func (*BasePtt) ClosePeers ¶
func (p *BasePtt) ClosePeers()
func (*BasePtt) CountEntities ¶
func (*BasePtt) CountPeers ¶
func (p *BasePtt) CountPeers() (*BackendCountPeers, error)
func (*BasePtt) DecryptData ¶
DecryptData decrypts data in ptt-layer. Reference: https://gist.github.com/stupidbodo/601b68bfef3449d1b8d9
func (*BasePtt) EncryptData ¶
EncryptData encrypts data in ptt-layer. Reference: https://gist.github.com/stupidbodo/601b68bfef3449d1b8d9
func (*BasePtt) EntityTerminal ¶
func (p *BasePtt) EntityTerminal(entity Entity, pm ProtocolManager, peer *PttPeer) error
func (*BasePtt) FinishIdentifyPeer ¶
func (*BasePtt) GenerateNodeInfo ¶
func (p *BasePtt) GenerateNodeInfo() func() interface{}
func (*BasePtt) GeneratePeerInfo ¶
func (*BasePtt) GenerateProtocols ¶
func (*BasePtt) GenerateRun ¶
GenerateRun generates run in Protocol (PttService) (No need to do sync in the ptt-layer for now, because there is no information needs to sync in the ptt-layer.)
- set up ptt-peer.
- peerWG.
- handle-peer.
func (*BasePtt) GetConfirmJoins ¶
func (p *BasePtt) GetConfirmJoins() ([]*BackendConfirmJoin, error)
func (*BasePtt) GetGitCommit ¶
func (*BasePtt) GetLastAnnounceP2PTS ¶
func (*BasePtt) GetMyEntity ¶
func (*BasePtt) GetMyService ¶
func (*BasePtt) GetPeerByUserID ¶
func (*BasePtt) GetPttOplogList ¶
func (p *BasePtt) GetPttOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*PttOplog, error)
gets the PttOplogs specifically from myEntity.
func (*BasePtt) GetVersion ¶
func (*BasePtt) HandleApproveJoin ¶
func (*BasePtt) HandleCodeEntityDeleted ¶
func (*BasePtt) HandleCodeIdentifyPeer ¶
func (*BasePtt) HandleCodeIdentifyPeerFail ¶
func (*BasePtt) HandleCodeIdentifyPeerWithMyID ¶
func (*BasePtt) HandleCodeIdentifyPeerWithMyIDAck ¶
func (*BasePtt) HandleCodeIdentifyPeerWithMyIDChallenge ¶
func (*BasePtt) HandleCodeIdentifyPeerWithMyIDChallengeAck ¶
func (*BasePtt) HandleCodeJoin ¶
func (*BasePtt) HandleCodeJoinAck ¶
func (*BasePtt) HandleCodeOp ¶
func (*BasePtt) HandleCodeOpCheckMember ¶
func (*BasePtt) HandleCodeOpCheckMemberAck ¶
func (*BasePtt) HandleCodeOpFail ¶
func (*BasePtt) HandleCodeRequestOpKey ¶
func (*BasePtt) HandleCodeRequestOpKeyAck ¶
func (*BasePtt) HandleCodeRequestOpKeyFail ¶
func (*BasePtt) HandleEntityTerminal ¶
func (*BasePtt) HandleIdentifyPeerAck ¶
func (p *BasePtt) HandleIdentifyPeerAck(entityID *types.PttID, data *IdentifyPeerAck, peer *PttPeer) error
HandleIdentifyPeerAck
func (*BasePtt) HandleIdentifyPeerFail ¶
func (*BasePtt) HandleIdentifyPeerWithMyID ¶
func (*BasePtt) HandleIdentifyPeerWithMyIDAck ¶
HandleIdentifyPeerWithMyIDAck
func (*BasePtt) HandleIdentifyPeerWithMyIDChallenge ¶
HandleIdentifyPeerWithMyIDChallenge handles IdentifyPeerWithMyIDChallenge (requester)
func (*BasePtt) HandleIdentifyPeerWithMyIDChallengeAck ¶
HandleIdentifyPeerWithMyIDChallengeAck handles IdentifyPeerWithMyIDChallengeAck (acker)
func (*BasePtt) HandleJoin ¶
func (*BasePtt) HandleJoinAckChallenge ¶
func (p *BasePtt) HandleJoinAckChallenge(dataBytes []byte, hash *common.Address, joinRequest *JoinRequest, peer *PttPeer) error
HandleJoinAckChallenge
func (*BasePtt) HandleJoinEntity ¶
func (p *BasePtt) HandleJoinEntity(dataBytes []byte, hash *common.Address, entity Entity, pm ProtocolManager, keyInfo *KeyInfo, peer *PttPeer) error
HandleJoinEntity
Recevied "join-entity" with revealed ID and Name. (invitor)
- if the entity auto-rejects the entity-id and node-id: => return err
- if the entity auto-approves the entity-id and node-id => do approve.
- put to confirm-queue.
func (*BasePtt) HandleMessage ¶
HandleMessage handles message
func (*BasePtt) HandleMessageWrapper ¶
HandleMessageWrapper
func (*BasePtt) HandleOpCheckMember ¶
func (*BasePtt) HandleOpCheckMemberAck ¶
func (*BasePtt) HandleOpFail ¶
func (*BasePtt) HandlePeer ¶
HandlePeer handles peer
- Basic handshake
- AddNewPeer (defer RemovePeer)
- init read/write
- for-loop handle-message
func (*BasePtt) HandleRequestOpKey ¶
func (*BasePtt) HandleRequestOpKeyAck ¶
func (*BasePtt) HandleRequestOpKeyFail ¶
func (*BasePtt) IdentifyPeer ¶
func (*BasePtt) IdentifyPeerAck ¶
IdentifyPeerAck
func (*BasePtt) IdentifyPeerFail ¶
IdentifyPeerFail acks PMIdentifyPeer as failed
func (*BasePtt) IdentifyPeerWithMyID ¶
IdentifyPeerWithMyID ask for identifying peer with providing my-id (requester)
func (*BasePtt) IdentifyPeerWithMyIDAck ¶
IdentifyPeerWithMyIDAck
func (*BasePtt) IdentifyPeerWithMyIDChallenge ¶
IdentifyPeerWithMyIDChallenge requests challenge to make sure the user-id (acker)
func (*BasePtt) IdentifyPeerWithMyIDChallengeAck ¶
func (p *BasePtt) IdentifyPeerWithMyIDChallengeAck(data *IdentifyPeer, peer *PttPeer) error
IdentifyPeerWithMyIDChallengeAck acks IdentifyPeerWithMyIDChallenge (requester)
func (*BasePtt) JoinAckChallenge ¶
func (p *BasePtt) JoinAckChallenge(keyInfo *KeyInfo, join *Join, peer *PttPeer, entity Entity) error
JoinAckChallenge acks join-challenge to show that I have the join-key. (invitor)
func (*BasePtt) JoinEntity ¶
func (p *BasePtt) JoinEntity(joinRequest *JoinRequest, joinAckChallenge *JoinAckChallenge, peer *PttPeer) error
JoinEntity confirmed the invitor from HandleJoinAckChallenge and requests joining the entity (joiner)
func (*BasePtt) MarshalData ¶
func (p *BasePtt) MarshalData(code CodeType, hash *common.Address, encData []byte) (*PttData, error)
MarshalData marshals the encrypted data based on ptt-protocol.
hash: entity-hash enc: encrypted-data
The purpose is to have checksum to ensure that the data is not randomly-modified (preventing machine-error)
func (*BasePtt) MarshalDataWithoutHash ¶
MarshalData marshals the encrypted data based on ptt-protocol.
hash: entity-hash enc: encrypted-data
The purpose is to have checksum to ensure that the data is not randomly-modified (preventing machine-error)
func (*BasePtt) MyNodeKey ¶
func (p *BasePtt) MyNodeKey() *ecdsa.PrivateKey
func (*BasePtt) MyNodeType ¶
func (*BasePtt) NoMorePeers ¶
func (p *BasePtt) NoMorePeers() chan struct{}
func (*BasePtt) NotifyNodeRestart ¶
func (*BasePtt) NotifyNodeStop ¶
func (*BasePtt) OpCheckMember ¶
func (*BasePtt) OpCheckMemberAck ¶
func (*BasePtt) RegisterEntity ¶
func (*BasePtt) RegisterEntityPeerWithOtherUserID ¶
func (*BasePtt) RegisterPeerToEntities ¶
RegisterPeerToEntities registers peer to all the existing entities (register-peer-to-ptt is already done in CheckPeerType / SetPeerType)
register to all the existing entities.
func (*BasePtt) RegisterService ¶
RegisterService registers service into ptt.
func (*BasePtt) RemoveJoinKey ¶
func (*BasePtt) RemoveOpKey ¶
func (*BasePtt) RemovePeer ¶
RemovePeer removes peer
- get reigsteredPeer
- unregister peer from entities
- unset peer type
- disconnect
func (*BasePtt) RequestOpKey ¶
func (*BasePtt) RequestOpKeyAck ¶
func (*BasePtt) RequestOpKeyByEntity ¶
func (*BasePtt) RequestOpKeyFail ¶
func (*BasePtt) ResetPeerType ¶
func (*BasePtt) SendDataToPeer ¶
func (*BasePtt) SetMyEntity ¶
func (p *BasePtt) SetMyEntity(myEntity PttMyEntity) error
func (*BasePtt) SetPeerType ¶
SetPeerType sets the peer to the new peer-type and set in ptt peer-map.
func (*BasePtt) ToConfirmJoin ¶
func (p *BasePtt) ToConfirmJoin(confirmKey []byte, entity Entity, joinEntity *JoinEntity, keyInfo *KeyInfo, peer *PttPeer, joinType JoinType) error
ToConfirmJoin puts the joinEntity into confirm-join-map and wait for confirming the join. (invitor)
func (*BasePtt) TryJoin ¶
func (p *BasePtt) TryJoin(challenge []byte, hash *common.Address, key *ecdsa.PrivateKey, request *JoinRequest) error
TryJoin trys to do join (joiner)
If the nodeID is my node: return err because we dont join entity from our devices
If the nodeID is my peer: do join.
Else: do add peer.
func (*BasePtt) UnlockJoins ¶
func (p *BasePtt) UnlockJoins()
func (*BasePtt) UnmarshalData ¶
UnmarshalData unmarshal the pttData to the original data
func (*BasePtt) UnregisterEntity ¶
func (*BasePtt) UnregisterPeerFromEntities ¶
UnregisterPeerFromEntities unregisters the peer from all the existing entities.
func (*BasePtt) UnsetPeerType ¶
UnsetPeerType unsets the peer from the ptt peer-map.
type BaseService ¶
type BaseService struct {
// contains filtered or unexported fields
}
BaseService implements the base-type of Service
func NewBaseService ¶
func NewBaseService(ptt Ptt, spm ServiceProtocolManager) (*BaseService, error)
func (*BaseService) APIs ¶
func (svc *BaseService) APIs() []rpc.API
func (*BaseService) CountPeers ¶
func (svc *BaseService) CountPeers(entityIDBytes []byte) (int, error)
func (*BaseService) EntityIDToEntity ¶
func (svc *BaseService) EntityIDToEntity(entityIDBytes []byte) (Entity, error)
func (*BaseService) EntityIDToPM ¶
func (svc *BaseService) EntityIDToPM(entityIDBytes []byte) (ProtocolManager, error)
func (*BaseService) ForceOpKey ¶
func (b *BaseService) ForceOpKey(entityIDBytes []byte) (bool, error)
func (*BaseService) ForceSyncMasterMerkle ¶
func (svc *BaseService) ForceSyncMasterMerkle(entityIDBytes []byte) (bool, error)
func (*BaseService) ForceSyncMemberMerkle ¶
func (svc *BaseService) ForceSyncMemberMerkle(entityIDBytes []byte) (bool, error)
func (*BaseService) GetMasterList ¶
func (*BaseService) GetMasterListFromCache ¶
func (svc *BaseService) GetMasterListFromCache(entityIDBytes []byte) ([]*Master, error)
func (*BaseService) GetMasterOplogList ¶
func (svc *BaseService) GetMasterOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error)
func (*BaseService) GetMasterOplogMerkleNodeList ¶
func (svc *BaseService) GetMasterOplogMerkleNodeList(entityIDBytes []byte, level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*BackendMerkleNode, error)
func (*BaseService) GetMemberList ¶
func (*BaseService) GetMemberOplogList ¶
func (svc *BaseService) GetMemberOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error)
func (*BaseService) GetMemberOplogMerkleNodeList ¶
func (svc *BaseService) GetMemberOplogMerkleNodeList(entityIDBytes []byte, level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*BackendMerkleNode, error)
func (*BaseService) GetMyMemberLog ¶
func (b *BaseService) GetMyMemberLog(entityIDBytes []byte) (*BaseOplog, error)
func (*BaseService) GetOpKeyOplogList ¶
func (svc *BaseService) GetOpKeyOplogList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error)
func (*BaseService) GetOpKeys ¶
func (svc *BaseService) GetOpKeys(entityIDBytes []byte) ([]*KeyInfo, error)
func (*BaseService) GetOpKeysFromDB ¶
func (svc *BaseService) GetOpKeysFromDB(entityIDBytes []byte) ([]*KeyInfo, error)
func (*BaseService) GetPeers ¶
func (svc *BaseService) GetPeers(entityIDBytes []byte) ([]*BackendPeer, error)
func (*BaseService) GetPendingMasterOplogInternalList ¶
func (svc *BaseService) GetPendingMasterOplogInternalList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error)
func (*BaseService) GetPendingMasterOplogMasterList ¶
func (svc *BaseService) GetPendingMasterOplogMasterList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MasterOplog, error)
func (*BaseService) GetPendingMemberOplogInternalList ¶
func (svc *BaseService) GetPendingMemberOplogInternalList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error)
func (*BaseService) GetPendingMemberOplogMasterList ¶
func (svc *BaseService) GetPendingMemberOplogMasterList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*MemberOplog, error)
func (*BaseService) GetPendingOpKeyOplogInternalList ¶
func (svc *BaseService) GetPendingOpKeyOplogInternalList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error)
func (*BaseService) GetPendingOpKeyOplogMasterList ¶
func (svc *BaseService) GetPendingOpKeyOplogMasterList(entityIDBytes []byte, logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*OpKeyOplog, error)
func (*BaseService) LeaveEntity ¶
func (b *BaseService) LeaveEntity(entityIDBytes []byte) (bool, error)
func (*BaseService) Prestart ¶
func (svc *BaseService) Prestart() error
func (*BaseService) Ptt ¶
func (svc *BaseService) Ptt() Ptt
func (*BaseService) RevokeOpKey ¶
func (*BaseService) SPM ¶
func (svc *BaseService) SPM() ServiceProtocolManager
func (*BaseService) ShowValidateKey ¶
func (svc *BaseService) ShowValidateKey() (*types.PttID, error)
func (*BaseService) Start ¶
func (svc *BaseService) Start() error
func (*BaseService) Stop ¶
func (svc *BaseService) Stop() error
func (*BaseService) ValidateValidateKey ¶
func (svc *BaseService) ValidateValidateKey(keyBytes []byte) (bool, error)
type BaseServiceProtocolManager ¶
type BaseServiceProtocolManager struct {
// contains filtered or unexported fields
}
func NewBaseServiceProtocolManager ¶
func NewBaseServiceProtocolManager(ptt Ptt, service Service) (*BaseServiceProtocolManager, error)
func (*BaseServiceProtocolManager) CreateEntity ¶
func (spm *BaseServiceProtocolManager) CreateEntity( data CreateData, createOp OpType, newEntity func(data CreateData, ptt Ptt, service Service) (Entity, OpData, error), newOplogWithTS func(objID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error), increate func(entity Entity, oplog *BaseOplog, opData OpData) error, postcreate func(entity Entity) error, ) (Entity, error)
CreateEntity creates the entity. CreateEntity is from SPM, while CreateObject and CreateMember is from PM.
- new entity.
- add master. 2.1. add member.
- oplog.
- increate.
- force-sign oplog.
- entity-save. 6.1. SPM register entity.
- oplog-save.
- post-save 8.1. create op-key. 8.2. prestart and start. 8.3. postcreate.
func (*BaseServiceProtocolManager) CreateJoinEntity ¶
func (spm *BaseServiceProtocolManager) CreateJoinEntity( approveJoin *ApproveJoinEntity, peer *PttPeer, meLog *BaseOplog, isStart bool, isNew bool, isForceNotBroadcast bool, isLocked bool, isResetOwnerID bool, ) (Entity, error)
CreateJoinEntity joins the entity and creates the corresponding information. Like CreateEntity, CreateJoinEntity is from SPM.
- lock.
- check is new.
- set JoinTS
- entity-save
- entity-init.
- master-log.
- member-log. 7.1: register master again (to help ptt-layer determining the status of the peer).
- oplog0.
- op-key.
- spm-registering.
- register member.
- me-oplog.
func (*BaseServiceProtocolManager) DBObjLock ¶
func (spm *BaseServiceProtocolManager) DBObjLock() *types.LockMap
func (*BaseServiceProtocolManager) Entities ¶
func (spm *BaseServiceProtocolManager) Entities() map[types.PttID]Entity
func (*BaseServiceProtocolManager) Entity ¶
func (spm *BaseServiceProtocolManager) Entity(id *types.PttID) Entity
func (*BaseServiceProtocolManager) GetDBLock ¶
func (spm *BaseServiceProtocolManager) GetDBLock() *types.LockMap
func (*BaseServiceProtocolManager) GetDBLogLock ¶
func (spm *BaseServiceProtocolManager) GetDBLogLock() *types.LockMap
func (*BaseServiceProtocolManager) Lock ¶
func (spm *BaseServiceProtocolManager) Lock(id *types.PttID) error
Lock locks the entity-level lock.
func (*BaseServiceProtocolManager) NewEmptyEntity ¶
func (spm *BaseServiceProtocolManager) NewEmptyEntity() Entity
func (*BaseServiceProtocolManager) Prestart ¶
func (spm *BaseServiceProtocolManager) Prestart() error
func (*BaseServiceProtocolManager) PrestartEntities ¶
func (b *BaseServiceProtocolManager) PrestartEntities() error
func (*BaseServiceProtocolManager) Ptt ¶
func (spm *BaseServiceProtocolManager) Ptt() Ptt
func (*BaseServiceProtocolManager) RLock ¶
func (spm *BaseServiceProtocolManager) RLock(id *types.PttID) error
RLock rlocks the entity-level lock.
func (*BaseServiceProtocolManager) RUnlock ¶
func (spm *BaseServiceProtocolManager) RUnlock(id *types.PttID) error
RUnlock runlocks the entity-level lock.
func (*BaseServiceProtocolManager) RegisterEntity ¶
func (spm *BaseServiceProtocolManager) RegisterEntity(id *types.PttID, e Entity) error
RegisterEntity register the entity to the service
need to do lock in the beginning because need to update entitiesByPeerID
func (*BaseServiceProtocolManager) Service ¶
func (spm *BaseServiceProtocolManager) Service() Service
func (*BaseServiceProtocolManager) Start ¶
func (spm *BaseServiceProtocolManager) Start() error
func (*BaseServiceProtocolManager) StartEntities ¶
func (b *BaseServiceProtocolManager) StartEntities() error
func (*BaseServiceProtocolManager) Stop ¶
func (spm *BaseServiceProtocolManager) Stop() error
func (*BaseServiceProtocolManager) StopEntities ¶
func (b *BaseServiceProtocolManager) StopEntities() error
func (*BaseServiceProtocolManager) Unlock ¶
func (spm *BaseServiceProtocolManager) Unlock(id *types.PttID) error
Unlock unlocks the entity-level lock.
func (*BaseServiceProtocolManager) UnregisterEntity ¶
func (spm *BaseServiceProtocolManager) UnregisterEntity(id *types.PttID) error
type BaseSyncInfo ¶
type BaseSyncInfo struct { LogID *types.PttID `json:"l"` UpdateTS types.Timestamp `json:"UT"` UpdaterID *types.PttID `json:"UID"` Status types.Status `json:"S"` BlockInfo *BlockInfo `json:"b,omitempty"` IsGood types.Bool `json:"g"` IsAllGood types.Bool `json:"a"` }
func (*BaseSyncInfo) CheckIsAllGood ¶
func (s *BaseSyncInfo) CheckIsAllGood() types.Bool
func (*BaseSyncInfo) GetBlockInfo ¶
func (s *BaseSyncInfo) GetBlockInfo() *BlockInfo
func (*BaseSyncInfo) GetIsAllGood ¶
func (s *BaseSyncInfo) GetIsAllGood() types.Bool
func (*BaseSyncInfo) GetIsGood ¶
func (s *BaseSyncInfo) GetIsGood() types.Bool
func (*BaseSyncInfo) GetLogID ¶
func (s *BaseSyncInfo) GetLogID() *types.PttID
func (*BaseSyncInfo) GetStatus ¶
func (s *BaseSyncInfo) GetStatus() types.Status
func (*BaseSyncInfo) GetUpdateTS ¶
func (s *BaseSyncInfo) GetUpdateTS() types.Timestamp
func (*BaseSyncInfo) GetUpdaterID ¶
func (s *BaseSyncInfo) GetUpdaterID() *types.PttID
func (*BaseSyncInfo) InitWithOplog ¶
func (s *BaseSyncInfo) InitWithOplog(status types.Status, oplog *BaseOplog)
func (*BaseSyncInfo) SetBlockInfo ¶
func (s *BaseSyncInfo) SetBlockInfo(blockInfo *BlockInfo) error
func (*BaseSyncInfo) SetIsAllGood ¶
func (s *BaseSyncInfo) SetIsAllGood(isAllGood types.Bool)
func (*BaseSyncInfo) SetIsGood ¶
func (s *BaseSyncInfo) SetIsGood(isGood types.Bool)
func (*BaseSyncInfo) SetLogID ¶
func (s *BaseSyncInfo) SetLogID(id *types.PttID)
func (*BaseSyncInfo) SetStatus ¶
func (s *BaseSyncInfo) SetStatus(status types.Status)
func (*BaseSyncInfo) SetUpdateTS ¶
func (s *BaseSyncInfo) SetUpdateTS(ts types.Timestamp)
func (*BaseSyncInfo) SetUpdaterID ¶
func (s *BaseSyncInfo) SetUpdaterID(id *types.PttID)
func (*BaseSyncInfo) ToObject ¶
func (s *BaseSyncInfo) ToObject(obj Object) error
type Block ¶
type Block struct { V types.Version ID *types.PttID BlockID uint32 `json:"bID"` SubBlockID uint8 `json:"sID"` Buf []byte `json:"B,omitempty"` ObjID *types.PttID `json:"o,omitempty"` Hash []byte `json:"H,omitempty"` Salt types.Salt `json:"s,omitempty"` Sig []byte `json:"S,omitempty"` Pub []byte `json:"K,omitempty"` KeyExtra *KeyExtraInfo `json:"k,omitempty"` // contains filtered or unexported fields }
func GetBlockList ¶
GetBlockList gets the block list based on the information of block-info.
Always getting all blocks with pttdb.ListOrderNext
func NewEmptyBlock ¶
func NewEmptyBlock() *Block
func (*Block) MarshalKey ¶
type BlockInfo ¶
type BlockInfo struct { V types.Version ID *types.PttID `json:"ID,omitempty"` NBlock int `json:"N"` Hashs [][][]byte `json:"H,omitempty"` IsGood types.BoolDoubleArray `json:"G,omitempty"` IsAllGood types.Bool `json:"g"` MediaIDs []*types.PttID `json:"M,omitempty"` UpdaterID *types.PttID `json:"U"` // contains filtered or unexported fields }
func NewBlockInfo ¶
func (*BlockInfo) GetBlockIterWithBlockInfo ¶
func (*BlockInfo) GetIsAllGood ¶
func (*BlockInfo) InitIsGood ¶
func (b *BlockInfo) InitIsGood()
func (*BlockInfo) ResetIsGood ¶
func (b *BlockInfo) ResetIsGood()
func (*BlockInfo) SetBlockDB ¶
func (*BlockInfo) SetIsAllGood ¶
func (b *BlockInfo) SetIsAllGood()
func (*BlockInfo) VerifyBlock ¶
type CodeType ¶
type CodeType uint64
CodeType
const ( CodeTypeInvalid CodeType = iota CodeTypeStatus CodeTypeJoin CodeTypeJoinAck CodeTypeOp CodeTypeOpAck CodeTypeRequireHash // require hash CodeTypeOpFail CodeTypeRequestOpKey CodeTypeRequestOpKeyAck CodeTypeRequestOpKeyFail CodeTypeEntityDeleted CodeTypeIdentifyPeer CodeTypeIdentifyPeerAck CodeTypeIdentifyPeerFail CodeTypeIdentifyPeerWithMyID CodeTypeIdentifyPeerWithMyIDChallenge CodeTypeIdentifyPeerWithMyIDChallengeAck CodeTypeIdentifyPeerWithMyIDAck CodeTypeOpCheckMember CodeTypeOpCheckMemberAck NCodeType )
func UnmarshalCode ¶
type CommentType ¶
type CommentType int
comment type
const ( CommentTypePush CommentType = iota CommentTypeBoo CommentTypeNone )
func (*CommentType) Marshal ¶
func (c *CommentType) Marshal() []byte
type ConfirmJoin ¶
type ConfirmJoin struct { Entity Entity JoinEntity *JoinEntity KeyInfo *KeyInfo Peer *PttPeer UpdateTS types.Timestamp JoinType JoinType }
ConfirmJoin represents the data for the invitors to confirm the join
type ContentBlock ¶
func GetContentBlockList ¶
func GetContentBlockList(blockInfo *BlockInfo, limit uint32, isLocked bool) ([]*ContentBlock, error)
GetContentBlockList gets the block list based on the information of block-info.
Always getting all blocks with pttdb.ListOrderNext ¶
This is used for the main-content (article).
func NewContentBlock ¶
func NewContentBlock(blockID uint32, buf [][]byte) *ContentBlock
type ContentType ¶
type ContentType int
const ( ContentTypeArticle ContentType = iota ContentTypeComment ContentTypeReply )
type Count ¶
type Count struct { Bits types.BitVector `json:"B"` // bitvector to hold the occupied buckets // contains filtered or unexported fields }
func (*Count) Count ¶
Distinct returns the estimate of the number of distinct elements seen if the backing BitVector is full it returns m, the size of the BitVector
func (*Count) Intersect ¶
Intersect the estimate of two LinearCounting reducing the precision to the minimum of the two sets the function will return nil and an error if the hash functions mismatch
func (*Count) MarshalKey ¶
type CreateData ¶
type CreateData interface{}
type DialHistory ¶
type DialHistory struct {
// contains filtered or unexported fields
}
func NewDialHistory ¶
func NewDialHistory() *DialHistory
func (*DialHistory) Expire ¶
func (h *DialHistory) Expire()
func (*DialHistory) Pop ¶
func (h *DialHistory) Pop()
type DialHistoryHeap ¶
type DialHistoryHeap []*DialInfo
func (DialHistoryHeap) Len ¶
func (h DialHistoryHeap) Len() int
func (DialHistoryHeap) Less ¶
func (h DialHistoryHeap) Less(i, j int) bool
func (*DialHistoryHeap) Pop ¶
func (h *DialHistoryHeap) Pop() interface{}
func (*DialHistoryHeap) Push ¶
func (h *DialHistoryHeap) Push(x interface{})
func (DialHistoryHeap) Swap ¶
func (h DialHistoryHeap) Swap(i, j int)
type Entity ¶
type Entity interface { PrestartAndStart() error Prestart() error Start() error Stop() error GetUpdateTS() types.Timestamp SetUpdateTS(ts types.Timestamp) Save(isLocked bool) error Init(ptt Ptt, service Service, spm ServiceProtocolManager) error GetID() *types.PttID SetID(id *types.PttID) GetCreateTS() types.Timestamp SetCreateTS(ts types.Timestamp) GetCreatorID() *types.PttID SetJoinTS(ts types.Timestamp) GetUpdaterID() *types.PttID SetUpdaterID(id *types.PttID) GetLogID() *types.PttID SetLogID(id *types.PttID) GetUpdateLogID() *types.PttID SetUpdateLogID(id *types.PttID) GetMeLogTS() types.Timestamp SetMeLogTS(ts types.Timestamp) GetMeLogID() *types.PttID SetMeLogID(id *types.PttID) GetStatus() types.Status SetStatus(status types.Status) GetOwnerIDs() []*types.PttID AddOwnerID(id *types.PttID) ResetOwnerIDs() RemoveOwnerID(id *types.PttID) IsOwner(id *types.PttID) bool GetEntityType() EntityType SetEntityType(t EntityType) PM() ProtocolManager Ptt() Ptt Service() Service Name() string SetName(name string) DB() *pttdb.LDBBatch DBLock() *types.LockMap SetDB(db *pttdb.LDBBatch, dbLock *types.LockMap) MustLock() error Lock() error Unlock() error RLock() error RUnlock() error SetSyncInfo(syncInfo SyncInfo) GetSyncInfo() SyncInfo IDString() string }
Entity is the fundamental interface of entities. The reason why entity is not an object is because:
- Creating an entity does not require the consensus from other nodes.
- We may recover a deleted entity.
type EntityDeleted ¶
type EntityType ¶
type EntityType int
EntityType
const ( EntityTypeInvalid EntityType = iota EntityTypePersonal EntityTypePrivate EntityTypePublic )
type ForceSyncID ¶
func ProcessInfoToForceSyncIDList ¶
func ProcessInfoToForceSyncIDList(info map[types.PttID]*BaseOplog) []*ForceSyncID
type ForceSyncObject ¶
type ForceSyncObject struct {
IDs []*ForceSyncID
}
type ForceSyncOplog ¶
type ForceSyncOplogByMerkle ¶
type ForceSyncOplogByMerkle struct { UpdateTS types.Timestamp `json:"UT"` Level MerkleTreeLevel `json:"L"` Nodes []*MerkleNode `json:"K"` }
type ForceSyncOplogByMerkleAck ¶
type ForceSyncOplogByMerkleAck struct {
Nodes []*MerkleNode `json:"K"`
}
type ForceSyncOplogByOplogAck ¶
type ForceSyncOplogByOplogAck struct {
Oplogs []*BaseOplog `json:"O"`
}
type IdentifyPeer ¶
type IdentifyPeerAck ¶
type IdentifyPeerFail ¶
type IdentifyPeerWithMyID ¶
type IdentifyPeerWithMyIDChallengeAck ¶
type IdentifyPeerWithMyIDChallengeAck struct { Challenge *types.Salt `json:"C"` AckData *IdentifyPeerAck `json:"A"` }
type Join ¶
Join represents the info for the joiner initiating join. Asking challenge to be sure that the hash is really issued by the invitor.
type JoinAckChallenge ¶
type JoinAckChallenge struct { Challenge []byte `json:"C"` ID *types.PttID Name []byte `json:"N"` Master0Hash []byte `json:"H"` }
JoinAckChallenge represents the info for the invitor responding join by answering challenge.
type JoinEntity ¶
JoinEntity represents the info for the entity during join-process.
type JoinRequest ¶
type JoinRequest struct { CreatorID *types.PttID `json:"CID"` CreateTS types.Timestamp `json:"CT"` NodeID *discover.NodeID `json:"NID"` Hash *common.Address `json:"H"` Key *ecdsa.PrivateKey `json:"K"` Name []byte `json:"N"` Status JoinStatus `json:"S"` Master0Hash []byte `json:"M"` Challenge []byte `json:"C"` ID *types.PttID }
JoinRequest represents the info for the joiners to request the join
func ParseBackendJoinURL ¶
func ParseBackendJoinURL(urlBytes []byte, path string) (*JoinRequest, error)
type JoinRequestEvent ¶
type JoinRequestEvent struct { CreatorID *types.PttID `json:"CID"` Hash []byte `json:"H"` MyID *types.PttID `json:"MID"` }
JoinRequestEvent represents the info for the joiners sending to the invitors
func JoinRequestToJoinRequestEvent ¶
func JoinRequestToJoinRequestEvent(joinRequst *JoinRequest, myID *types.PttID) *JoinRequestEvent
type JoinStatus ¶
type JoinStatus int
const ( JoinStatusPending JoinStatus JoinStatusRequested JoinStatusWaitAccepted JoinStatusAccepted )
type KeyBIP32 ¶
type KeyBIP32 struct { Parent []byte `json:"P"` Salt *types.Salt `json:"S"` Child uint32 `json:"c"` }
KeyBIP32 represents the extra data for BIP32
type KeyExtraInfo ¶
type KeyExtraInfo struct { KeyType KeyType `json:"T"` Data interface{} `json:"D"` }
func (*KeyExtraInfo) GetData ¶
func (k *KeyExtraInfo) GetData(data interface{}) error
func (*KeyExtraInfo) IsValid ¶
func (k *KeyExtraInfo) IsValid(pubKeyBytes []byte, doerID *types.PttID) bool
func (*KeyExtraInfo) IsValidBIP32 ¶
func (k *KeyExtraInfo) IsValidBIP32(pubKeyBytes []byte, doerID *types.PttID) bool
type KeyInfo ¶
type KeyInfo struct { *BaseObject `json:"b"` Hash *common.Address `json:"H"` Key *ecdsa.PrivateKey `json:"-"` KeyBytes []byte `json:"K"` PubKeyBytes []byte `json:"-"` UpdateTS types.Timestamp `json:"UT"` Extra *KeyExtraInfo `json:"e,omitempty"` SyncInfo *BaseSyncInfo `json:"s,omitempty"` CreateLogID *types.PttID `json:"c,omitempty"` Count int `json:"-"` }
KeyInfo
func NewEmptyOpKey ¶
func NewEmptyOpKey() *KeyInfo
func NewOpKeyInfo ¶
func NewSignKeyInfo ¶
func ObjsToOpKeys ¶
func (*KeyInfo) GetNewObjByID ¶
func (*KeyInfo) GetSyncInfo ¶
func (*KeyInfo) GetUpdateTS ¶
func (*KeyInfo) Init ¶
func (k *KeyInfo) Init( pm ProtocolManager, ) error
func (*KeyInfo) MarshalKey ¶
func (*KeyInfo) NewEmptyObj ¶
func (*KeyInfo) RemoveMeta ¶
func (k *KeyInfo) RemoveMeta()
func (*KeyInfo) SetSyncInfo ¶
func (*KeyInfo) SetUpdateTS ¶
type LRUCount ¶
func NewLRUCount ¶
type Locale ¶
type Locale uint8
const ( LocaleTW Locale LocaleHK LocaleCN LocaleEN NLocale )
var ( DefaultLocale Locale = LocaleTW CurrentLocale Locale = DefaultLocale )
locale
func LoadLocale ¶
func LoadLocale() Locale
type Master ¶
type Master struct { *BaseObject `json:"b"` UpdateTS types.Timestamp `json:"UT"` TransferToID *types.PttID `json:"t,omitempty"` SyncInfo *SyncPersonInfo `json:"s,omitempty"` }
func NewEmptyMaster ¶
func NewEmptyMaster() *Master
func ObjsToMasters ¶
func (*Master) GetNewObjByID ¶
func (*Master) GetSyncInfo ¶
func (*Master) GetUpdateTS ¶
func (*Master) MarshalKey ¶
func (*Master) NewEmptyObj ¶
func (*Master) SetSyncInfo ¶
func (*Master) SetUpdateTS ¶
type MasterOpCreateMaster ¶
type MasterOpCreateMaster struct { }
type MasterOplog ¶
type MasterOplog struct {
*BaseOplog `json:"O"`
}
func NewMasterOplog ¶
func OplogToMasterOplog ¶
func OplogToMasterOplog(oplog *BaseOplog) *MasterOplog
func OplogsToMasterOplogs ¶
func OplogsToMasterOplogs(oplogs []*BaseOplog) []*MasterOplog
func (*MasterOplog) GetBaseOplog ¶
func (o *MasterOplog) GetBaseOplog() *BaseOplog
type Media ¶
type Media struct { *BaseObject `json:"b"` UpdateTS types.Timestamp `json:"UT"` SyncInfo *BaseSyncInfo `json:"s,omitempty"` MediaType MediaType `json:"T"` MediaData MediaData `json:"D,omitempty"` Buf []byte `json:"-"` }
func NewEmptyMedia ¶
func NewEmptyMedia() *Media
func ObjsToMedias ¶
func (*Media) GetNewObjByID ¶
func (*Media) GetSyncInfo ¶
func (*Media) GetUpdateTS ¶
func (*Media) MarshalKey ¶
func (*Media) NewEmptyObj ¶
func (*Media) SetBlockDB ¶
func (*Media) SetSyncInfo ¶
func (*Media) SetUpdateTS ¶
type MediaDataFile ¶
type MediaDataFile struct {
Filename []byte `json:"f"`
}
type MediaDataGIF ¶
type MediaDataJPEG ¶
type MediaDataPNG ¶
type Member ¶
type Member struct { *BaseObject `json:"b"` UpdateTS types.Timestamp `json:"UT"` TransferToID *types.PttID `json:"t,omitempty"` SyncInfo *SyncPersonInfo `json:"s,omitempty"` }
func NewEmptyMember ¶
func NewEmptyMember() *Member
func ObjsToMembers ¶
func (*Member) GetNewObjByID ¶
func (*Member) GetSyncInfo ¶
func (*Member) GetUpdateTS ¶
func (*Member) MarshalKey ¶
func (*Member) NewEmptyObj ¶
func (*Member) SetSyncInfo ¶
func (*Member) SetUpdateTS ¶
type MemberOpAddMember ¶
type MemberOpAddMember struct { }
type MemberOpDeleteMember ¶
type MemberOpDeleteMember struct { }
type MemberOplog ¶
type MemberOplog struct {
*BaseOplog `json:"O"`
}
func NewMemberOplog ¶
func OplogToMemberOplog ¶
func OplogToMemberOplog(oplog *BaseOplog) *MemberOplog
func OplogsToMemberOplogs ¶
func OplogsToMemberOplogs(oplogs []*BaseOplog) []*MemberOplog
func (*MemberOplog) GetBaseOplog ¶
func (o *MemberOplog) GetBaseOplog() *BaseOplog
type Merkle ¶
type Merkle struct { DBOplogPrefix []byte DBMerklePrefix []byte PrefixID *types.PttID LastGenerateTS types.Timestamp BusyGenerateTS types.Timestamp LastSyncTS types.Timestamp LastFailSyncTS types.Timestamp GenerateSeconds time.Duration ExpireGenerateSeconds int64 Name string // contains filtered or unexported fields }
Merkle is the representation / op of the merkle-tree-over-time for the oplog.
func (*Merkle) GetAndResetToUpdateTSList ¶
func (*Merkle) GetChildKeys ¶
func (*Merkle) GetChildNodes ¶
func (m *Merkle) GetChildNodes(level MerkleTreeLevel, ts types.Timestamp) ([]*MerkleNode, error)
func (*Merkle) GetMerkleIter ¶
func (*Merkle) GetMerkleIterByKey ¶
func (*Merkle) GetMerkleTreeList ¶
func (m *Merkle) GetMerkleTreeList(ts types.Timestamp, isNow bool) ([]*MerkleNode, []*MerkleNode, error)
Given the ts, retrieve the merkle until ts.
func (*Merkle) GetMerkleTreeListByLevel ¶
func (m *Merkle) GetMerkleTreeListByLevel(level MerkleTreeLevel, ts types.Timestamp, nextTS types.Timestamp) ([]*MerkleNode, error)
func (*Merkle) GetMerkleTreeListCore ¶
func (m *Merkle) GetMerkleTreeListCore(level MerkleTreeLevel, ts types.Timestamp, nextTS types.Timestamp) ([]*MerkleNode, error)
func (*Merkle) GetNodeByKey ¶
func (m *Merkle) GetNodeByKey(key []byte) (*MerkleNode, error)
func (*Merkle) GetNodeByLevelTS ¶
func (m *Merkle) GetNodeByLevelTS(level MerkleTreeLevel, ts types.Timestamp) (*MerkleNode, error)
func (*Merkle) LoadToUpdateTSs ¶
func (*Merkle) LoadUpdatingTSList ¶
func (*Merkle) MarshalFailSyncTimeKey ¶
func (*Merkle) MarshalGenerateTimeKey ¶
func (*Merkle) MarshalKey ¶
func (*Merkle) MarshalSyncTimeKey ¶
func (*Merkle) MarshalToUpdateTSKey ¶
func (*Merkle) MarshalUpdatingKey ¶
func (*Merkle) ResetUpdateTS ¶
func (*Merkle) ResetUpdatingTSList ¶
func (*Merkle) SaveMerkleTreeCore ¶
func (*Merkle) SetUpdateTS2 ¶
func (*Merkle) ToGenerateTime ¶
func (*Merkle) TryForceSync ¶
func (m *Merkle) TryForceSync(pm ProtocolManager) error
type MerkleNode ¶
type MerkleNode struct { Level MerkleTreeLevel `json:"L"` Addr []byte `json:"A"` UpdateTS types.Timestamp `json:"UT"` NChildren uint32 `json:"N"` Key []byte `json:"K"` }
func (*MerkleNode) ConstructUpdateTSAndLevelByKey ¶
func (m *MerkleNode) ConstructUpdateTSAndLevelByKey(key []byte) error
func (*MerkleNode) Marshal ¶
func (m *MerkleNode) Marshal() ([]byte, error)
func (*MerkleNode) MarshalJSON ¶
func (m *MerkleNode) MarshalJSON() ([]byte, error)
func (*MerkleNode) ToKey ¶
func (m *MerkleNode) ToKey(merkle *Merkle) []byte
func (*MerkleNode) Unmarshal ¶
func (m *MerkleNode) Unmarshal(b []byte) error
func (*MerkleNode) UnmarshalJSON ¶
func (m *MerkleNode) UnmarshalJSON(b []byte) error
func (*MerkleNode) UpdateTSToTS ¶
func (m *MerkleNode) UpdateTSToTS() types.Timestamp
type MerkleTreeLevel ¶
type MerkleTreeLevel uint8
const ( MerkleTreeLevelInvalid MerkleTreeLevel = iota MerkleTreeLevelNow MerkleTreeLevelHR MerkleTreeLevelDay MerkleTreeLevelMonth MerkleTreeLevelYear )
type MeteredMsgReadWriter ¶
type MeteredMsgReadWriter interface { p2p.MsgReadWriter Version() uint Init(version uint) error }
func NewBaseMeteredMsgReadWriter ¶
func NewBaseMeteredMsgReadWriter(rw p2p.MsgReadWriter, version uint) (MeteredMsgReadWriter, error)
type MyEntity ¶
type MyEntity interface { GetID() *types.PttID GetStatus() types.Status PM() ProtocolManager Name() string NewOpKeyInfo(entityID *types.PttID, setOpKeyObjDB func(k *KeyInfo)) (*KeyInfo, error) GetProfile() Entity GetBoard() Entity GetNodeSignID() *types.PttID GetUserNodeID(id *types.PttID) (*discover.NodeID, error) Sign(oplog *BaseOplog) error InternalSign(oplog *BaseOplog) error MasterSign(oplog *BaseOplog) error SignBlock(block *Block) error IsValidInternalOplog(signInfos []*SignInfo) (*types.PttID, uint32, bool) CreateEntityOplog(entity Entity) error CreateJoinEntityOplog(entity Entity) error GetValidateKey() *types.PttID }
type MyProtocolManager ¶
type MyProtocolManager interface { ProtocolManager SetMeDB(log *BaseOplog) SetMasterDB(log *BaseOplog) }
type MyPtt ¶
type MyPtt interface { Ptt NotifyNodeRestart() *types.Chan NotifyNodeStop() *types.Chan SetMyEntity(m PttMyEntity) error MyRaftID() uint64 MyNodeType() NodeType MyNodeKey() *ecdsa.PrivateKey SetPeerType(peer *PttPeer, peerType PeerType, isForce bool, isLocked bool) error SetupPeer(peer *PttPeer, peerType PeerType, isLocked bool) error GetEntities() map[types.PttID]Entity }
type Object ¶
type Object interface { Save(isLocked bool) error NewEmptyObj() Object GetBaseObject() *BaseObject GetByID(isLocked bool) error GetNewObjByID(id *types.PttID, isLocked bool) (Object, error) Unmarshal(theBytes []byte) error SetUpdateTS(ts types.Timestamp) GetUpdateTS() types.Timestamp RemoveMeta() // data GetBlockInfo() *BlockInfo SetBlockInfo(blockInfo *BlockInfo) error // sync-info GetSyncInfo() SyncInfo SetSyncInfo(syncInfo SyncInfo) error SetDB( db *pttdb.LDBBatch, dbLock *types.LockMap, entityID *types.PttID, fullDBPrefix []byte, fullDBIdxPrefix []byte, setBlockDB func(blockInfo *BlockInfo, objID *types.PttID), setMediaDB func(media *Media), ) Lock() error Unlock() error RLock() error RUnlock() error SetVersion(v types.Version) SetCreateTS(ts types.Timestamp) GetCreateTS() types.Timestamp SetCreatorID(id *types.PttID) GetCreatorID() *types.PttID SetUpdaterID(id *types.PttID) GetUpdaterID() *types.PttID SetID(id *types.PttID) GetID() *types.PttID SetLogID(id *types.PttID) GetLogID() *types.PttID GetNewestLogID() *types.PttID SetUpdateLogID(id *types.PttID) GetUpdateLogID() *types.PttID SetStatus(status types.Status) GetStatus() types.Status SetEntityID(id *types.PttID) GetEntityID() *types.PttID SetIsGood(isGood types.Bool) GetIsGood() types.Bool SetIsAllGood(isAllGood types.Bool) GetIsAllGood() types.Bool CheckIsAllGood() types.Bool Delete(isLocked bool) error GetKey(id *types.PttID, isLocked bool) ([]byte, error) }
func AliveObjects ¶
func GetObjList ¶
func MastersToObjs ¶
func MediasToObjs ¶
func MembersToObjs ¶
func OpKeysToObjs ¶
type OpCheckMember ¶
type OpCheckMemberAck ¶
type OpCreateMedia ¶
type OpDeleteMedia ¶
type OpDeleteMedia struct{}
type OpKeyOpCreateOpKey ¶
type OpKeyOpCreateOpKey struct { }
type OpKeyOpRevokeOpKey ¶
type OpKeyOpRevokeOpKey struct { }
type OpKeyOplog ¶
type OpKeyOplog struct {
*BaseOplog `json:"O"`
}
func NewOpKeyOplog ¶
func OplogToOpKeyOplog ¶
func OplogToOpKeyOplog(oplog *BaseOplog) *OpKeyOplog
func OplogsToOpKeyOplogs ¶
func OplogsToOpKeyOplogs(oplogs []*BaseOplog) []*OpKeyOplog
func (*OpKeyOplog) GetBaseOplog ¶
func (o *OpKeyOplog) GetBaseOplog() *BaseOplog
type OpType ¶
type OpType uint32
OpType
const ( JoinMsg OpType JoinAckChallengeMsg JoinEntityMsg ApproveJoinMsg JoinAlreadyRegisteredMsg JoinAckAlreadyRegistedMsg AddOpKeyOplogMsg // 7 AddOpKeyOplogsMsg AddPendingOpKeyOplogMsg AddPendingOpKeyOplogsMsg SyncOpKeyOplogMsg SyncOpKeyOplogAckMsg InvalidSyncOpKeyOplogMsg ForceSyncOpKeyOplogMsg ForceSyncOpKeyOplogAckMsg SyncPendingOpKeyOplogMsg SyncPendingOpKeyOplogAckMsg SyncCreateOpKeyMsg SyncCreateOpKeyAckMsg // master AddMasterOplogMsg // 17 AddMasterOplogsMsg AddPendingMasterOplogMsg AddPendingMasterOplogsMsg SyncMasterOplogMsg SyncMasterOplogAckMsg SyncMasterOplogNewOplogsMsg SyncMasterOplogNewOplogsAckMsg InvalidSyncMasterOplogMsg ForceSyncMasterOplogMsg ForceSyncMasterOplogAckMsg ForceSyncMasterOplogByMerkleMsg ForceSyncMasterOplogByMerkleAckMsg ForceSyncMasterOplogByOplogAckMsg SyncPendingMasterOplogMsg SyncPendingMasterOplogAckMsg // member AddMemberOplogMsg // 27 AddMemberOplogsMsg AddPendingMemberOplogMsg AddPendingMemberOplogsMsg SyncMemberOplogMsg SyncMemberOplogAckMsg SyncMemberOplogNewOplogsMsg SyncMemberOplogNewOplogsAckMsg InvalidSyncMemberOplogMsg ForceSyncMemberOplogMsg ForceSyncMemberOplogAckMsg ForceSyncMemberOplogByMerkleMsg ForceSyncMemberOplogByMerkleAckMsg ForceSyncMemberOplogByOplogAckMsg SyncPendingMemberOplogMsg SyncPendingMemberOplogAckMsg // peer IdentifyPeerMsg // 37 IdentifyPeerAckMsg BoardLastSeenMsg ArticleLastSeenMsg NMsg )
msg
const ( MasterOpTypeAddMaster OpType MasterOpTypeMigrateMaster MasterOpTypeTransferMaster )
const ( MemberOpTypeAddMember OpType MemberOpTypeDeleteMember MemberOpTypeMigrateMember )
const ( OpKeyOpTypeCreateOpKey OpType OpKeyOpTypeRevokeOpKey )
const ( PttOpTypeCreateMe OpType PttOpTypeCreateArticle PttOpTypeCreateComment PttOpTypeCreateReply PttOpTypeCreateFriend PttOpTypeJoinBoard )
func UnmarshalOp ¶
type PersonOpTransferPerson ¶
type PrivateAPI ¶
type PrivateAPI struct {
// contains filtered or unexported fields
}
func NewPrivateAPI ¶
func NewPrivateAPI(p *BasePtt) *PrivateAPI
func (*PrivateAPI) CountEntities ¶
func (api *PrivateAPI) CountEntities() (int, error)
func (*PrivateAPI) CountPeers ¶
func (api *PrivateAPI) CountPeers() (*BackendCountPeers, error)
func (*PrivateAPI) GetConfirmJoins ¶
func (api *PrivateAPI) GetConfirmJoins() ([]*BackendConfirmJoin, error)
func (*PrivateAPI) GetGitCommit ¶
func (api *PrivateAPI) GetGitCommit() (string, error)
func (*PrivateAPI) GetLastAnnounceP2PTS ¶
func (api *PrivateAPI) GetLastAnnounceP2PTS() (types.Timestamp, error)
func (*PrivateAPI) GetLocale ¶
func (api *PrivateAPI) GetLocale() (Locale, error)
func (*PrivateAPI) GetOffsetSecond ¶
func (api *PrivateAPI) GetOffsetSecond() (int64, error)
func (*PrivateAPI) GetPeers ¶
func (api *PrivateAPI) GetPeers() ([]*BackendPeer, error)
func (*PrivateAPI) GetPttOplogList ¶
func (*PrivateAPI) GetPttOplogSeen ¶
func (api *PrivateAPI) GetPttOplogSeen() (types.Timestamp, error)
func (*PrivateAPI) GetTimestamp ¶
func (api *PrivateAPI) GetTimestamp() (types.Timestamp, error)
func (*PrivateAPI) GetVersion ¶
func (api *PrivateAPI) GetVersion() (string, error)
func (*PrivateAPI) MarkPttOplogSeen ¶
func (api *PrivateAPI) MarkPttOplogSeen() (types.Timestamp, error)
func (*PrivateAPI) Restart ¶
func (api *PrivateAPI) Restart() (bool, error)
func (*PrivateAPI) SetOffsetSecond ¶
func (api *PrivateAPI) SetOffsetSecond(sec int64) (bool, error)
func (*PrivateAPI) Shutdown ¶
func (api *PrivateAPI) Shutdown() (bool, error)
type ProcessInfo ¶
type ProcessInfo interface{}
type ProcessOpKeyInfo ¶
type ProcessOpKeyInfo struct { CreateOpKeyInfo map[types.PttID]*BaseOplog DeleteOpKeyInfo map[types.PttID]*BaseOplog }
func NewProcessOpKeyInfo ¶
func NewProcessOpKeyInfo() *ProcessOpKeyInfo
type ProcessPersonInfo ¶
type ProcessPersonInfo struct { CreateInfo map[types.PttID]*BaseOplog DeleteInfo map[types.PttID]*BaseOplog }
func NewProcessPersonInfo ¶
func NewProcessPersonInfo() *ProcessPersonInfo
type ProtocolManager ¶
type ProtocolManager interface { Prestart() error Start() error Prestop() error Stop() error Poststop() error HandleNonRegisteredMessage(op OpType, dataBytes []byte, peer *PttPeer) error HandleMessage(op OpType, dataBytes []byte, peer *PttPeer) error Sync(peer *PttPeer) error LeaveEntity() (bool, error) Delete() error PostdeleteEntity(opData OpData, isForce bool) error FullCleanLog() // join ApproveJoin( joinEntity *JoinEntity, keyInfo *KeyInfo, peer *PttPeer, ) (*KeyInfo, interface{}, error) GetJoinType(hash *common.Address) (JoinType, error) // master MasterLog0Hash() []byte SetMasterLog0Hash(theBytes []byte) error AddMaster(id *types.PttID, isForce bool) (*Master, *MasterOplog, error) MigrateMaster(id *types.PttID) error TransferMaster(id *types.PttID) error IsMaster(id *types.PttID, isLocked bool) bool RegisterMaster(master *Master, isLocked bool, isSkipPtt bool) error AddMember(id *types.PttID, isForce bool) (*Member, *MemberOplog, error) MigrateMember(fromID *types.PttID, toID *types.PttID) error DeleteMember(id *types.PttID) (bool, error) // owner-id SetOwnerID(ownerID *types.PttID, isLocked bool) GetOwnerID(isLocked bool) *types.PttID // oplog BroadcastOplog(oplog *BaseOplog, msg OpType, pendingMsg OpType) error BroadcastOplogs(oplogs []*BaseOplog, msg OpType, pendingMsg OpType) error SignOplog(oplog *BaseOplog) error ForceSignOplog(oplog *BaseOplog) error IntegrateOplog(oplog *BaseOplog, isLocked bool, merkle *Merkle) (types.Bool, bool, error) InternalSign(oplog *BaseOplog) (bool, error) // peers IsMyDevice(peer *PttPeer) bool IsImportantPeer(peer *PttPeer) bool IsMemberPeer(peer *PttPeer) bool IsPendingPeer(peer *PttPeer) bool IsSuspiciousID(id *types.PttID, nodeID *discover.NodeID) bool IsGoodID(id *types.PttID, nodeID *discover.NodeID) bool LoadPeers() error // event-mux EventMux() *event.TypeMux // master SetNewestMasterLogID(id *types.PttID) error GetNewestMasterLogID() *types.PttID GetMasterListFromCache(isLocked bool) ([]*Master, error) GetMasterList(startID *types.PttID, limit int, listOrder pttdb.ListOrder, isLocked bool) ([]*Master, error) // master-oplog BroadcastMasterOplog(log *MasterOplog) error HandleAddMasterOplog(dataBytes []byte, peer *PttPeer) error HandleAddMasterOplogs(dataBytes []byte, peer *PttPeer) error HandleAddPendingMasterOplog(dataBytes []byte, peer *PttPeer) error HandleAddPendingMasterOplogs(dataBytes []byte, peer *PttPeer) error HandleSyncMasterOplog(dataBytes []byte, peer *PttPeer) error HandleForceSyncMasterOplog(dataBytes []byte, peer *PttPeer) error HandleForceSyncMasterOplogAck(dataBytes []byte, peer *PttPeer) error HandleForceSyncMasterOplogByMerkle(dataBytes []byte, peer *PttPeer) error HandleForceSyncMasterOplogByMerkleAck(dataBytes []byte, peer *PttPeer) error HandleForceSyncMasterOplogByOplogAck(dataBytes []byte, peer *PttPeer) error HandleSyncMasterOplogInvalid(dataBytes []byte, peer *PttPeer) error HandleSyncMasterOplogAck(dataBytes []byte, peer *PttPeer) error HandleSyncNewMasterOplog(dataBytes []byte, peer *PttPeer) error HandleSyncNewMasterOplogAck(dataBytes []byte, peer *PttPeer) error HandleSyncPendingMasterOplog(dataBytes []byte, peer *PttPeer) error HandleSyncPendingMasterOplogAck(dataBytes []byte, peer *PttPeer) error HandleMasterOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error GetMasterOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*MasterOplog, error) GetMasterOplogMerkleNodeList(level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*MerkleNode, error) ForceSyncMasterMerkle() (bool, error) GetMemberList(startID *types.PttID, limit int, listOrder pttdb.ListOrder, isLocked bool) ([]*Member, error) // member-oplog BroadcastMemberOplog(log *MemberOplog) error HandleAddMemberOplog(dataBytes []byte, peer *PttPeer) error HandleAddMemberOplogs(dataBytes []byte, peer *PttPeer) error HandleAddPendingMemberOplog(dataBytes []byte, peer *PttPeer) error HandleAddPendingMemberOplogs(dataBytes []byte, peer *PttPeer) error HandleSyncMemberOplog(dataBytes []byte, peer *PttPeer) error HandleForceSyncMemberOplog(dataBytes []byte, peer *PttPeer) error HandleForceSyncMemberOplogAck(dataBytes []byte, peer *PttPeer) error HandleForceSyncMemberOplogByMerkle(dataBytes []byte, peer *PttPeer) error HandleForceSyncMemberOplogByMerkleAck(dataBytes []byte, peer *PttPeer) error HandleForceSyncMemberOplogByOplogAck(dataBytes []byte, peer *PttPeer) error HandleSyncMemberOplogInvalid(dataBytes []byte, peer *PttPeer) error HandleSyncMemberOplogAck(dataBytes []byte, peer *PttPeer) error HandleSyncNewMemberOplog(dataBytes []byte, peer *PttPeer) error HandleSyncNewMemberOplogAck(dataBytes []byte, peer *PttPeer) error HandleSyncPendingMemberOplog(dataBytes []byte, peer *PttPeer) error HandleSyncPendingMemberOplogAck(dataBytes []byte, peer *PttPeer) error HandleMemberOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error SetMemberSyncTime(ts types.Timestamp) error GetMemberOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*MemberOplog, error) GetMemberOplogMerkleNodeList(level MerkleTreeLevel, startKey []byte, limit int, listOrder pttdb.ListOrder) ([]*MerkleNode, error) GetMemberLogByMemberID(id *types.PttID, isLocked bool) (*MemberOplog, error) MyMemberLog() *MemberOplog ForceSyncMemberMerkle() (bool, error) // log0 SetLog0DB(oplog *BaseOplog) Log0Merkle() *Merkle HandleLog0s(logs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error // join GetJoinKeyFromHash(hash *common.Address) (*KeyInfo, error) GetJoinKey() (*KeyInfo, error) CreateJoinKeyLoop() error JoinKeyList() []*KeyInfo GetOpKeyFromHash(hash *common.Address, isLocked bool) (*KeyInfo, error) GetNewestOpKey(isLocked bool) (*KeyInfo, error) GetOldestOpKey(isLocked bool) (*KeyInfo, error) RegisterOpKey(keyInfo *KeyInfo, isLocked bool) error RevokeOpKey(keyID *types.PttID) (bool, error) RemoveOpKeyFromHash(hash *common.Address, isLocked bool, isDeleteOplog bool, isDeleteDB bool) error OpKeys() map[common.Address]*KeyInfo OpKeyList() []*KeyInfo RenewOpKeySeconds() int64 ExpireOpKeySeconds() int64 GetToRenewOpKeySeconds() int ToRenewOpKeyTS() (types.Timestamp, error) DBOpKeyLock() *types.LockMap DBOpKey() *pttdb.LDBBatch DBOpKeyPrefix() []byte DBOpKeyIdxPrefix() []byte SetOpKeyDB(oplog *BaseOplog) SetOpKeyObjDB(opKey *KeyInfo) GetOpKeyListFromDB() ([]*KeyInfo, error) CreateOpKeyLoop() error CreateOpKey() error ForceCreateOpKey() error ForceOpKey() chan struct{} BroadcastOpKeyOplog(log *OpKeyOplog) error HandleAddOpKeyOplog(dataBytes []byte, peer *PttPeer) error HandleAddOpKeyOplogs(dataBytes []byte, peer *PttPeer) error HandleAddPendingOpKeyOplog(dataBytes []byte, peer *PttPeer) error HandleAddPendingOpKeyOplogs(dataBytes []byte, peer *PttPeer) error SyncOpKeyOplog(peer *PttPeer, syncMsg OpType) error HandleSyncOpKeyOplog(dataBytes []byte, peer *PttPeer, syncMsg OpType) error HandleSyncPendingOpKeyOplog(dataBytes []byte, peer *PttPeer) error HandleSyncPendingOpKeyOplogAck(dataBytes []byte, peer *PttPeer) error HandleOpKeyOplogs(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error HandleSyncCreateOpKey(dataBytes []byte, peer *PttPeer) error HandleSyncCreateOpKeyAck(dataBytes []byte, peer *PttPeer) error HandleSyncCreateOpKeyAckObj(opKey *KeyInfo, peer *PttPeer) error GetOpKeyOplogList(logID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status) ([]*OpKeyOplog, error) // peers Peers() *PttPeerSet NewPeerCh() chan *PttPeer NoMorePeers() chan struct{} SetNoMorePeers(noMorePeers chan struct{}) RegisterPeer(peer *PttPeer, peerType PeerType, isLocked bool) error RegisterPendingPeer(peer *PttPeer, isLocked bool) error UnregisterPeer(peer *PttPeer, isForceReset bool, isForceNotReset bool, isPttLocked bool) error GetPeerType(peer *PttPeer) PeerType IdentifyPeer(peer *PttPeer) HandleIdentifyPeer(dataBytes []byte, peer *PttPeer) error IdentifyPeerAck(data *IdentifyPeer, peer *PttPeer) error HandleIdentifyPeerAck(dataBytes []byte, peer *PttPeer) error SendDataToPeer(op OpType, data interface{}, peer *PttPeer) error SendDataToPeers(op OpType, data interface{}, peerList []*PttPeer) error CountPeers() (int, error) GetPeers() ([]*PttPeer, error) // sync ForceSyncCycle() time.Duration ForceSync() chan struct{} QuitSync() chan struct{} SyncWG() *sync.WaitGroup // entity Entity() Entity SaveNewEntityWithOplog(oplog *BaseOplog, isLocked bool, isForce bool) error MaybePostcreateEntity( oplog *BaseOplog, isForce bool, postcreateEntity func(entity Entity) error, ) error GetEntityLog() (*BaseOplog, error) HandleEntityTerminal(status types.Status, entityLog *BaseOplog, peer *PttPeer) error // ptt Ptt() Ptt // db DB() *pttdb.LDBBatch DBObjLock() *types.LockMap }
type Ptt ¶
type Ptt interface { ErrChan() *types.Chan // peers IdentifyPeer(entityID *types.PttID, quitSync chan struct{}, peer *PttPeer, isForce bool) (*IdentifyPeer, error) IdentifyPeerAck(challenge *types.Salt, peer *PttPeer) (*IdentifyPeerAck, error) HandleIdentifyPeerAck(entityID *types.PttID, data *IdentifyPeerAck, peer *PttPeer) error FinishIdentifyPeer(peer *PttPeer, isLocked bool, isResetPeerType bool) error ResetPeerType(peer *PttPeer, isLocked bool, isResetPeerType bool) error NoMorePeers() chan struct{} AddDial(nodeID *discover.NodeID, opKey *common.Address, peerType PeerType, isAddPeer bool) error RegisterEntity(e Entity, isLocked bool, isPeerLock bool) error UnregisterEntity(e Entity, isLocked bool) error RegisterEntityPeerWithOtherUserID(e Entity, id *types.PttID, peerType PeerType, isLocked bool) error AddJoinKey(hash *common.Address, entityID *types.PttID, isLocked bool) error RemoveJoinKey(hash *common.Address, entityID *types.PttID, isLocked bool) error TryJoin(challenge []byte, hash *common.Address, key *ecdsa.PrivateKey, request *JoinRequest) error AddOpKey(hash *common.Address, entityID *types.PttID, isLocked bool) error RemoveOpKey(hash *common.Address, entityID *types.PttID, isLocked bool) error RequestOpKeyByEntity(entity Entity, peer *PttPeer) error SyncWG() *sync.WaitGroup MyNodeID() *discover.NodeID GetMyEntity() MyEntity GetMyService() Service EncryptData(op OpType, data []byte, keyInfo *KeyInfo) ([]byte, error) DecryptData(ciphertext []byte, keyInfo *KeyInfo) (OpType, []byte, error) MarshalData(code CodeType, hash *common.Address, encData []byte) (*PttData, error) UnmarshalData(pttData *PttData) (CodeType, *common.Address, []byte, error) }
Ptt is the public-access version of Ptt.
type PttData ¶
type PttData struct { Node []byte `json:"N,omitempty"` Code CodeType `json:"C"` Hash []byte `json:"H,omitempty"` EvWithSalt []byte `json:"E,omitempty"` Checksum []byte `json:"c,omitempty"` Relay uint8 `json:"R"` }
PttData
type PttEventData ¶
type PttEventData struct { Code CodeType `json:"C"` Hash []byte `json:"H,omitempty"` EncData []byte `json:"D,omitempty"` }
PttEventData
type PttMyEntity ¶
type PttMyEntity interface { MyEntity MyPM() MyProtocolManager SignKey() *KeyInfo // join GetJoinRequest(hash *common.Address) (*JoinRequest, error) HandleApproveJoin(dataBytes []byte, hash *common.Address, joinRequest *JoinRequest, peer *PttPeer) error // node GetLenNodes() int Service() Service }
type PttNodeInfo ¶
type PttOpCreateArticle ¶
type PttOpCreateComment ¶
type PttOpCreateFriend ¶
type PttOpCreateFriend struct{}
type PttOpCreateMe ¶
type PttOpCreateReply ¶
type PttOpJoinBoard ¶
type PttOpJoinBoard struct{}
type PttOplog ¶
type PttOplog struct {
*BaseOplog `json:"O"`
}
func NewPttOplog ¶
func OplogsToPttOplogs ¶
type PttPeer ¶
type PttPeer struct { *p2p.Peer LockPeerType sync.RWMutex PeerType PeerType UserID *types.PttID IDEntityID *types.PttID IDChallenge *types.Salt IDChan chan struct{} IsRegistered bool IsToClose bool // contains filtered or unexported fields }
func NewPttPeer ¶
func RandomPeer ¶
func (*PttPeer) InitID ¶
func (p *PttPeer) InitID(entityID *types.PttID, quitSync chan struct{}, isForce bool) (*types.Salt, error)
InitID initializes info for identifying user-id
func (*PttPeer) RW ¶
func (p *PttPeer) RW() p2p.MsgReadWriter
func (*PttPeer) ReadStatus ¶
func (*PttPeer) ResetInitID ¶
func (p *PttPeer) ResetInitID()
type PttPeerInfo ¶
type PttPeerInfo struct { NodeID *discover.NodeID `json:"N"` UserID *types.PttID `json:"U"` PeerType PeerType `json:"T"` }
PttPeerInfo
type PttPeerSet ¶
type PttPeerSet struct {
// contains filtered or unexported fields
}
func NewPttPeerSet ¶
func NewPttPeerSet() (*PttPeerSet, error)
func (*PttPeerSet) Close ¶
func (ps *PttPeerSet) Close(isLocked bool)
Close disconnects all peers. No new peers can be registered after Close has returned.
func (*PttPeerSet) GetPeerWithPeerType ¶
func (*PttPeerSet) GetPendingPeerByUserID ¶
func (*PttPeerSet) ImportantPeerList ¶
func (ps *PttPeerSet) ImportantPeerList(isLocked bool) []*PttPeer
func (*PttPeerSet) ImportantPeers ¶
func (ps *PttPeerSet) ImportantPeers() map[discover.NodeID]*PttPeer
func (*PttPeerSet) IsClosed ¶
func (ps *PttPeerSet) IsClosed() bool
func (*PttPeerSet) IsPendingPeer ¶
func (ps *PttPeerSet) IsPendingPeer(peer *PttPeer, isLocked bool) bool
func (*PttPeerSet) Len ¶
func (ps *PttPeerSet) Len(isLocked bool) int
Len returns if the current number of peers in the set.
func (*PttPeerSet) Lock ¶
func (ps *PttPeerSet) Lock()
func (*PttPeerSet) MePeerList ¶
func (ps *PttPeerSet) MePeerList(isLocked bool) []*PttPeer
func (*PttPeerSet) MePeers ¶
func (ps *PttPeerSet) MePeers(isLocked bool) map[discover.NodeID]*PttPeer
func (*PttPeerSet) MemberPeerList ¶
func (ps *PttPeerSet) MemberPeerList(isLocked bool) []*PttPeer
func (*PttPeerSet) MemberPeers ¶
func (ps *PttPeerSet) MemberPeers() map[discover.NodeID]*PttPeer
func (*PttPeerSet) Peer ¶
func (ps *PttPeerSet) Peer(id *discover.NodeID, isLocked bool) *PttPeer
Peer retrieves the registered peer with the given id.
func (*PttPeerSet) PeerList ¶
func (ps *PttPeerSet) PeerList(isLocked bool) []*PttPeer
func (*PttPeerSet) PeersToPeerList ¶
func (*PttPeerSet) PendingPeerList ¶
func (ps *PttPeerSet) PendingPeerList(isLocked bool) []*PttPeer
func (*PttPeerSet) RLock ¶
func (ps *PttPeerSet) RLock()
func (*PttPeerSet) RUnlock ¶
func (ps *PttPeerSet) RUnlock()
func (*PttPeerSet) Register ¶
func (ps *PttPeerSet) Register(peer *PttPeer, peerType PeerType, isLocked bool) error
func (*PttPeerSet) Unlock ¶
func (ps *PttPeerSet) Unlock()
func (*PttPeerSet) Unregister ¶
func (ps *PttPeerSet) Unregister(peer *PttPeer, isLocked bool) error
func (*PttPeerSet) UnregisterPeerByOtherUserID ¶
type PttProtocolManager ¶
type PttProtocolManager interface { ProtocolManager }
type PttService ¶
type PttService interface { // Protocols retrieves the P2P protocols the service wishes to start. Protocols() []p2p.Protocol // APIs retrieves the list of RPC descriptors the service provides APIs() []rpc.API // Start is called after all services have been constructed and the networking // layer was also initialized to spawn any goroutines required by the service. Start(server *p2p.Server) error // Stop terminates all goroutines belonging to the service, blocking until they // are all terminated. Stop() error }
PttService is the interface for ptt as the service in the node-level.
type RequestOpKey ¶
type RequestOpKeyAck ¶
type SendDataToPeersEvent ¶
type SendDataToPeersEvent struct {
// contains filtered or unexported fields
}
type Service ¶
type Service interface { // APIs retrieves the list of RPC descriptors the service provides APIs() []rpc.API // Start is called after all services have been constructed and the networking // layer was not initialized yet. Prestart() error // Start is called after all services have been constructed and the networking // layer was also initialized to spawn any goroutines required by the service. Start() error // Stop terminates all goroutines belonging to the service, blocking until they // are all terminated. Stop() error SPM() ServiceProtocolManager Name() string Ptt() Ptt }
type ServiceConstructor ¶
type ServiceConstructor func(ctx *ServiceContext) (PttService, error)
ServiceConstructor is the function signature of the constructors needed to be registered for service instantiation.
type ServiceContext ¶
type ServiceContext struct { Services map[reflect.Type]PttService EventMux *event.TypeMux }
func (*ServiceContext) Service ¶
func (ctx *ServiceContext) Service(service interface{}) error
Service retrieves a currently running service registered of a specific type.
type ServiceProtocolManager ¶
type ServiceProtocolManager interface { Prestart() error Start() error Stop() error // entities Entities() map[types.PttID]Entity Entity(id *types.PttID) Entity RegisterEntity(id *types.PttID, e Entity) error UnregisterEntity(id *types.PttID) error Ptt() Ptt Service() Service DBObjLock() *types.LockMap GetDBLock() *types.LockMap Lock(id *types.PttID) error Unlock(id *types.PttID) error RLock(id *types.PttID) error RUnlock(id *types.PttID) error NewEmptyEntity() Entity }
ServiceProtocolManager manage service-level operations.
ServiceProtocolManager includes peers-of-services and the corresponding entities. both are dynamically allocated / deallocated.
When there is a new peer: have all the existing entities trying to register the peer. When a peer disappear: have all the existing entities trying to unregister the peer.
When there is a new entity: trying to register all the peers. When a peer disappear: trying to unregister all the peers.
type SyncBlock ¶
type SyncBlock struct {
IDs []*SyncBlockID
}
type SyncBlockAck ¶
type SyncBlockAck struct {
Blocks []*Block `json:"B"`
}
type SyncBlockID ¶
type SyncBlockID struct { ID *types.PttID ObjID *types.PttID `json:"o"` LogID *types.PttID `json:"l"` }
func ProcessInfoToSyncBlockIDList ¶
func ProcessInfoToSyncBlockIDList(info map[types.PttID]*BaseOplog, op OpType) []*SyncBlockID
type SyncCreateOpKeyAck ¶
type SyncCreateOpKeyAck struct {
Objs []*KeyInfo `json:"o"`
}
type SyncInfo ¶
type SyncInfo interface { GetLogID() *types.PttID SetLogID(id *types.PttID) GetUpdateTS() types.Timestamp SetUpdateTS(ts types.Timestamp) GetUpdaterID() *types.PttID SetUpdaterID(id *types.PttID) GetStatus() types.Status SetStatus(status types.Status) SetBlockInfo(blockInfo *BlockInfo) error GetBlockInfo() *BlockInfo SetIsGood(isGood types.Bool) GetIsGood() types.Bool SetIsAllGood(isAllGood types.Bool) GetIsAllGood() types.Bool CheckIsAllGood() types.Bool FromOplog(status types.Status, oplog *BaseOplog, opData OpData) error ToObject(obj Object) error }
type SyncMasterOplog ¶
type SyncMasterOplog struct {
Oplogs []*BaseOplog `json:"O"`
}
type SyncMediaAck ¶
type SyncMediaAck struct {
Objs []*Media `json:"o"`
}
type SyncMemberOplog ¶
type SyncMemberOplog struct {
Oplogs []*BaseOplog `json:"O"`
}
type SyncObject ¶
type SyncObject struct {
IDs []*SyncID
}
type SyncObjectAck ¶
type SyncObjectAck struct {
Objs []Object `json:"o"`
}
type SyncOpKeyOplog ¶
type SyncOpKeyOplog struct {
Oplogs []*BaseOplog `json:"O"`
}
type SyncOplog ¶
type SyncOplog struct { ToSyncTime types.Timestamp `json:"LT"` ToSyncNodes []*MerkleNode `json:"LN"` }
sync-oplog
type SyncOplogAck ¶
type SyncOplogAckInvalid ¶
type SyncOplogNewOplogs ¶
type SyncOplogNewOplogsAck ¶
type SyncPendingOplog ¶
type SyncPendingOplog struct {
Oplogs []*BaseOplog
}
type SyncPendingOplogAck ¶
type SyncPendingOplogAck struct {
Oplogs []*BaseOplog
}
type SyncPersonInfo ¶
type SyncPersonInfo struct { *BaseSyncInfo `json:"b"` TransferToID *types.PttID `json:"t"` }
func NewEmptySyncPersonInfo ¶
func NewEmptySyncPersonInfo() *SyncPersonInfo
type UpdateData ¶
type UpdateData interface{}
Source Files ¶
- article_block.go
- backend_types.go
- block.go
- block_info.go
- block_utils.go
- config.go
- content_types.go
- count.go
- dial_history.go
- entity.go
- entity_utils.go
- errors.go
- globals.go
- join_types.go
- key_info.go
- key_types.go
- locale.go
- lru_count.go
- master.go
- master_oplog.go
- master_oplog_types.go
- media.go
- media_op_types.go
- media_types.go
- media_utils.go
- member.go
- member_oplog.go
- member_oplog_types.go
- merkle.go
- merkle_node.go
- merkle_utils.go
- metered_msg_read_writer.go
- my_entity.go
- object.go
- object_utils.go
- op_key_oplog.go
- op_key_oplog_types.go
- op_key_utils.go
- op_types.go
- oplog.go
- oplog_utils.go
- process_info.go
- protocol_add_master.go
- protocol_add_master_logs.go
- protocol_add_member.go
- protocol_add_member_logs.go
- protocol_add_oplog.go
- protocol_add_person.go
- protocol_approve_join.go
- protocol_approve_join_entity.go
- protocol_create_entity.go
- protocol_create_join_entity.go
- protocol_create_media.go
- protocol_create_media_logs.go
- protocol_create_object.go
- protocol_create_object_logs.go
- protocol_create_op_key.go
- protocol_create_op_key_logs.go
- protocol_create_person.go
- protocol_create_person_logs.go
- protocol_delete_entity.go
- protocol_delete_entity_logs.go
- protocol_delete_media.go
- protocol_delete_media_logs.go
- protocol_delete_member.go
- protocol_delete_member_logs.go
- protocol_delete_object.go
- protocol_delete_object_logs.go
- protocol_delete_person.go
- protocol_delete_person_logs.go
- protocol_entity_terminal.go
- protocol_failed_create_object_log.go
- protocol_failed_delete_object_log.go
- protocol_failed_entity_log.go
- protocol_failed_person_log.go
- protocol_failed_update_object_log.go
- protocol_fix_138_master_log.go
- protocol_fix_190_merkle.go
- protocol_force_reconstruct_merkle.go
- protocol_force_sync_media.go
- protocol_force_sync_media_ack.go
- protocol_force_sync_object.go
- protocol_force_sync_object_ack.go
- protocol_force_sync_oplog.go
- protocol_force_sync_oplog_ack.go
- protocol_force_sync_oplog_by_merkle.go
- protocol_force_sync_oplog_by_merkle_ack.go
- protocol_force_sync_oplog_by_oplog_ack.go
- protocol_get_master_list.go
- protocol_get_master_list_from_cache.go
- protocol_get_master_oplog_list.go
- protocol_get_media.go
- protocol_get_member_list.go
- protocol_get_member_oplog_list.go
- protocol_get_op_key_infos_from_db.go
- protocol_get_op_key_oplog_list.go
- protocol_get_ptt_oplog_list.go
- protocol_handle_master_oplog.go
- protocol_handle_master_oplogs.go
- protocol_handle_member_oplog.go
- protocol_handle_member_oplogs.go
- protocol_handle_op_key_oplog.go
- protocol_handle_op_key_oplogs.go
- protocol_handle_oplogs.go
- protocol_identify_peer.go
- protocol_identify_peer_ack.go
- protocol_identify_peer_fail.go
- protocol_identify_peer_with_my_id.go
- protocol_identify_peer_with_my_id_ack.go
- protocol_identify_peer_with_my_id_challenge.go
- protocol_identify_peer_with_my_id_challenge_ack.go
- protocol_join.go
- protocol_join_ack_challenge.go
- protocol_join_entity.go
- protocol_leave_entity.go
- protocol_log_utils.go
- protocol_manager.go
- protocol_manager_utils.go
- protocol_manager_utils_block.go
- protocol_manager_utils_entity.go
- protocol_manager_utils_handle_message.go
- protocol_manager_utils_join_key.go
- protocol_manager_utils_log0.go
- protocol_manager_utils_master.go
- protocol_manager_utils_member.go
- protocol_manager_utils_merkle.go
- protocol_manager_utils_op_key.go
- protocol_manager_utils_oplog.go
- protocol_manager_utils_owner_id.go
- protocol_manager_utils_peer.go
- protocol_manager_utils_sync.go
- protocol_master_oplog.go
- protocol_member_oplog.go
- protocol_migrate_master.go
- protocol_migrate_master_logs.go
- protocol_migrate_member.go
- protocol_migrate_member_logs.go
- protocol_op_check_member.go
- protocol_op_check_member_ack.go
- protocol_op_fail.go
- protocol_op_key_oplog.go
- protocol_request_op_key.go
- protocol_request_op_key_ack.go
- protocol_request_op_key_fail.go
- protocol_revoke_op_key.go
- protocol_revoke_op_key_logs.go
- protocol_set_newest_create_object_log.go
- protocol_set_newest_delete_object_log.go
- protocol_set_newest_entity_log.go
- protocol_set_newest_person_log.go
- protocol_set_newest_update_object_log.go
- protocol_sync_block.go
- protocol_sync_create_block_ack.go
- protocol_sync_create_media.go
- protocol_sync_create_media_ack.go
- protocol_sync_create_object.go
- protocol_sync_create_object_ack.go
- protocol_sync_create_op_key.go
- protocol_sync_create_op_key_ack.go
- protocol_sync_master_oplog.go
- protocol_sync_member_oplog.go
- protocol_sync_op_key_oplog.go
- protocol_sync_oplog.go
- protocol_sync_oplog_ack.go
- protocol_sync_oplog_invalid.go
- protocol_sync_oplog_invalid_by_merkle.go
- protocol_sync_oplog_new_oplogs.go
- protocol_sync_oplog_new_oplogs_ack.go
- protocol_sync_pending_oplog.go
- protocol_sync_pending_oplog_ack.go
- protocol_sync_update_block_ack.go
- protocol_sync_update_object.go
- protocol_sync_update_object_ack.go
- protocol_to_confirm_join.go
- protocol_transfer_master.go
- protocol_transfer_master_logs.go
- protocol_transfer_person.go
- protocol_transfer_person_logs.go
- protocol_update_object.go
- protocol_update_object_logs.go
- protocol_update_person.go
- protocol_update_person_logs.go
- ptt.go
- ptt_api.go
- ptt_core.go
- ptt_oplog.go
- ptt_oplog_types.go
- ptt_peer.go
- ptt_peer_set.go
- ptt_service.go
- ptt_service_utils.go
- ptt_types.go
- ptt_utils.go
- ptt_utils_entity.go
- ptt_utils_handle_message.go
- ptt_utils_join.go
- ptt_utils_me.go
- ptt_utils_op.go
- ptt_utils_peer.go
- ptt_utils_sync.go
- service.go
- service_context.go
- service_core.go
- service_protocol_manager.go
- service_protocol_manager_utils_entity.go
- sync_info.go
- types.go
- utils.go