Documentation
¶
Index ¶
- func Filter(update *Update, sources Sources) bool
- func Sort(history []*Update)
- type Accept
- type CreateIdFn
- type IsAccepted
- type Option
- type Protocol
- type Scuttlebutt
- func (sb *Scuttlebutt) ApplyUpdates(update *Update) bool
- func (sb *Scuttlebutt) Dispose()
- func (sb *Scuttlebutt) History(peerSources Sources, accept interface{}) []*Update
- func (sb *Scuttlebutt) Id() SourceId
- func (sb *Scuttlebutt) IsAccepted(peerAccept interface{}, update *Update) bool
- func (sb *Scuttlebutt) LocalUpdate(any map[string]interface{})
- func (sb *Scuttlebutt) Update(update *Update) bool
- type Sign
- type SourceId
- type Sources
- type Timestamp
- type Update
- type Verify
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CreateIdFn ¶
type CreateIdFn func() SourceId
type IsAccepted ¶
type Scuttlebutt ¶
type Scuttlebutt struct {
Protocol
*event.Emitter
Accept *Accept
Sources Sources
Streams int
// contains filtered or unexported fields
}
func NewScuttlebutt ¶
func NewScuttlebutt(protocol Protocol, opts ...Option) *Scuttlebutt
func (*Scuttlebutt) ApplyUpdates ¶
func (sb *Scuttlebutt) ApplyUpdates(update *Update) bool
func (*Scuttlebutt) Dispose ¶ added in v1.0.1
func (sb *Scuttlebutt) Dispose()
each stream will be ended due to this event
func (*Scuttlebutt) History ¶
func (sb *Scuttlebutt) History(peerSources Sources, accept interface{}) []*Update
func (*Scuttlebutt) Id ¶
func (sb *Scuttlebutt) Id() SourceId
func (*Scuttlebutt) IsAccepted ¶
func (sb *Scuttlebutt) IsAccepted(peerAccept interface{}, update *Update) bool
func (*Scuttlebutt) LocalUpdate ¶
func (sb *Scuttlebutt) LocalUpdate(any map[string]interface{})
func (*Scuttlebutt) Update ¶
func (sb *Scuttlebutt) Update(update *Update) bool
type Timestamp ¶
type Timestamp int64
"我"所知道的所有和“我”相连的节点(包括我自己的)的最新时间戳 会随着后续所有 stream 上收到的 Update 来更新
type Update ¶
type Update struct {
Data map[string]interface{} `json:"data"`
Timestamp Timestamp `json:"timestamp"`
SourceId SourceId `json:"source_id"`
From SourceId `json:"from"`
Digest string `json:"digest"`
}
一次更新
func (*Update) MarshalJSON ¶ added in v1.1.0
todo.test
func (*Update) UnmarshalJSON ¶ added in v1.1.0
Click to show internal directories.
Click to hide internal directories.