service

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

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

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

Documentation

Index

Constants

View Source
const (
	PathJoinMe     = "/joinme"
	PathJoinFriend = "/joinfriend"
	PathJoinBoard  = "/joinboard"
)
View Source
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

View Source
const (
	IntRenewJoinKeySeconds = 86400 // 1 day for now
	RenewJoinKeySeconds    = time.Duration(IntRenewJoinKeySeconds) * time.Second
)

join

View Source
const (
	MaxIterDeriveKeyBIP32 = 10

	SleepTimeOpKeyLock = 10
)

op-key

View Source
const (
	MaxSyncObjectAck = 50
	MaxSyncBlock     = 50
)

object

View Source
const (
	NSubBlock        = 2
	NLineInBlock     = 20
	NScrambleInBlock = 2
)
View Source
const (
	NByteInBlock = 65535

	MaxUploadMediaSize = 10485760 // 10MB

	MaxUploadImageWidth  = 8192
	MaxUploadImageHeight = 8192
)

media

View Source
const (
	SleepTimePttLock = 10

	SleepTimeLock = 10

	MaxCountPttOplog = 2000
	PPttOplog        = 12 // 2^12 = 4096
)

db

View Source
const (
	MaxSyncOplogAck = 200
)

oplog

View Source
const (
	Ptt4 uint
)

protocol

Variables

View Source
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")
)
View Source
var (
	ProtocolVersions = [1]uint{Ptt4}
	ProtocolName     = "ptt4"
	ProtocolLengths  = [1]uint64{uint64(NCodeType)}
)
View Source
var (
	DBMasterPrefix    = []byte(".MAdb")
	DBMasterIdxPrefix = []byte(".MAix")

	DBMasterOplogPrefix       = []byte(".MAlg")
	DBMasterIdxOplogPrefix    = []byte(".MAig")
	DBMasterMerkleOplogPrefix = []byte(".MAmk")
)

member

View Source
var (
	DBMemberPrefix    = []byte(".mbdb")
	DBMemberIdxPrefix = []byte(".mbix")

	DBMemberOplogPrefix       = []byte(".mblg")
	DBMemberIdxOplogPrefix    = []byte(".mbig")
	DBMemberMerkleOplogPrefix = []byte(".mbmk")
)

member

View Source
var (
	DBOpKeyPrefix     = []byte(".okdb")
	DBOpKeyIdxPrefix  = []byte(".okix")
	DBOpKeyIdx2Prefix = []byte(".oki2")

	DBOpKeyOplogPrefix    = []byte(".oklg")
	DBOpKeyIdxOplogPrefix = []byte(".okig")
)
View Source
var (
	DBBlockInfoPrefix    = []byte(".bidb")
	DBBlockInfoIdxPrefix = []byte(".biix")

	DBContentBlockPrefix = []byte(".bkdb")
)
View Source
var (
	DBMediaPrefix    = []byte(".mddb")
	DBMediaIdxPrefix = []byte(".mdix")
)
View Source
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")
)
View Source
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

View Source
var (
	ExpireDialHistorySeconds int64 = 30
	DialHistoryLoopInterval        = 30 * time.Second
)

dial-history

View Source
var (
	IsE2E = false

	IsPrivateAsPublic = false
)

misc

View Source
var (
	DBFix190Prefix = []byte(".f04H") // 190 in base58
)

fix

View Source
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

View Source
var (
	ExpireOplogSeconds = 300 // expire oplog circulation as 5 minutes for now.
)

oplog

Functions

func DBPrefix

func DBPrefix(dbPrefix []byte, id *types.PttID) ([]byte, error)

func DiffMerkleKeys

func DiffMerkleKeys(
	myKeys [][]byte,
	theirKeys [][]byte,
) ([][]byte, [][]byte, error)

func DiffMerkleTree

func DiffMerkleTree(
	myNodes []*MerkleNode,
	theirNodes []*MerkleNode,

	ts types.Timestamp,

	pm ProtocolManager,
	merkle *Merkle,

) ([]*MerkleNode, []*MerkleNode, error)

func DiffOplogKeys

func DiffOplogKeys(myKeys [][]byte, theirKeys [][]byte) ([][]byte, [][]byte, error)

func ErrResp

func ErrResp(code error, format string, v ...interface{}) error

func GenChallenge

func GenChallenge() []byte

func GetMerkleName

func GetMerkleName(merkle *Merkle, pm ProtocolManager) string

func GetOplogIterWithOplog

func GetOplogIterWithOplog(oplog *BaseOplog, startID *types.PttID, listOrder pttdb.ListOrder, status types.Status, isLocked bool) (iterator.Iterator, error)

func HandleFailedOplogs

func HandleFailedOplogs(
	oplogs []*BaseOplog,

	setDB func(oplog *BaseOplog),
	handleFailedOplog func(oplog *BaseOplog) error,
) error

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.

  1. verify all the oplogs, return if any of the log is invalid.
  2. preset oplog (isSync as false and setDB)
  3. check pre-log-id
  4. integrate existing oplog. skip if already synced.
  5. process me-oplog.
  6. save me-oplog.
  7. broadcast me-oplogs.
  8. 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 IDInOplogSigns

func IDInOplogSigns(id *types.PttID, signs []*SignInfo) bool

func InitService

func InitService(dataDir string) error

func MarshalCode

func MarshalCode(code CodeType) ([]byte, error)

func MarshalOp

func MarshalOp(op OpType) ([]byte, error)

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 NewObjectWithOplog(obj Object, oplog *BaseOplog)

func NewPttIDWithMixedIDs

func NewPttIDWithMixedIDs(pttIDs []*types.PttID) (*types.PttID, error)

func NewPttIDWithMyID

func NewPttIDWithMyID(myID *types.PttID) (*types.PttID, error)

func OplogKeyToIDBytes

func OplogKeyToIDBytes(key []byte) ([]byte, error)

func OplogKeyToIdxKey

func OplogKeyToIdxKey(key []byte, dbIdxPrefix []byte) []byte

func PMHandleMessageWrapper

func PMHandleMessageWrapper(pm ProtocolManager, hash *common.Address, encData []byte, peer *PttPeer) error

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

func ScrambleBuf(buf [][]byte) ([][]byte, error)

ScrambleBuf scrambles the buf.

  1. obtain the json-str to ensure that the 1st-char and the last-char are not 0
  2. do scramble on the json-str.

XXX TODO: better scrambleBuf

func SetDeleteObjectWithOplog

func SetDeleteObjectWithOplog(
	obj Object,
	status types.Status,
	oplog *BaseOplog,
)

func SetEntityWithOplog

func SetEntityWithOplog(entity Entity, status types.Status, oplog *BaseOplog) error

func SetFailedObjectWithOplog

func SetFailedObjectWithOplog(
	obj Object,
	oplog *BaseOplog,

	ts types.Timestamp,
)

func SetLocale

func SetLocale(locale Locale) error

func SetNewEntityWithOplog

func SetNewEntityWithOplog(entity Entity, status types.Status, oplog *BaseOplog) error

func SetNewObjectWithOplog

func SetNewObjectWithOplog(
	obj Object,
	oplog *BaseOplog,
)

func SetPendingPersonSyncInfo

func SetPendingPersonSyncInfo(person Object, pendingStatus types.Status, oplog *BaseOplog) error

func SetPttDB

func SetPttDB(myID *types.PttID, oplog *BaseOplog)

func SetUpdateObjectWithOplog

func SetUpdateObjectWithOplog(
	obj Object,
	oplog *BaseOplog,
)

func SignData

func SignData(bytes []byte, keyInfo *KeyInfo) ([]byte, []byte, []byte, []byte, error)

func StartPM

func StartPM(pm ProtocolManager) error

StartPM starts the pm

  1. go PMSync (require sync first to receive new-peer-ch)
  2. pm.Start
  3. go PMCreateOpKeyLoop

func StopPM

func StopPM(pm ProtocolManager) error

func TeardownService

func TeardownService()

func UnscrambleBuf

func UnscrambleBuf(buf [][]byte) ([][]byte, error)

UnscrambleBuf unscramles the buf.

  1. unscramble the buf.
  2. do json.unmarshal.

func ValidateMerkleTree

func ValidateMerkleTree(
	myNodes []*MerkleNode,
	theirNodes []*MerkleNode,
	ts types.Timestamp,

	pm ProtocolManager,
	merkle *Merkle,

) (types.Timestamp, bool)

func VerifyData

func VerifyData(bytesWithSalt []byte, expectedHash []byte, sig []byte, pubKeyBytes []byte, doerID *types.PttID, extra *KeyExtraInfo) error

Types

type AddOplog

type AddOplog struct {
	Oplog *BaseOplog `json:"O"`
}

type AddOplogs

type AddOplogs struct {
	Oplogs []*BaseOplog `json:"O"`
}

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 ApproveJoinEntity struct {
	MyID       *types.PttID `json:"ID"`
	Entity     Entity       `json:"e"`
	Oplog0     *BaseOplog   `json:"0"`
	MasterLogs []*BaseOplog `json:"M"`
	MemberLogs []*BaseOplog `json:"m"`
	OpKey      *KeyInfo     `json:"O"`
	OpKeyLog   *BaseOplog   `json:"o"`
}

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 BackendConfirmJoin struct {
	ID         *types.PttID
	Name       []byte           `json:"N"`
	EntityID   *types.PttID     `json:"EID"`
	EntityName []byte           `json:"EN"`
	JoinType   JoinType         `json:"JT"`
	UpdateTS   types.Timestamp  `json:"UT"`
	NodeID     *discover.NodeID `json:"NID"`
}

type BackendCountPeers

type BackendCountPeers struct {
	MyPeers        int `json:"M"`
	ImportantPeers int `json:"I"`
	MemberPeers    int `json:"E"`
	RandomPeers    int `json:"R"`
}

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 BackendJoinURL struct {
	CreatorID    string `json:"C"`
	Name         string `json:"N"`
	Hash         string `json:"H"`
	Pn           string `json:"Pn"`
	URL          string
	UpdateTS     types.Timestamp `json:"UT"`
	ExpireSecond uint            `json:"e"`
}

func MarshalBackendJoinURL

func MarshalBackendJoinURL(id *types.PttID, nodeID *discover.NodeID, keyInfo *KeyInfo, name []byte, path string) (*BackendJoinURL, error)

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 NewBaseEntity(id *types.PttID, createTS types.Timestamp, creatorID *types.PttID, status types.Status, db *pttdb.LDBBatch, dbLock *types.LockMap) *BaseEntity

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) GetID

func (e *BaseEntity) GetID() *types.PttID

implemented in BaseEntity

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) IsOwner

func (e *BaseEntity) IsOwner(id *types.PttID) bool

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) SetDB

func (e *BaseEntity) SetDB(db *pttdb.LDBBatch, dbLock *types.LockMap)

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

func (*BaseMeteredMsgReadWriter) WriteMsg

func (rw *BaseMeteredMsgReadWriter) WriteMsg(msg p2p.Msg) error

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 NewObject

func NewObject(
	id *types.PttID,
	createTS types.Timestamp,
	creatorID *types.PttID,
	entityID *types.PttID,

	logID *types.PttID,

	status types.Status,
) *BaseObject

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 (obj *BaseObject) GetCrossObjIterWithObj(startPrefix []byte, startID *types.PttID, listOrder pttdb.ListOrder, isLocked bool) (iterator.Iterator, error)

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) GetKey

func (o *BaseObject) GetKey(id *types.PttID, isLocked bool) ([]byte, error)

func (*BaseObject) GetLogID

func (o *BaseObject) GetLogID() *types.PttID

func (*BaseObject) GetNewestLogID

func (o *BaseObject) GetNewestLogID() *types.PttID

func (*BaseObject) GetObjIdxIterWithObj

func (obj *BaseObject) GetObjIdxIterWithObj(startID *types.PttID, listOrder pttdb.ListOrder, isLocked bool) (iterator.Iterator, error)

func (*BaseObject) GetObjIterWithObj

func (obj *BaseObject) GetObjIterWithObj(startID *types.PttID, listOrder pttdb.ListOrder, isLocked bool) (iterator.Iterator, error)

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) KeyToID

func (o *BaseObject) KeyToID(key []byte) (*types.PttID, error)

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) SetDB

func (o *BaseObject) 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),
)

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 ConcatLog

func ConcatLog(slices [][]*BaseOplog) ([]*BaseOplog, error)

func GetOplogList

func GetOplogList(oplog *BaseOplog, startID *types.PttID, limit int, listOrder pttdb.ListOrder, status types.Status, isLocked bool) ([]*BaseOplog, error)

func MasterOplogsToOplogs

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

func MemberOplogsToOplogs

func MemberOplogsToOplogs(typedLogs []*MemberOplog) []*BaseOplog

func NewOplog

func NewOplog(id *types.PttID, ts types.Timestamp, doerID *types.PttID, op OpType, data interface{}, db *pttdb.LDBBatch, dbPrefixID *types.PttID, dbPrefix []byte, dbIdxPrefix []byte, dbMerklePrefix []byte, dbLock *types.LockMap) (*BaseOplog, error)

func NewOplogForLoadData

func NewOplogForLoadData(data interface{}, db *pttdb.LDBBatch) *BaseOplog

func OpKeyOplogsToOplogs

func OpKeyOplogsToOplogs(typedLogs []*OpKeyOplog) []*BaseOplog

func ProcessInfoToBroadcastLogs

func ProcessInfoToBroadcastLogs(info map[types.PttID]*BaseOplog, broadcastLogs []*BaseOplog) []*BaseOplog

func ProcessInfoToLogs

func ProcessInfoToLogs(info map[types.PttID]*BaseOplog, op OpType) []*BaseOplog

func PttOplogsToOplogs

func PttOplogsToOplogs(typedLogs []*PttOplog) []*BaseOplog

func (*BaseOplog) CheckAlreadyExists

func (o *BaseOplog) CheckAlreadyExists() error

func (*BaseOplog) DBPrefix

func (o *BaseOplog) DBPrefix() []byte

Prefix

func (*BaseOplog) DBPrefixInternal

func (o *BaseOplog) DBPrefixInternal() []byte

PrefixInternal

func (*BaseOplog) DBPrefixMaster

func (o *BaseOplog) DBPrefixMaster() []byte

PrefixInternal

func (*BaseOplog) Delete

func (o *BaseOplog) Delete(isLocked bool) error

func (*BaseOplog) ForceSave

func (o *BaseOplog) ForceSave(isLocked bool, merkle *Merkle) error

func (*BaseOplog) Get

func (o *BaseOplog) Get(id *types.PttID, isLocked bool) error

func (*BaseOplog) GetDB

func (o *BaseOplog) GetDB() *pttdb.LDBBatch

func (*BaseOplog) GetDBIdxPrefix

func (o *BaseOplog) GetDBIdxPrefix() []byte

func (*BaseOplog) GetDBLock

func (o *BaseOplog) GetDBLock() *types.LockMap

func (*BaseOplog) GetDBMerklePrefix

func (o *BaseOplog) GetDBMerklePrefix() []byte

func (*BaseOplog) GetDBPrefix

func (o *BaseOplog) GetDBPrefix() []byte

func (*BaseOplog) GetDBPrefixInternal

func (o *BaseOplog) GetDBPrefixInternal() []byte

func (*BaseOplog) GetDBPrefixMaster

func (o *BaseOplog) GetDBPrefixMaster() []byte

func (*BaseOplog) GetDBPrefxiID

func (o *BaseOplog) GetDBPrefxiID() *types.PttID

func (*BaseOplog) GetData

func (o *BaseOplog) GetData(data interface{}) error

func (*BaseOplog) GetKey

func (o *BaseOplog) GetKey(id *types.PttID, isLocked bool) ([]byte, error)

func (*BaseOplog) IdxKey

func (o *BaseOplog) IdxKey() ([]byte, error)

IdxKey: idxPrefix:OplogID

func (*BaseOplog) IdxPrefix

func (o *BaseOplog) IdxPrefix() []byte

IdxPrefix

func (*BaseOplog) IntegrateExisting

func (o *BaseOplog) IntegrateExisting(isLocked bool, merkle *Merkle) (types.Bool, bool, error)

IntegrateExisting integrates with existing oplog. Return: is-to-re-sign, error

func (*BaseOplog) InternalSign

func (o *BaseOplog) InternalSign(id *types.PttID, keyInfo *KeyInfo) error

func (*BaseOplog) Load

func (o *BaseOplog) Load(key []byte) error

func (*BaseOplog) Lock

func (o *BaseOplog) Lock() error

func (*BaseOplog) Marshal

func (o *BaseOplog) Marshal() ([]byte, error)

func (*BaseOplog) MarshalKey

func (o *BaseOplog) MarshalKey(prefix []byte) ([]byte, error)

MarshalKey: prefixID:TS:OplogID:Op

func (*BaseOplog) MarshalMerkleKey

func (o *BaseOplog) MarshalMerkleKey() ([]byte, error)

MarshalKey: prefixID:TS:OplogID:Op

func (*BaseOplog) MasterSign

func (o *BaseOplog) MasterSign(id *types.PttID, keyInfo *KeyInfo) error

func (*BaseOplog) Save

func (o *BaseOplog) Save(isLocked bool, merkle *Merkle) error

func (*BaseOplog) SaveCore

func (o *BaseOplog) SaveCore() ([]byte, *pttdb.Index, []*pttdb.KeyVal, error)

func (*BaseOplog) SaveCorePending

func (o *BaseOplog) SaveCorePending() ([]byte, *pttdb.Index, []*pttdb.KeyVal, error)

func (*BaseOplog) SelectExisting

func (o *BaseOplog) SelectExisting(isLocked bool, merkle *Merkle) (types.Bool, types.Bool, error)

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) SetDB

func (o *BaseOplog) SetDB(db *pttdb.LDBBatch, id *types.PttID, prefix []byte, idxPrefix []byte, merklePrefix []byte, dbLock *types.LockMap)

func (*BaseOplog) SetMasterLogID

func (o *BaseOplog) SetMasterLogID(oplogID *types.PttID, weight uint32) error

func (*BaseOplog) SetPreLogID

func (o *BaseOplog) SetPreLogID(id *types.PttID)

func (*BaseOplog) Sign

func (o *BaseOplog) Sign(keyInfo *KeyInfo) error

func (*BaseOplog) SignsHash

func (o *BaseOplog) SignsHash() ([]byte, error)

func (*BaseOplog) ToStatus

func (o *BaseOplog) ToStatus() types.Status

func (*BaseOplog) Unlock

func (o *BaseOplog) Unlock() error

func (*BaseOplog) Unmarshal

func (o *BaseOplog) Unmarshal(data []byte) error

func (*BaseOplog) Verify

func (o *BaseOplog) Verify() error

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 (pm *BaseProtocolManager) BaseDeleteMedia(
	id *types.PttID,
	op OpType,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),
	newOplog func(objID *types.PttID, op OpType, opData OpData) (Oplog, error),
	broadcastLog func(oplog *BaseOplog) error,
) error

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.

  1. new person
  2. new oplog
  3. set synced (is-all-good).
  4. sign oplog
  5. save object
  6. oplog-save
  7. broadcast-log

func (*BaseProtocolManager) DB

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 (pm *BaseProtocolManager) ForceSyncOplog(
	fromTS types.Timestamp,
	toTS types.Timestamp,

	merkle *Merkle,

	forceSyncOplogMsg OpType,

	peer *PttPeer,
) error

func (*BaseProtocolManager) ForceSyncOplogAck

func (pm *BaseProtocolManager) ForceSyncOplogAck(
	fromTS types.Timestamp,
	toTS types.Timestamp,

	merkle *Merkle,

	forceSyncOplogAckMsg OpType,

	peer *PttPeer,
) error

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) GetMaster

func (pm *BaseProtocolManager) GetMaster(id *types.PttID, isLocked bool) (*Master, error)

func (*BaseProtocolManager) GetMasterList

func (pm *BaseProtocolManager) GetMasterList(startID *types.PttID, limit int, listOrder pttdb.ListOrder, isLocked bool) ([]*Master, error)

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) GetMember

func (pm *BaseProtocolManager) GetMember(id *types.PttID, isLocked bool) (*Member, error)

func (*BaseProtocolManager) GetMemberList

func (pm *BaseProtocolManager) GetMemberList(startID *types.PttID, limit int, listOrder pttdb.ListOrder, isLocked bool) ([]*Member, error)

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 (pm *BaseProtocolManager) GetOpKeyFromHash(hash *common.Address, isLocked bool) (*KeyInfo, error)

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 (pm *BaseProtocolManager) GetPendingOplogs(setDB func(oplog *BaseOplog), peer *PttPeer, isGetAll bool) ([]*BaseOplog, []*BaseOplog, error)

func (*BaseProtocolManager) GetPendingPeerByUserID

func (pm *BaseProtocolManager) GetPendingPeerByUserID(id *types.PttID, isLocked bool) (*PttPeer, error)

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 (pm *BaseProtocolManager) HandleAddOplog(
	dataBytes []byte,
	handleOplogs func(oplogs []*BaseOplog, p *PttPeer, isUpdateSyncTime bool) error,
	peer *PttPeer) error

func (*BaseProtocolManager) HandleAddOplogs

func (pm *BaseProtocolManager) HandleAddOplogs(
	dataBytes []byte,
	handleOplogs func(oplogs []*BaseOplog, p *PttPeer, isUpdateSyncTime bool) error,
	peer *PttPeer) error

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 (pm *BaseProtocolManager) HandleAddPendingOplog(
	dataBytes []byte,
	handlePendingOplogs func(oplogs []*BaseOplog, p *PttPeer) error,
	peer *PttPeer) error

func (*BaseProtocolManager) HandleAddPendingOplogs

func (pm *BaseProtocolManager) HandleAddPendingOplogs(
	dataBytes []byte,
	handlePendingOplogs func(oplogs []*BaseOplog, p *PttPeer) error,
	peer *PttPeer) error

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.

  1. lock person
  2. check whether the person exists. (should always be ErrNotFound)
  3. new person.
  4. set is-all-sync
  5. 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 (pm *BaseProtocolManager) HandleEntityTerminal(status types.Status, entityLog *BaseOplog, peer *PttPeer) error

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.

  1. lock-obj.
  2. get obj, and return if unable to get the obj (already deleted)
  3. check validity.
  4. prefailed
  5. if not my object: remove blocks and the object.
  6. 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

  1. get article
  2. check validity
  3. 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.

  1. lock-obj.
  2. get obj, and return if unable to get the obj (already deleted)
  3. check validity.
  4. prefailed
  5. if not my object: remove blocks and the object.
  6. if my object: only set the status as failed.

func (*BaseProtocolManager) HandleFailedValidCreatePersonLog

func (pm *BaseProtocolManager) HandleFailedValidCreatePersonLog(
	oplog *BaseOplog,
	person Object,

	prefailed func(obj Object, oplog *BaseOplog) error,
) error

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

  1. get article
  2. check validity
  3. 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 (pm *BaseProtocolManager) HandleForceSyncMediaAck(
	dataBytes []byte,
	peer *PttPeer,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),
	syncMediaBlockMsg OpType,
) error

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 (pm *BaseProtocolManager) HandleForceSyncObject(
	dataBytes []byte,
	peer *PttPeer,

	obj Object,

	syncAckMsg OpType,
) error

func (*BaseProtocolManager) HandleForceSyncObjectAck

func (pm *BaseProtocolManager) HandleForceSyncObjectAck(
	obj Object,
	peer *PttPeer,

	origObj Object,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),

) error

func (*BaseProtocolManager) HandleForceSyncOplog

func (pm *BaseProtocolManager) HandleForceSyncOplog(
	dataBytes []byte,
	peer *PttPeer,

	merkle *Merkle,
	forceSyncOplogAckMsg OpType,
) error

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 (pm *BaseProtocolManager) HandleForceSyncOplogByMerkle(
	dataBytes []byte,
	peer *PttPeer,

	forceSyncOplogAckMsg OpType,
	forceSyncOplogByOplogAckMsg OpType,

	setDB func(oplog *BaseOplog),

	setNewestOplog func(log *BaseOplog) error,

	merkle *Merkle,
) error

func (*BaseProtocolManager) HandleForceSyncOplogByMerkleAck

func (pm *BaseProtocolManager) HandleForceSyncOplogByMerkleAck(
	dataBytes []byte,
	peer *PttPeer,

	forceSyncOplogMsg OpType,

	merkle *Merkle,
) error

func (*BaseProtocolManager) HandleForceSyncOplogByOplogAck

func (pm *BaseProtocolManager) HandleForceSyncOplogByOplogAck(
	dataBytes []byte,
	peer *PttPeer,

	handleOplogs func(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error,

	merkle *Merkle,

) error

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

  1. if we've already know the user-id: return.
  2. try to cancel peer waiting for identification.
  3. 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 (pm *BaseProtocolManager) HandlePendingUpdatePersonLog(
	oplog *BaseOplog,
	origPerson Object,
	opData OpData,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),

) (types.Bool, []*BaseOplog, error)

func (*BaseProtocolManager) HandleSyncBlock

func (pm *BaseProtocolManager) HandleSyncBlock(
	dataBytes []byte,
	peer *PttPeer,
	obj Object,
	syncAckMsg OpType,
) error

func (*BaseProtocolManager) HandleSyncCreateBlockAck

func (pm *BaseProtocolManager) HandleSyncCreateBlockAck(
	dataBytes []byte,
	peer *PttPeer,

	obj Object,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),
	postcreate func(obj Object, oplog *BaseOplog) error,
	broadcastLog func(oplog *BaseOplog) error,
) error

func (*BaseProtocolManager) HandleSyncCreateMedia

func (pm *BaseProtocolManager) HandleSyncCreateMedia(dataBytes []byte, peer *PttPeer, syncAckMsg OpType) error

func (*BaseProtocolManager) HandleSyncCreateMediaAck

func (pm *BaseProtocolManager) HandleSyncCreateMediaAck(
	dataBytes []byte,
	peer *PttPeer,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),
	broadcastLog func(oplog *BaseOplog) error,

) error

func (*BaseProtocolManager) HandleSyncCreateMediaBlockAck

func (pm *BaseProtocolManager) HandleSyncCreateMediaBlockAck(
	dataBytes []byte,
	peer *PttPeer,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),
	broadcastLog func(oplog *BaseOplog) error,

) error

func (*BaseProtocolManager) HandleSyncCreateObject

func (pm *BaseProtocolManager) HandleSyncCreateObject(
	dataBytes []byte,
	peer *PttPeer,
	obj Object,
	syncAckMsg OpType,
) error

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.)

  1. get my merkle-tree-list.
  2. validate merkle tree
  3. SyncOplogAck

func (*BaseProtocolManager) HandleSyncOplogAck

func (pm *BaseProtocolManager) HandleSyncOplogAck(
	dataBytes []byte,
	peer *PttPeer,

	merkle *Merkle,

	setDB func(oplog *BaseOplog),
	setNewestOplog func(log *BaseOplog) error,
	postsync func(peer *PttPeer) error,

	newLogsMsg OpType,
) error

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.

  1. if the peer is PeerTypeMe or the peer is master: do Resync
  2. if I am the master (asked from non-master): invalid op
  3. (The peer is not the master) 3.1. if I am connecting to the master => get the master-peer and resync with the master.
  4. Try to connect to the master.

func (*BaseProtocolManager) HandleSyncOplogNewOplogs

func (pm *BaseProtocolManager) HandleSyncOplogNewOplogs(
	dataBytes []byte,
	peer *PttPeer,
	setDB func(oplog *BaseOplog),
	handleOplogs func(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error,
	setNewestOplog func(log *BaseOplog) error,
	newLogsAckMsg OpType,
) error

func (*BaseProtocolManager) HandleSyncOplogNewOplogsAck

func (pm *BaseProtocolManager) HandleSyncOplogNewOplogsAck(
	dataBytes []byte,
	peer *PttPeer,
	setDB func(oplog *BaseOplog),
	handleOplogs func(oplogs []*BaseOplog, peer *PttPeer, isUpdateSyncTime bool) error,
	postsync func(peer *PttPeer) error,
) error

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 (pm *BaseProtocolManager) HandleSyncPendingOplog(
	dataBytes []byte,
	peer *PttPeer,
	handlePendingOplogs func(oplogs []*BaseOplog, peer *PttPeer) error,
	setDB func(oplog *BaseOplog),
	handleFailedOplog func(oplog *BaseOplog) error,
	syncAckMsg OpType,
) error

func (*BaseProtocolManager) HandleSyncPendingOplogAck

func (pm *BaseProtocolManager) HandleSyncPendingOplogAck(
	dataBytes []byte,
	peer *PttPeer,

	handlePendingOplogs func(oplogs []*BaseOplog, peer *PttPeer) error,
) error

func (*BaseProtocolManager) HandleSyncUpdateBlockAck

func (pm *BaseProtocolManager) HandleSyncUpdateBlockAck(
	dataBytes []byte,
	peer *PttPeer,

	obj Object,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),

	postupdate func(obj Object, oplog *BaseOplog) error,
	broadcastLog func(oplog *BaseOplog) error,

) error

func (*BaseProtocolManager) HandleSyncUpdateObject

func (pm *BaseProtocolManager) HandleSyncUpdateObject(
	dataBytes []byte,
	peer *PttPeer,
	obj Object,
	syncAckMsg OpType,
) error

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 (pm *BaseProtocolManager) HandleUpdatePersonLog(
	oplog *BaseOplog,
	origPerson Object,
	opData OpData,

	merkle *Merkle,

	setLogDB func(oplog *BaseOplog),
	postupdate func(obj Object, oplog *BaseOplog) error,

) ([]*BaseOplog, error)

func (*BaseProtocolManager) IdentifyPeer

func (pm *BaseProtocolManager) IdentifyPeer(peer *PttPeer)

IdentifyPeer identifies the peer by providing the op-key of the pm (requester)

  1. generate salt
  2. initialize info in peer
  3. 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.

  1. return my data
  2. if we do not know the peer, do identify peer process.

func (*BaseProtocolManager) IntegrateOplog

func (pm *BaseProtocolManager) IntegrateOplog(
	oplog *BaseOplog,
	isLocked bool,

	merkle *Merkle,
) (types.Bool, bool, error)

func (*BaseProtocolManager) InternalSign

func (pm *BaseProtocolManager) InternalSign(oplog *BaseOplog) (bool, error)

func (*BaseProtocolManager) IsGoodID

func (pm *BaseProtocolManager) IsGoodID(id *types.PttID, nodeID *discover.NodeID) bool

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 (pm *BaseProtocolManager) IsSuspiciousID(id *types.PttID, nodeID *discover.NodeID) bool

func (*BaseProtocolManager) IsValidOplog

func (pm *BaseProtocolManager) IsValidOplog(signInfos []*SignInfo) (*types.PttID, uint32, bool)

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 (pm *BaseProtocolManager) MigrateMember(fromID *types.PttID, toID *types.PttID) error

func (*BaseProtocolManager) MyMemberLog

func (pm *BaseProtocolManager) MyMemberLog() *MemberOplog

func (*BaseProtocolManager) NewMaster

func (pm *BaseProtocolManager) NewMaster(id *types.PttID) (Object, OpData, error)

func (*BaseProtocolManager) NewMasterOplog

func (pm *BaseProtocolManager) NewMasterOplog(keyID *types.PttID, op OpType, opData OpData) (Oplog, error)

func (*BaseProtocolManager) NewMasterOplogWithTS

func (pm *BaseProtocolManager) NewMasterOplogWithTS(keyID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error)

func (*BaseProtocolManager) NewMedia

func (pm *BaseProtocolManager) NewMedia(theData CreateData) (Object, OpData, error)

func (*BaseProtocolManager) NewMember

func (pm *BaseProtocolManager) NewMember(id *types.PttID) (Object, OpData, error)

func (*BaseProtocolManager) NewMemberOplog

func (pm *BaseProtocolManager) NewMemberOplog(keyID *types.PttID, op OpType, opData OpData) (Oplog, error)

func (*BaseProtocolManager) NewMemberOplogWithTS

func (pm *BaseProtocolManager) NewMemberOplogWithTS(keyID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error)

func (*BaseProtocolManager) NewOpKey

func (pm *BaseProtocolManager) NewOpKey(data CreateData) (Object, OpData, error)

func (*BaseProtocolManager) NewOpKeyOplog

func (pm *BaseProtocolManager) NewOpKeyOplog(keyID *types.PttID, op OpType, opData OpData) (Oplog, error)

func (*BaseProtocolManager) NewOpKeyOplogWithTS

func (pm *BaseProtocolManager) NewOpKeyOplogWithTS(keyID *types.PttID, ts types.Timestamp, op OpType, opData OpData) (Oplog, error)

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 (pm *BaseProtocolManager) RemoveMediaInfosByOplog(mediaInfos map[types.PttID]*BaseOplog, mediaIDs []*types.PttID, oplog *BaseOplog, deleteMediaOp OpType)

func (*BaseProtocolManager) RemoveOpKey

func (pm *BaseProtocolManager) RemoveOpKey(
	keyInfo *KeyInfo,

	isLocked bool,
	isDeleteOplog bool,
	isDeleteDB bool,
) error

func (*BaseProtocolManager) RemoveOpKeyFromHash

func (pm *BaseProtocolManager) RemoveOpKeyFromHash(
	hash *common.Address,

	isLocked bool,
	isDeleteOplog bool,
	isDeleteDB bool,
) error

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.

  1. lock.
  2. get data.
  3. 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 (pm *BaseProtocolManager) SetNewestDeleteObjectLog(
	oplog *BaseOplog,
	obj Object,
) (types.Bool, error)

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

  1. get article.
  2. if Status > failed: return LogID
  3. 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 (pm *BaseProtocolManager) SetOplogIsSync(
	oplog *BaseOplog, isBroadcast bool,
	broadcastLog func(oplog *BaseOplog) error,
) (bool, error)

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 (pm *BaseProtocolManager) SplitContentBlocks(prefix []byte, objID *types.PttID, buf [][]byte, nFirstLineInBlock int) (*types.PttID, [][][]byte, error)

func (*BaseProtocolManager) SplitMediaBlocks

func (pm *BaseProtocolManager) SplitMediaBlocks(objID *types.PttID, buf []byte) (*types.PttID, [][][]byte, error)

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).

  1. check isToSyncPeer (The peer is considered as valid and I need to sync with them.)
  2. if isToSyncPeer: ResyncOplog (with resyncOp. I become the requester.)
  3. 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 (pm *BaseProtocolManager) SyncOplogNewOplogsAck(
	ts types.Timestamp,
	keys [][]byte,
	peer *PttPeer,
	setDB func(oplog *BaseOplog),
	setNewestOplog func(log *BaseOplog) error,
	newLogsAckMsg OpType,
) error

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 (pm *BaseProtocolManager) SyncPendingOplog(
	peer *PttPeer,

	setDB func(oplog *BaseOplog),
	handleFailedOplog func(oplog *BaseOplog) error,

	syncMsg OpType,
) error

func (*BaseProtocolManager) SyncPendingOplogAck

func (pm *BaseProtocolManager) SyncPendingOplogAck(
	data *SyncPendingOplog,
	peer *PttPeer,

	syncAckMsg OpType,

	handlePendingOplogs func(oplogs []*BaseOplog, peer *PttPeer) error,
	setDB func(oplog *BaseOplog),
	handleFailedOplog func(oplog *BaseOplog) error,
) error

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 (pm *BaseProtocolManager) UnregisterPeer(peer *PttPeer, isForceReset bool, isForceNotReset bool, isPttLocked bool) error

func (*BaseProtocolManager) UnregisterPeerByOtherUserID

func (pm *BaseProtocolManager) UnregisterPeerByOtherUserID(id *types.PttID, isResetPeerType bool, isPttLocked bool) error

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) APIs

func (p *BasePtt) APIs() []rpc.API

func (*BasePtt) AddDial

func (p *BasePtt) AddDial(nodeID *discover.NodeID, opKey *common.Address, peerType PeerType, isAddPeer bool) error

func (*BasePtt) AddJoinKey

func (p *BasePtt) AddJoinKey(hash *common.Address, entityID *types.PttID, isLocked bool) error

func (*BasePtt) AddNewPeer

func (p *BasePtt) AddNewPeer(peer *PttPeer) error

AddPeer adds a new peer. expected no user-id.

  1. validate peer as random.
  2. set peer type as random.
  3. check dial-entity
  4. if there is a corresponding entity for dial: identify peer.

func (*BasePtt) AddOpKey

func (p *BasePtt) AddOpKey(hash *common.Address, entityID *types.PttID, isLocked bool) error

func (*BasePtt) ApproveJoin

func (p *BasePtt) ApproveJoin(confirmKey []byte) error

ApproveJoin approves join (invitor)

func (*BasePtt) BEGetPeers

func (p *BasePtt) BEGetPeers() ([]*BackendPeer, error)

func (*BasePtt) BEGetPttOplogList

func (p *BasePtt) BEGetPttOplogList(logIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*PttOplog, error)

func (*BasePtt) CheckDialEntityAndIdentifyPeer

func (p *BasePtt) CheckDialEntityAndIdentifyPeer(peer *PttPeer) error

func (*BasePtt) ClosePeers

func (p *BasePtt) ClosePeers()

func (*BasePtt) CountEntities

func (p *BasePtt) CountEntities() (int, error)

func (*BasePtt) CountPeers

func (p *BasePtt) CountPeers() (*BackendCountPeers, error)

func (*BasePtt) DecryptData

func (p *BasePtt) DecryptData(ciphertext []byte, keyInfo *KeyInfo) (OpType, []byte, error)

DecryptData decrypts data in ptt-layer. Reference: https://gist.github.com/stupidbodo/601b68bfef3449d1b8d9

func (*BasePtt) EncryptData

func (p *BasePtt) EncryptData(op OpType, data []byte, keyInfo *KeyInfo) ([]byte, error)

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) ErrChan

func (p *BasePtt) ErrChan() *types.Chan

func (*BasePtt) FinishIdentifyPeer

func (p *BasePtt) FinishIdentifyPeer(peer *PttPeer, isLocked bool, isResetPeerType bool) error

func (*BasePtt) GenerateNodeInfo

func (p *BasePtt) GenerateNodeInfo() func() interface{}

func (*BasePtt) GeneratePeerInfo

func (p *BasePtt) GeneratePeerInfo() func(id discover.NodeID) interface{}

func (*BasePtt) GenerateProtocols

func (p *BasePtt) GenerateProtocols() []p2p.Protocol

func (*BasePtt) GenerateRun

func (p *BasePtt) GenerateRun(version uint) func(peer *p2p.Peer, rw p2p.MsgReadWriter) error

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.)

  1. set up ptt-peer.
  2. peerWG.
  3. handle-peer.

func (*BasePtt) GetConfirmJoins

func (p *BasePtt) GetConfirmJoins() ([]*BackendConfirmJoin, error)

func (*BasePtt) GetEntities

func (p *BasePtt) GetEntities() map[types.PttID]Entity

func (*BasePtt) GetGitCommit

func (p *BasePtt) GetGitCommit() (string, error)

func (*BasePtt) GetJoins

func (p *BasePtt) GetJoins() map[common.Address]*types.PttID

func (*BasePtt) GetLastAnnounceP2PTS

func (p *BasePtt) GetLastAnnounceP2PTS() (types.Timestamp, error)

func (*BasePtt) GetMyEntity

func (p *BasePtt) GetMyEntity() MyEntity

func (*BasePtt) GetMyEntityFromMe

func (p *BasePtt) GetMyEntityFromMe(myID *types.PttID) Entity

func (*BasePtt) GetMyService

func (p *BasePtt) GetMyService() Service

func (*BasePtt) GetOps

func (p *BasePtt) GetOps() map[common.Address]*types.PttID

func (*BasePtt) GetPeer

func (p *BasePtt) GetPeer(id *discover.NodeID, isLocked bool) *PttPeer

GetPeer gets specific peer

func (*BasePtt) GetPeerByUserID

func (p *BasePtt) GetPeerByUserID(id *types.PttID, isLocked bool) (*PttPeer, error)

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) GetPttOplogSeen

func (p *BasePtt) GetPttOplogSeen() (types.Timestamp, error)

func (*BasePtt) GetVersion

func (p *BasePtt) GetVersion() (string, error)

func (*BasePtt) HandleApproveJoin

func (p *BasePtt) HandleApproveJoin(dataBytes []byte, hash *common.Address, joinRequest *JoinRequest, peer *PttPeer) error

func (*BasePtt) HandleCodeEntityDeleted

func (p *BasePtt) HandleCodeEntityDeleted(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeIdentifyPeer

func (p *BasePtt) HandleCodeIdentifyPeer(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeIdentifyPeerFail

func (p *BasePtt) HandleCodeIdentifyPeerFail(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeIdentifyPeerWithMyID

func (p *BasePtt) HandleCodeIdentifyPeerWithMyID(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeIdentifyPeerWithMyIDAck

func (p *BasePtt) HandleCodeIdentifyPeerWithMyIDAck(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeIdentifyPeerWithMyIDChallenge

func (p *BasePtt) HandleCodeIdentifyPeerWithMyIDChallenge(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeIdentifyPeerWithMyIDChallengeAck

func (p *BasePtt) HandleCodeIdentifyPeerWithMyIDChallengeAck(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeJoin

func (p *BasePtt) HandleCodeJoin(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeJoinAck

func (p *BasePtt) HandleCodeJoinAck(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeOp

func (p *BasePtt) HandleCodeOp(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeOpCheckMember

func (p *BasePtt) HandleCodeOpCheckMember(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeOpCheckMemberAck

func (p *BasePtt) HandleCodeOpCheckMemberAck(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeOpFail

func (p *BasePtt) HandleCodeOpFail(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeRequestOpKey

func (p *BasePtt) HandleCodeRequestOpKey(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeRequestOpKeyAck

func (p *BasePtt) HandleCodeRequestOpKeyAck(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleCodeRequestOpKeyFail

func (p *BasePtt) HandleCodeRequestOpKeyFail(hash *common.Address, encData []byte, peer *PttPeer) error

func (*BasePtt) HandleEntityTerminal

func (p *BasePtt) HandleEntityTerminal(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) HandleIdentifyPeerAck

func (p *BasePtt) HandleIdentifyPeerAck(entityID *types.PttID, data *IdentifyPeerAck, peer *PttPeer) error

HandleIdentifyPeerAck

func (*BasePtt) HandleIdentifyPeerFail

func (p *BasePtt) HandleIdentifyPeerFail(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) HandleIdentifyPeerWithMyID

func (p *BasePtt) HandleIdentifyPeerWithMyID(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) HandleIdentifyPeerWithMyIDAck

func (p *BasePtt) HandleIdentifyPeerWithMyIDAck(dataBytes []byte, peer *PttPeer) error

HandleIdentifyPeerWithMyIDAck

func (*BasePtt) HandleIdentifyPeerWithMyIDChallenge

func (p *BasePtt) HandleIdentifyPeerWithMyIDChallenge(dataBytes []byte, peer *PttPeer) error

HandleIdentifyPeerWithMyIDChallenge handles IdentifyPeerWithMyIDChallenge (requester)

func (*BasePtt) HandleIdentifyPeerWithMyIDChallengeAck

func (p *BasePtt) HandleIdentifyPeerWithMyIDChallengeAck(dataBytes []byte, peer *PttPeer) error

HandleIdentifyPeerWithMyIDChallengeAck handles IdentifyPeerWithMyIDChallengeAck (acker)

func (*BasePtt) HandleJoin

func (p *BasePtt) HandleJoin(dataBytes []byte, hash *common.Address, entity Entity, pm ProtocolManager, keyInfo *KeyInfo, peer *PttPeer) error

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)

  1. if the entity auto-rejects the entity-id and node-id: => return err
  2. if the entity auto-approves the entity-id and node-id => do approve.
  3. put to confirm-queue.

func (*BasePtt) HandleMessage

func (p *BasePtt) HandleMessage(code CodeType, data *PttData, peer *PttPeer) error

HandleMessage handles message

func (*BasePtt) HandleMessageWrapper

func (p *BasePtt) HandleMessageWrapper(peer *PttPeer) error

HandleMessageWrapper

func (*BasePtt) HandleOpCheckMember

func (p *BasePtt) HandleOpCheckMember(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) HandleOpCheckMemberAck

func (p *BasePtt) HandleOpCheckMemberAck(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) HandleOpFail

func (p *BasePtt) HandleOpFail(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) HandlePeer

func (p *BasePtt) HandlePeer(peer *PttPeer) error

HandlePeer handles peer

  1. Basic handshake
  2. AddNewPeer (defer RemovePeer)
  3. init read/write
  4. for-loop handle-message

func (*BasePtt) HandleRequestOpKey

func (p *BasePtt) HandleRequestOpKey(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) HandleRequestOpKeyAck

func (p *BasePtt) HandleRequestOpKeyAck(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) HandleRequestOpKeyFail

func (p *BasePtt) HandleRequestOpKeyFail(dataBytes []byte, peer *PttPeer) error

func (*BasePtt) IdentifyPeer

func (p *BasePtt) IdentifyPeer(entityID *types.PttID, quitSync chan struct{}, peer *PttPeer, isForce bool) (*IdentifyPeer, error)

func (*BasePtt) IdentifyPeerAck

func (p *BasePtt) IdentifyPeerAck(challenge *types.Salt, peer *PttPeer) (*IdentifyPeerAck, error)

IdentifyPeerAck

func (*BasePtt) IdentifyPeerFail

func (p *BasePtt) IdentifyPeerFail(hash *common.Address, peer *PttPeer) error

IdentifyPeerFail acks PMIdentifyPeer as failed

func (*BasePtt) IdentifyPeerWithMyID

func (p *BasePtt) IdentifyPeerWithMyID(peer *PttPeer) error

IdentifyPeerWithMyID ask for identifying peer with providing my-id (requester)

func (*BasePtt) IdentifyPeerWithMyIDAck

func (p *BasePtt) IdentifyPeerWithMyIDAck(challenge *types.Salt, peer *PttPeer) error

IdentifyPeerWithMyIDAck

func (*BasePtt) IdentifyPeerWithMyIDChallenge

func (p *BasePtt) IdentifyPeerWithMyIDChallenge(userID *types.PttID, peer *PttPeer) error

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) IsHubPeer

func (p *BasePtt) IsHubPeer(peer *PttPeer) bool

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) LockJoins

func (p *BasePtt) LockJoins()

func (*BasePtt) LockOps

func (p *BasePtt) LockOps()

func (*BasePtt) MarkPttOplogSeen

func (p *BasePtt) MarkPttOplogSeen() (types.Timestamp, error)

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

func (p *BasePtt) MarshalDataWithoutHash(code CodeType, 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) MyNodeID

func (p *BasePtt) MyNodeID() *discover.NodeID

func (*BasePtt) MyNodeKey

func (p *BasePtt) MyNodeKey() *ecdsa.PrivateKey

func (*BasePtt) MyNodeType

func (p *BasePtt) MyNodeType() NodeType

func (*BasePtt) MyRaftID

func (p *BasePtt) MyRaftID() uint64

func (*BasePtt) NewPeer

func (p *BasePtt) NewPeer(version uint, peer *p2p.Peer, rw p2p.MsgReadWriter) (*PttPeer, error)

NewPeer inits PttPeer

func (*BasePtt) NoMorePeers

func (p *BasePtt) NoMorePeers() chan struct{}

func (*BasePtt) NodeInfo

func (p *BasePtt) NodeInfo() interface{}

func (*BasePtt) NotifyNodeRestart

func (p *BasePtt) NotifyNodeRestart() *types.Chan

func (*BasePtt) NotifyNodeStop

func (p *BasePtt) NotifyNodeStop() *types.Chan

func (*BasePtt) OpCheckMember

func (p *BasePtt) OpCheckMember(entityID *types.PttID, peer *PttPeer) error

func (*BasePtt) OpCheckMemberAck

func (p *BasePtt) OpCheckMemberAck(
	entityID *types.PttID,
	memberLog *BaseOplog,
	peer *PttPeer,
) error

func (*BasePtt) OpFail

func (p *BasePtt) OpFail(hash *common.Address, peer *PttPeer) error

func (*BasePtt) Prestart

func (p *BasePtt) Prestart() error

func (*BasePtt) Protocols

func (p *BasePtt) Protocols() []p2p.Protocol

func (*BasePtt) PttAPIs

func (p *BasePtt) PttAPIs() []rpc.API

func (*BasePtt) RWInit

func (p *BasePtt) RWInit(peer *PttPeer, version uint)

func (*BasePtt) RegisterEntity

func (p *BasePtt) RegisterEntity(e Entity, isLocked bool, isPeerLocked bool) error

func (*BasePtt) RegisterEntityPeerWithOtherUserID

func (p *BasePtt) RegisterEntityPeerWithOtherUserID(e Entity, id *types.PttID, peerType PeerType, isLocked bool) error

func (*BasePtt) RegisterPeerToEntities

func (p *BasePtt) RegisterPeerToEntities(peer *PttPeer) error

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

func (p *BasePtt) RegisterService(service Service) error

RegisterService registers service into ptt.

func (*BasePtt) RemoveJoinKey

func (p *BasePtt) RemoveJoinKey(hash *common.Address, entityID *types.PttID, isLocked bool) error

func (*BasePtt) RemoveOpHash

func (p *BasePtt) RemoveOpHash(hash *common.Address) error

func (*BasePtt) RemoveOpKey

func (p *BasePtt) RemoveOpKey(hash *common.Address, entityID *types.PttID, isLocked bool) error

func (*BasePtt) RemovePeer

func (p *BasePtt) RemovePeer(peer *PttPeer, isLocked bool) error

RemovePeer removes peer

  1. get reigsteredPeer
  2. unregister peer from entities
  3. unset peer type
  4. disconnect

func (*BasePtt) RequestOpKey

func (p *BasePtt) RequestOpKey(hash *common.Address, peer *PttPeer) error

func (*BasePtt) RequestOpKeyAck

func (p *BasePtt) RequestOpKeyAck(entityID *types.PttID, peer *PttPeer) error

func (*BasePtt) RequestOpKeyByEntity

func (p *BasePtt) RequestOpKeyByEntity(entity Entity, peer *PttPeer) error

func (*BasePtt) RequestOpKeyFail

func (p *BasePtt) RequestOpKeyFail(entityID *types.PttID, peer *PttPeer) error

func (*BasePtt) ResetPeerType

func (p *BasePtt) ResetPeerType(peer *PttPeer, isLocked bool, isForceReset bool) error

func (*BasePtt) Restart

func (p *BasePtt) Restart() (bool, error)

func (*BasePtt) SendDataToPeer

func (p *BasePtt) SendDataToPeer(code CodeType, data interface{}, peer *PttPeer) error

func (*BasePtt) Server

func (p *BasePtt) Server() *p2p.Server

func (*BasePtt) SetMyEntity

func (p *BasePtt) SetMyEntity(myEntity PttMyEntity) error

func (*BasePtt) SetPeerType

func (p *BasePtt) SetPeerType(peer *PttPeer, peerType PeerType, isForce bool, isLocked bool) error

SetPeerType sets the peer to the new peer-type and set in ptt peer-map.

func (*BasePtt) SetupPeer

func (p *BasePtt) SetupPeer(peer *PttPeer, peerType PeerType, isLocked bool) error

SetupPeer setup peer with known user-id and register to entities.

func (*BasePtt) Shutdown

func (p *BasePtt) Shutdown() (bool, error)

func (*BasePtt) Start

func (p *BasePtt) Start(server *p2p.Server) error

func (*BasePtt) Stop

func (p *BasePtt) Stop() error

func (*BasePtt) SyncWG

func (p *BasePtt) SyncWG() *sync.WaitGroup

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)

  1. If the nodeID is my node: return err because we dont join entity from our devices

  2. If the nodeID is my peer: do join.

  3. Else: do add peer.

func (*BasePtt) UnlockJoins

func (p *BasePtt) UnlockJoins()

func (*BasePtt) UnlockOps

func (p *BasePtt) UnlockOps()

func (*BasePtt) UnmarshalData

func (p *BasePtt) UnmarshalData(pttData *PttData) (CodeType, *common.Address, []byte, error)

UnmarshalData unmarshal the pttData to the original data

func (*BasePtt) UnregisterEntity

func (p *BasePtt) UnregisterEntity(e Entity, isLocked bool) error

func (*BasePtt) UnregisterPeerFromEntities

func (p *BasePtt) UnregisterPeerFromEntities(peer *PttPeer) error

UnregisterPeerFromEntities unregisters the peer from all the existing entities.

func (*BasePtt) UnsetPeerType

func (p *BasePtt) UnsetPeerType(peer *PttPeer, isLocked bool) error

UnsetPeerType unsets the peer from the ptt peer-map.

func (*BasePtt) ValidatePeer

func (p *BasePtt) ValidatePeer(nodeID *discover.NodeID, userID *types.PttID, peerType PeerType, isLocked bool) error

ValidatePeer validates peer

  1. no need to do anything with my device
  2. check repeated user-id
  3. check

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) ForceSync

func (b *BaseService) ForceSync(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 (svc *BaseService) GetMasterList(entityIDBytes []byte, startIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*Master, error)

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 (svc *BaseService) GetMemberList(entityIDBytes []byte, startIDBytes []byte, limit int, listOrder pttdb.ListOrder) ([]*Member, error)

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 (svc *BaseService) RevokeOpKey(entityIDBytes []byte, keyIDBytes []byte, myKey []byte) (bool, error)

func (*BaseService) SPM

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.

  1. new entity.
  2. add master. 2.1. add member.
  3. oplog.
  4. increate.
  5. force-sign oplog.
  6. entity-save. 6.1. SPM register entity.
  7. oplog-save.
  8. 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.

  1. lock.
  2. check is new.
  3. set JoinTS
  4. entity-save
  5. entity-init.
  6. master-log.
  7. member-log. 7.1: register master again (to help ptt-layer determining the status of the peer).
  8. oplog0.
  9. op-key.
  10. spm-registering.
  11. register member.
  12. 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

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) FromOplog

func (s *BaseSyncInfo) FromOplog(status types.Status, oplog *BaseOplog, opData OpData) error

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

func GetBlockList(blockInfo *BlockInfo, limit uint32, isLocked bool) ([]*Block, error)

GetBlockList gets the block list based on the information of block-info.

Always getting all blocks with pttdb.ListOrderNext

func NewBlock

func NewBlock(
	blockID uint32,
	subBlockID uint8,
	buf []byte,

) (*Block, error)

func NewEmptyBlock

func NewEmptyBlock() *Block

func (*Block) GetIter

func (b *Block) GetIter(listOrder pttdb.ListOrder, isLocked bool) (iterator.Iterator, error)

func (*Block) Marshal

func (b *Block) Marshal() ([]byte, error)

func (*Block) MarshalKey

func (b *Block) MarshalKey() ([]byte, error)

func (*Block) Prefix

func (b *Block) Prefix() ([]byte, error)

func (*Block) RemoveAll

func (b *Block) RemoveAll() error

func (*Block) Save

func (b *Block) Save() error

func (*Block) SetDB

func (b *Block) SetDB(
	db *pttdb.LDBBatch,
	fullDBPrefix []byte,

	objID *types.PttID,
	id *types.PttID,

)

func (*Block) Sign

func (b *Block) Sign(key *KeyInfo) error

func (*Block) Unmarshal

func (b *Block) Unmarshal(theBytes []byte) error

func (*Block) Verify

func (b *Block) Verify(expectedHash []byte, creatorID *types.PttID) error

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 NewBlockInfo(

	id *types.PttID,

	hashs [][][]byte,

	mediaIDs []*types.PttID,

	updaterID *types.PttID,

) (*BlockInfo, error)

func (*BlockInfo) GetBlockIterWithBlockInfo

func (b *BlockInfo) GetBlockIterWithBlockInfo(isLocked bool) (iterator.Iterator, error)

func (*BlockInfo) GetIsAllGood

func (b *BlockInfo) GetIsAllGood() bool

func (*BlockInfo) GetIsGood

func (b *BlockInfo) GetIsGood(blockID uint32, subBlockID uint8) types.Bool

func (*BlockInfo) Init

func (b *BlockInfo) Init(nBlock int)

func (*BlockInfo) InitIsGood

func (b *BlockInfo) InitIsGood()

func (*BlockInfo) Remove

func (b *BlockInfo) Remove(
	isLocked bool,

) error

func (*BlockInfo) ResetIsGood

func (b *BlockInfo) ResetIsGood()

func (*BlockInfo) SaveBlocks

func (b *BlockInfo) SaveBlocks(isLocked bool, blocks []*Block) error

func (*BlockInfo) SetBlockDB

func (b *BlockInfo) SetBlockDB(block *Block)

func (*BlockInfo) SetDB

func (b *BlockInfo) SetDB(
	db *pttdb.LDBBatch,
	dbLock *types.LockMap,
	fullDBPrefix []byte,

	objID *types.PttID,

	setMediaDB func(media *Media),
)

func (*BlockInfo) SetIsAllGood

func (b *BlockInfo) SetIsAllGood()

func (*BlockInfo) SetIsGood

func (b *BlockInfo) SetIsGood(blockID uint32, subBlockID uint8, isGood types.Bool)

func (*BlockInfo) VerifyBlock

func (b *BlockInfo) VerifyBlock(block *Block) bool

func (*BlockInfo) VerifyBlocks

func (b *BlockInfo) VerifyBlocks(blocks []*Block) ([]*Block, []*Block)

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

func UnmarshalCode(codeBytes []byte) (CodeType, error)

func (CodeType) String

func (c CodeType) String() string

type CommentType

type CommentType int

comment type

const (
	CommentTypePush CommentType = iota
	CommentTypeBoo
	CommentTypeNone
)

func (*CommentType) Marshal

func (c *CommentType) Marshal() []byte

type Config

type Config struct {
	MaxPeers          int
	MaxHubPeers       int
	MaxImportantPeers int
	MaxMemberPeers    int
	MaxPendingPeers   int
	MaxRandomPeers    int

	DataDir   string
	Version   string
	GitCommit string

	NodeType NodeType

	ExpireOplogSeconds int

	IsE2E bool

	IsPrivateAsPublic bool
}

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

type ContentBlock struct {
	BlockID uint32   `json:"ID"`
	Buf     [][]byte `json:"B,omitempty"`
}

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 NewCount

func NewCount(db *pttdb.LDBBatch, dbPrefixID *types.PttID, dbID *types.PttID, dbPrefix []byte, p uint, isNewBits bool) (*Count, error)

func (*Count) Add

func (c *Count) Add(item []byte)

Return: isNew

func (*Count) AddWithIsNew

func (c *Count) AddWithIsNew(item []byte) bool

Return: isNew

func (*Count) Count

func (c *Count) Count() uint64

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) Delete

func (c *Count) Delete() error

func (*Count) Intersect

func (c *Count) Intersect(c2 *Count) (*Count, error)

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) Load

func (c *Count) Load() error

func (*Count) MarshalKey

func (c *Count) MarshalKey() ([]byte, error)

func (*Count) NewBits

func (c *Count) NewBits()

func (*Count) Save

func (c *Count) Save() error

func (*Count) SetBits

func (c *Count) SetBits(bits types.BitVector)

func (*Count) SetDB

func (c *Count) SetDB(db *pttdb.LDBBatch, dbPrefixID *types.PttID, dbID *types.PttID, dbPrefix []byte)

func (*Count) SetHash

func (c *Count) SetHash()

func (*Count) Union

func (c *Count) Union(c2 *Count) (*Count, error)

Union 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

type CreateData

type CreateData interface{}

type DialHistory

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

func NewDialHistory

func NewDialHistory() *DialHistory

func (*DialHistory) Add

func (h *DialHistory) Add(id *discover.NodeID, opKey *common.Address) error

func (*DialHistory) Expire

func (h *DialHistory) Expire()

func (*DialHistory) Get

func (h *DialHistory) Get(id *discover.NodeID) *DialInfo

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 DialInfo

type DialInfo struct {
	NodeID   *discover.NodeID
	UpdateTS types.Timestamp
	OpKey    *common.Address
}

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:

  1. Creating an entity does not require the consensus from other nodes.
  2. We may recover a deleted entity.

type EntityDeleted

type EntityDeleted struct {
	EntityID  *types.PttID `json:"ID"`
	EntityLog *BaseOplog   `json:"E"`
	Status    types.Status `json:"S"`
}

type EntityType

type EntityType int

EntityType

const (
	EntityTypeInvalid EntityType = iota
	EntityTypePersonal
	EntityTypePrivate
	EntityTypePublic
)

type ForceSyncID

type ForceSyncID struct {
	ID *types.PttID
	TS types.Timestamp
}

func ProcessInfoToForceSyncIDList

func ProcessInfoToForceSyncIDList(info map[types.PttID]*BaseOplog) []*ForceSyncID

type ForceSyncObject

type ForceSyncObject struct {
	IDs []*ForceSyncID
}

type ForceSyncOplog

type ForceSyncOplog struct {
	FromTS types.Timestamp `json:"f"`
	ToTS   types.Timestamp `json:"t"`
}

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 IdentifyPeer struct {
	Challenge *types.Salt `json:"C"`
}

type IdentifyPeerAck

type IdentifyPeerAck struct {
	AckChallenge []byte        `json:"A,omitempty"`
	Hash         []byte        `json:"H,omitempty"`
	Sig          []byte        `json:"S,omitempty"`
	PubBytes     []byte        `json:"P,omitempty"`
	Extra        *KeyExtraInfo `json:"E,omitempty"`
	MyID         *types.PttID  `json:"M,omitempty"`
}

type IdentifyPeerFail

type IdentifyPeerFail struct {
	Hash *common.Address `json:"H"`
}

type IdentifyPeerWithMyID

type IdentifyPeerWithMyID struct {
	ID        *types.PttID
	Challenge *types.Salt `json:"C"`
}

type IdentifyPeerWithMyIDChallengeAck

type IdentifyPeerWithMyIDChallengeAck struct {
	Challenge *types.Salt      `json:"C"`
	AckData   *IdentifyPeerAck `json:"A"`
}

type Join

type Join struct {
	Hash      []byte `json:"H"`
	Challenge []byte `json:"C"`
}

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

type JoinEntity struct {
	ID          *types.PttID
	Name        []byte `json:"N"`
	Master0Hash []byte `json:"M"`
}

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 JoinType

type JoinType uint8
const (
	JoinTypeInvalid JoinType = iota
	JoinTypeMe
	JoinTypeFriend
	JoinTypeBoard
)

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 NewJoinKeyInfo

func NewJoinKeyInfo(entityID *types.PttID) (*KeyInfo, error)

func NewOpKeyInfo

func NewOpKeyInfo(entityID *types.PttID, doerID *types.PttID, masterKey *ecdsa.PrivateKey) (*KeyInfo, error)

func NewSignKeyInfo

func NewSignKeyInfo(doerID *types.PttID, masterKey *ecdsa.PrivateKey) (*KeyInfo, error)

func ObjsToOpKeys

func ObjsToOpKeys(objs []Object) []*KeyInfo

func (*KeyInfo) GetByID

func (k *KeyInfo) GetByID(isLocked bool) error

func (*KeyInfo) GetNewObjByID

func (k *KeyInfo) GetNewObjByID(id *types.PttID, isLocked bool) (Object, error)

func (*KeyInfo) GetSyncInfo

func (k *KeyInfo) GetSyncInfo() SyncInfo

func (*KeyInfo) GetUpdateTS

func (k *KeyInfo) GetUpdateTS() types.Timestamp

func (*KeyInfo) Init

func (k *KeyInfo) Init(
	pm ProtocolManager,
) error

func (*KeyInfo) Marshal

func (k *KeyInfo) Marshal() ([]byte, error)

func (*KeyInfo) MarshalKey

func (k *KeyInfo) MarshalKey() ([]byte, error)

func (*KeyInfo) NewEmptyObj

func (k *KeyInfo) NewEmptyObj() Object

func (*KeyInfo) RemoveMeta

func (k *KeyInfo) RemoveMeta()

func (*KeyInfo) Save

func (k *KeyInfo) Save(isLocked bool) error

func (*KeyInfo) SetSyncInfo

func (k *KeyInfo) SetSyncInfo(theSyncInfo SyncInfo) error

func (*KeyInfo) SetUpdateTS

func (k *KeyInfo) SetUpdateTS(ts types.Timestamp)

func (*KeyInfo) Unmarshal

func (k *KeyInfo) Unmarshal(data []byte) error

type KeyType

type KeyType uint8
const (
	KeyTypeBIP32 KeyType
)

type LRUCount

type LRUCount struct {
	*Count   `json:"C"`
	MaxCount uint64     `json:"M"`
	Full     types.Bool `json:"f"`
}

func NewLRUCount

func NewLRUCount(maxCount uint64, db *pttdb.LDBBatch, dbPrefixID *types.PttID, dbID *types.PttID, dbPrefix []byte, p uint, isNewBits bool) (*LRUCount, error)

func (*LRUCount) IsFull

func (l *LRUCount) IsFull() bool

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 NewMaster

func NewMaster(
	id *types.PttID,
	createTS types.Timestamp,
	creatorID *types.PttID,
	entityID *types.PttID,

	logID *types.PttID,

	status types.Status,

) *Master

func ObjsToMasters

func ObjsToMasters(objs []Object) []*Master

func (*Master) GetByID

func (m *Master) GetByID(isLocked bool) error

func (*Master) GetNewObjByID

func (m *Master) GetNewObjByID(id *types.PttID, isLocked bool) (Object, error)

func (*Master) GetSyncInfo

func (m *Master) GetSyncInfo() SyncInfo

func (*Master) GetUpdateTS

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

func (*Master) Marshal

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

func (*Master) MarshalKey

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

func (*Master) NewEmptyObj

func (m *Master) NewEmptyObj() Object

func (*Master) Save

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

func (*Master) SetSyncInfo

func (m *Master) SetSyncInfo(theSyncInfo SyncInfo) error

func (*Master) SetUpdateTS

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

func (*Master) Unmarshal

func (m *Master) Unmarshal(data []byte) error

type MasterOpCreateMaster

type MasterOpCreateMaster struct {
}

type MasterOplog

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

func NewMasterOplog

func NewMasterOplog(keyID *types.PttID, ts types.Timestamp, doerID *types.PttID, op OpType, opData OpData, db *pttdb.LDBBatch, entityID *types.PttID, dbLock *types.LockMap) (*MasterOplog, error)

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 NewMedia

func NewMedia(
	createTS types.Timestamp,
	creatorID *types.PttID,
	entityID *types.PttID,

	logID *types.PttID,

	status types.Status,

) (*Media, error)

func ObjsToMedias

func ObjsToMedias(objs []Object) []*Media

func (*Media) DeleteAll

func (m *Media) DeleteAll(
	isLocked bool,
) error

func (*Media) GetBuf

func (m *Media) GetBuf() error

get buf

func (*Media) GetByID

func (m *Media) GetByID(isLocked bool) error

func (*Media) GetNewObjByID

func (m *Media) GetNewObjByID(id *types.PttID, isLocked bool) (Object, error)

func (*Media) GetSyncInfo

func (m *Media) GetSyncInfo() SyncInfo

func (*Media) GetUpdateTS

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

func (*Media) Marshal

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

func (*Media) MarshalKey

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

func (*Media) NewEmptyObj

func (m *Media) NewEmptyObj() Object

func (*Media) Save

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

func (*Media) SetBlockDB

func (m *Media) SetBlockDB(block *Block)

func (*Media) SetSyncInfo

func (m *Media) SetSyncInfo(theSyncInfo SyncInfo) error

func (*Media) SetUpdateTS

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

func (*Media) Unmarshal

func (m *Media) Unmarshal(data []byte) error

type MediaData

type MediaData interface{}

type MediaDataFile

type MediaDataFile struct {
	Filename []byte `json:"f"`
}

type MediaDataGIF

type MediaDataGIF struct {
	Width  uint16 `json:"W"`
	Height uint16 `json:"H"`
}

type MediaDataJPEG

type MediaDataJPEG struct {
	Width  uint16 `json:"W"`
	Height uint16 `json:"H"`
}

type MediaDataPNG

type MediaDataPNG struct {
	Width  uint16 `json:"W"`
	Height uint16 `json:"H"`
}

type MediaType

type MediaType uint8
const (
	MediaTypeJPEG MediaType = iota
	MediaTypeGIF
	MediaTypePNG
	MediaTypeFile
)

func NormalizeImage

func NormalizeImage(theBytes []byte) (MediaType, interface{}, []byte, error)

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 NewMember

func NewMember(
	id *types.PttID,
	createTS types.Timestamp,
	creatorID *types.PttID,
	entityID *types.PttID,

	logID *types.PttID,

	status types.Status,
) *Member

func ObjsToMembers

func ObjsToMembers(objs []Object) []*Member

func (*Member) GetByID

func (m *Member) GetByID(isLocked bool) error

func (*Member) GetNewObjByID

func (m *Member) GetNewObjByID(id *types.PttID, isLocked bool) (Object, error)

func (*Member) GetSyncInfo

func (m *Member) GetSyncInfo() SyncInfo

func (*Member) GetUpdateTS

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

func (*Member) Marshal

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

func (*Member) MarshalKey

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

func (*Member) NewEmptyObj

func (m *Member) NewEmptyObj() Object

func (*Member) Save

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

func (*Member) SetSyncInfo

func (m *Member) SetSyncInfo(theSyncInfo SyncInfo) error

func (*Member) SetUpdateTS

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

func (*Member) Unmarshal

func (m *Member) Unmarshal(data []byte) error

type MemberOpAddMember

type MemberOpAddMember struct {
}

type MemberOpDeleteMember

type MemberOpDeleteMember struct {
}

type MemberOplog

type MemberOplog struct {
	*BaseOplog `json:"O"`
}

func NewMemberOplog

func NewMemberOplog(keyID *types.PttID, ts types.Timestamp, doerID *types.PttID, op OpType, opData OpData, db *pttdb.LDBBatch, entityID *types.PttID, dbLock *types.LockMap) (*MemberOplog, error)

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 NewMerkle

func NewMerkle(dbOplogPrefix []byte, dbMerklePrefix []byte, prefixID *types.PttID, db *pttdb.LDBBatch, name string) (*Merkle, error)

func (*Merkle) Clean

func (m *Merkle) Clean()

func (*Merkle) DBPrefix

func (m *Merkle) DBPrefix() []byte

func (*Merkle) ForceSaveSyncTime

func (m *Merkle) ForceSaveSyncTime(ts types.Timestamp) error

func (*Merkle) ForceSync

func (m *Merkle) ForceSync() chan struct{}

func (*Merkle) GetAndResetToUpdateTSList

func (m *Merkle) GetAndResetToUpdateTSList() ([]int64, error)

func (*Merkle) GetChildKeys

func (m *Merkle) GetChildKeys(level MerkleTreeLevel, ts types.Timestamp) ([][]byte, error)

func (*Merkle) GetChildNodes

func (m *Merkle) GetChildNodes(level MerkleTreeLevel, ts types.Timestamp) ([]*MerkleNode, error)

func (*Merkle) GetFailSyncTime

func (m *Merkle) GetFailSyncTime() (types.Timestamp, error)

func (*Merkle) GetGenerateTime

func (m *Merkle) GetGenerateTime() (types.Timestamp, error)

func (*Merkle) GetMerkleIter

func (m *Merkle) GetMerkleIter(level MerkleTreeLevel, ts types.Timestamp, nextTS types.Timestamp, listOrder pttdb.ListOrder) (iterator.Iterator, error)

func (*Merkle) GetMerkleIterByKey

func (m *Merkle) GetMerkleIterByKey(startKey []byte, level MerkleTreeLevel, listOrder pttdb.ListOrder) (iterator.Iterator, error)

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) GetSyncTime

func (m *Merkle) GetSyncTime() (types.Timestamp, error)

func (*Merkle) LoadToUpdateTSs

func (m *Merkle) LoadToUpdateTSs() error

func (*Merkle) LoadUpdatingTSList

func (m *Merkle) LoadUpdatingTSList() ([]int64, error)

func (*Merkle) MarshalFailSyncTimeKey

func (m *Merkle) MarshalFailSyncTimeKey() ([]byte, error)

func (*Merkle) MarshalGenerateTimeKey

func (m *Merkle) MarshalGenerateTimeKey() ([]byte, error)

func (*Merkle) MarshalKey

func (m *Merkle) MarshalKey(level MerkleTreeLevel, ts types.Timestamp) ([]byte, error)

func (*Merkle) MarshalSyncTimeKey

func (m *Merkle) MarshalSyncTimeKey() ([]byte, error)

func (*Merkle) MarshalToUpdateTSKey

func (m *Merkle) MarshalToUpdateTSKey(ts types.Timestamp) []byte

func (*Merkle) MarshalUpdatingKey

func (m *Merkle) MarshalUpdatingKey() []byte

func (*Merkle) ResetUpdateTS

func (m *Merkle) ResetUpdateTS() error

func (*Merkle) ResetUpdatingTSList

func (m *Merkle) ResetUpdatingTSList() error

func (*Merkle) SaveFailSyncTime

func (m *Merkle) SaveFailSyncTime(ts types.Timestamp) error

func (*Merkle) SaveGenerateTime

func (m *Merkle) SaveGenerateTime(ts types.Timestamp) error

func (*Merkle) SaveMerkleTree

func (m *Merkle) SaveMerkleTree(ts types.Timestamp) error

func (*Merkle) SaveMerkleTreeCore

func (m *Merkle) SaveMerkleTreeCore(level MerkleTreeLevel, offsetTS types.Timestamp, nextTS types.Timestamp, updateTS types.Timestamp) (types.Timestamp, error)

func (*Merkle) SaveSyncTime

func (m *Merkle) SaveSyncTime(ts types.Timestamp) error

func (*Merkle) SetUpdateTS

func (m *Merkle) SetUpdateTS(ts types.Timestamp) error

func (*Merkle) SetUpdateTS2

func (m *Merkle) SetUpdateTS2(ts types.Timestamp, ts2 types.Timestamp) error

func (*Merkle) ToGenerateTime

func (m *Merkle) ToGenerateTime() types.Timestamp

func (*Merkle) ToSyncTime

func (m *Merkle) ToSyncTime() (types.Timestamp, error)

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 MyService

type MyService interface {
	Service
}

type NodeType

type NodeType int

NodeType

const (
	NodeTypeUnknown NodeType = iota
	NodeTypeMobile
	NodeTypeDesktop
	NodeTypeServer
)

func (NodeType) String

func (n NodeType) String() string

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 AliveObjects(theObjs []Object) []Object

func GetObjList

func GetObjList(obj Object, startID *types.PttID, limit int, listOrder pttdb.ListOrder, isLocked bool) ([]Object, error)

func MastersToObjs

func MastersToObjs(typedObjs []*Master) []Object

func MediasToObjs

func MediasToObjs(typedObjs []*Media) []Object

func MembersToObjs

func MembersToObjs(typedObjs []*Member) []Object

func OpKeysToObjs

func OpKeysToObjs(typedObjs []*KeyInfo) []Object

type OpCheckMember

type OpCheckMember struct {
	EntityID *types.PttID `json:"ID"`
	MyLog    *BaseOplog   `json:"m"`
	TheirLog *BaseOplog   `json:"t"`
}

type OpCheckMemberAck

type OpCheckMemberAck struct {
	EntityID *types.PttID `json:"ID"`
	Log      *BaseOplog   `json:"l"`
}

type OpClass

type OpClass int
const (
	OpClassInvalid OpClass = iota
	OpClassCreate
	OpClassUpdate
	OpClassDelete
	OpClassOther
)

type OpCreateMedia

type OpCreateMedia struct {
	BlockInfoID *types.PttID `json:"BID"`
	Hashs       [][][]byte   `json:"H"`
	NBlock      int          `json:"NB"`
}

type OpData

type OpData interface{}

OpData

type OpDeleteMedia

type OpDeleteMedia struct{}

type OpFail

type OpFail struct {
	Hash *common.Address `json:"H"`
}

type OpKeyFail

type OpKeyFail struct {
	EntityID *types.PttID `json:"ID"`
}

type OpKeyOpCreateOpKey

type OpKeyOpCreateOpKey struct {
}

type OpKeyOpRevokeOpKey

type OpKeyOpRevokeOpKey struct {
}

type OpKeyOplog

type OpKeyOplog struct {
	*BaseOplog `json:"O"`
}

func NewOpKeyOplog

func NewOpKeyOplog(keyID *types.PttID, ts types.Timestamp, doerID *types.PttID, op OpType, opData OpData, db *pttdb.LDBBatch, entityID *types.PttID, dbLock *types.LockMap) (*OpKeyOplog, error)

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 (
	ZeroOpType OpType = 0
	MaxOpType  OpType = 0xffffffff
)
const (
	PttOpTypeCreateMe OpType

	PttOpTypeCreateArticle
	PttOpTypeCreateComment
	PttOpTypeCreateReply

	PttOpTypeCreateFriend
	PttOpTypeJoinBoard
)

func UnmarshalOp

func UnmarshalOp(opBytes []byte) (OpType, error)

type Oplog

type Oplog interface {
	GetBaseOplog() *BaseOplog
	Save(isLocked bool, merkle *Merkle) error
	Delete(isLocked bool) error

	SetPreLogID(logID *types.PttID)
	ToStatus() types.Status
}

type PeerType

type PeerType int
const (
	PeerTypeErr PeerType = iota
	PeerTypeRemoved
	PeerTypeRandom
	PeerTypePending
	PeerTypeMember
	PeerTypeImportant
	PeerTypeHub
	PeerTypeMe
	NPeerType
)

func (PeerType) String

func (p PeerType) String() string

type PersonOpTransferPerson

type PersonOpTransferPerson struct {
	ToID *types.PttID `json:"t"`
}

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) GetJoins

func (api *PrivateAPI) GetJoins() (map[common.Address]*types.PttID, 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) GetOps

func (api *PrivateAPI) GetOps() (map[common.Address]*types.PttID, error)

func (*PrivateAPI) GetPeers

func (api *PrivateAPI) GetPeers() ([]*BackendPeer, error)

func (*PrivateAPI) GetPttOplogList

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

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) SetLocale

func (api *PrivateAPI) SetLocale(locale Locale) (Locale, 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

func (*PttData) Clone

func (p *PttData) Clone() *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 PttNodeInfo struct {
	NodeID *discover.NodeID `json:"N"`
	UserID *types.PttID     `json:"U"`

	Peers    int `json:"NP"`
	Entities int `json:"NE"`
	Services int `json:"NS"`
}

type PttOpCreateArticle

type PttOpCreateArticle struct {
	BoardID *types.PttID `json:"bID"`
	Title   []byte       `json:"T"`
}

type PttOpCreateComment

type PttOpCreateComment struct {
	BoardID   *types.PttID `json:"bID"`
	ArticleID *types.PttID `json:"aID"`
}

type PttOpCreateFriend

type PttOpCreateFriend struct{}

type PttOpCreateMe

type PttOpCreateMe struct {
	NodeID *discover.NodeID `json:"ID"`
}

type PttOpCreateReply

type PttOpCreateReply struct {
	BoardID   *types.PttID `json:"bID"`
	ArticleID *types.PttID `json:"aID"`
	CommentID *types.PttID `json:"cID"`
}

type PttOpJoinBoard

type PttOpJoinBoard struct{}

type PttOplog

type PttOplog struct {
	*BaseOplog `json:"O"`
}

func NewPttOplog

func NewPttOplog(objID *types.PttID, ts types.Timestamp, doerID *types.PttID, op OpType, data OpData, myID *types.PttID) (*PttOplog, error)

func OplogsToPttOplogs

func OplogsToPttOplogs(logs []*BaseOplog) []*PttOplog

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 NewPttPeer(version uint, p *p2p.Peer, rw p2p.MsgReadWriter, ptt *BasePtt) (*PttPeer, error)

func RandomPeer

func RandomPeer(peerList []*PttPeer) *PttPeer

func (*PttPeer) Broadcast

func (p *PttPeer) Broadcast() error

func (*PttPeer) FinishID

func (p *PttPeer) FinishID(entityID *types.PttID)

FinishID finishes info for identifying user-id (remove info)

func (*PttPeer) GetID

func (p *PttPeer) GetID() *discover.NodeID

func (*PttPeer) GetPeer

func (p *PttPeer) GetPeer() *p2p.Peer

func (*PttPeer) Handshake

func (p *PttPeer) Handshake(networkID uint32) error

func (*PttPeer) Info

func (p *PttPeer) Info() interface{}

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 (p *PttPeer) ReadStatus(networkID uint32) error

func (*PttPeer) ResetInitID

func (p *PttPeer) ResetInitID()

func (*PttPeer) SendData

func (p *PttPeer) SendData(data *PttData) error

func (*PttPeer) String

func (p *PttPeer) String() string

func (*PttPeer) Version

func (p *PttPeer) Version() uint

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 (ps *PttPeerSet) GetPeerWithPeerType(id *discover.NodeID, peerType PeerType, isLocked bool) *PttPeer

func (*PttPeerSet) GetPendingPeerByUserID

func (ps *PttPeerSet) GetPendingPeerByUserID(id *types.PttID, isLocked bool) (*PttPeer, error)

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 (ps *PttPeerSet) PeersToPeerList(peers map[discover.NodeID]*PttPeer, isLocked bool) []*PttPeer

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

func (ps *PttPeerSet) UnregisterPeerByOtherUserID(id *types.PttID, isLocked bool) (*PttPeer, PeerType, error)

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 PttStatus

type PttStatus struct {
	Version   uint32
	NetworkID uint32
}

PttStatus

type RequestOpKey

type RequestOpKey struct {
	EntityID  *types.PttID `json:"ID"`
	OpKeys    []*KeyInfo   `json:"o"`
	OpKeyLogs []*BaseOplog `json:"O"`
}

type RequestOpKeyAck

type RequestOpKeyAck struct {
	EntityID *types.PttID `json:"ID"`
	OpKeys   []*KeyInfo   `json:"k"`
	Logs     []*BaseOplog `json:"l"`
}

type SendDataToPeerWithCodeEvent

type SendDataToPeerWithCodeEvent struct {
	Code CodeType
	Op   OpType
	Data interface{}
	Peer *PttPeer
}

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 SignInfo

type SignInfo struct {
	ID       *types.PttID    `json:"ID"`
	CreateTS types.Timestamp `json:"CT"`

	Hash   []byte        `json:"H"`
	Salt   types.Salt    `json:"s"`
	Sig    []byte        `json:"S"`
	Pubkey []byte        `json:"K"`
	Extra  *KeyExtraInfo `json:"e,omitempty"`
}

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 SyncID

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

func ProcessInfoToSyncIDList

func ProcessInfoToSyncIDList(info map[types.PttID]*BaseOplog, op OpType) []*SyncID

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 SyncOplogAck struct {
	TS    types.Timestamp
	Nodes []*MerkleNode `json:"N"`

	StartHourTS types.Timestamp `json:"STS"`
	EndHourTS   types.Timestamp `json:"ETS"`
	StartTS     types.Timestamp `json:"sTS"`
	EndTS       types.Timestamp `json:"eTS"`
}

type SyncOplogAckInvalid

type SyncOplogAckInvalid struct {
	FromTS types.Timestamp `json:"f"`
	ToTS   types.Timestamp `json:"t"`
}

type SyncOplogNewOplogs

type SyncOplogNewOplogs struct {
	TS        types.Timestamp
	Oplogs    []*BaseOplog `json:"O"`
	MyNewKeys [][]byte     `json:"K"`
}

type SyncOplogNewOplogsAck

type SyncOplogNewOplogsAck struct {
	TS     types.Timestamp
	Oplogs []*BaseOplog `json:"O"`
}

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

Jump to

Keyboard shortcuts

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