Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Idle indicates an idle state Idle = iota // Init indicates the state when first block is received Init = Idle + 1 // Active indicates the state after first block has been processed Active = Init + 1 )
View Source
const ( // Open indicates an open state Open = iota // Closing indicates a closing state Closing = Open + 1 // Closed indicates a closed state Closed = Closing + 1 )
Variables ¶
View Source
var ( // ErrInvalidRange indicates invalid range. ErrInvalidRange = errors.New("invalid open/close values") )
View Source
var WindowSize uint32 = 8
WindowSize defines the size of window
Functions ¶
Types ¶
type BlockSync ¶
type BlockSync interface { Start() error Stop() error P2P() *network.Overlay ProcessSyncRequest(sender string, sync *pb.BlockSync) error ProcessBlock(blk *bc.Block) error ProcessBlockSync(blk *bc.Block) error }
BlockSync defines the interface of blocksyncer
type SlidingWindow ¶
type SlidingWindow struct { State int // contains filtered or unexported fields }
SlidingWindow implements a sliding window
func NewSlidingWindow ¶
func NewSlidingWindow() *SlidingWindow
NewSlidingWindow returns a SlidingWindow instance
func (*SlidingWindow) Next ¶
func (sw *SlidingWindow) Next() uint32
Next returns the next close value of the sliding window
func (*SlidingWindow) SetRange ¶
func (sw *SlidingWindow) SetRange(left uint32, right uint32) error
SetRange set the initial range for sliding window
func (*SlidingWindow) TurnClose ¶
func (sw *SlidingWindow) TurnClose() bool
TurnClose returns true if State transitions Open --> Closing/Closed
func (*SlidingWindow) TurnOpen ¶
func (sw *SlidingWindow) TurnOpen() bool
TurnOpen returns true if State transitions Closing/Closed --> Open
func (*SlidingWindow) Update ¶
func (sw *SlidingWindow) Update(value uint32)
Update updates the window [close, open]
Click to show internal directories.
Click to hide internal directories.