Documentation ¶
Index ¶
- type Block
- type BlockProcessorQueue
- func (b *BlockProcessorQueue) CanBeConfirmed(num uint64) bool
- func (b *BlockProcessorQueue) CanPublish(block uint64) bool
- func (b *BlockProcessorQueue) ConfirmedDone(block uint64) bool
- func (b *BlockProcessorQueue) ConfirmedFailed(block uint64) bool
- func (b *BlockProcessorQueue) ConfirmedNext() (uint64, bool)
- func (b *BlockProcessorQueue) Inserted(block uint64) bool
- func (b *BlockProcessorQueue) Latest(num uint64) bool
- func (b *BlockProcessorQueue) Published(block uint64) bool
- func (b *BlockProcessorQueue) Put(block uint64) bool
- func (b *BlockProcessorQueue) Start(ctx context.Context)
- func (b *BlockProcessorQueue) Stat() StatResponse
- func (b *BlockProcessorQueue) UnconfirmedDone(block uint64) bool
- func (b *BlockProcessorQueue) UnconfirmedFailed(block uint64) bool
- func (b *BlockProcessorQueue) UnconfirmedNext() (uint64, bool)
- type Next
- type Request
- type Stat
- type StatResponse
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { UnconfirmedProgress bool // 1. Joins Published bool // 2. Pub/Sub publishing UnconfirmedDone bool // 3. Done with processing ConfirmedProgress bool // 4. Attempting confirm whether chain reorg happened or not ConfirmedDone bool // 5. Done with bringing latest changes LastAttempted time.Time Delay time.Duration }
Block - Keeps track of single block i.e. how many times attempted till date, last attempted to process whether block data has been published on pubsub topic or not, is block processing currently
func (*Block) CanAttempt ¶
CanAttempt - Can we attempt to process this block ?
Yes, if waiting phase has elapsed
func (*Block) SetDelay ¶
func (b *Block) SetDelay()
SetDelay - Set delay at next fibonacci number in series, interpreted as seconds NOTE: The ratio of two adjacent numbers in the Fibonacci series rapidly approaches ((1 + sqrt(5)) / 2). So if N is multiplied by ((1 + sqrt(5)) / 2) and round it, the resultant number will be the next fibonacci number.
func (*Block) SetLastAttempted ¶
func (b *Block) SetLastAttempted()
SetLastAttempted - Updates last attempted to process block to current UTC time
type BlockProcessorQueue ¶
type BlockProcessorQueue struct { Blocks map[uint64]*Block StartedWith uint64 TotalInserted uint64 LatestBlock uint64 Total uint64 PutChan chan Request CanPublishChan chan Request PublishedChan chan Request InsertedChan chan Request UnconfirmedFailedChan chan Request UnconfirmedDoneChan chan Request ConfirmedFailedChan chan Request ConfirmedDoneChan chan Request StatChan chan Stat LatestChan chan Update UnconfirmedNextChan chan Next ConfirmedNextChan chan Next }
BlockProcessorQueue - concurrent safe queue to be interacted with before attempting to process any block
func New ¶
func New(startingWith uint64) *BlockProcessorQueue
New - Getting new instance of queue, to be invoked during setting up application
func (*BlockProcessorQueue) CanBeConfirmed ¶
func (b *BlockProcessorQueue) CanBeConfirmed(num uint64) bool
CanBeConfirmed - Checking whether given block number has reached finality as per given user set preference, then it can be attempted to be checked again & finally entered into storage
func (*BlockProcessorQueue) CanPublish ¶
func (b *BlockProcessorQueue) CanPublish(block uint64) bool
CanPublish - Before any client attempts to publish any block on Pub/Sub topic, they're supposed to be invoking this method to check whether they're eligible of publishing or not
NOTE: if any other client has already published it, we'll avoid redoing it
func (*BlockProcessorQueue) ConfirmedDone ¶
func (b *BlockProcessorQueue) ConfirmedDone(block uint64) bool
ConfirmedDone - Confirmed block processed successfully
func (*BlockProcessorQueue) ConfirmedFailed ¶
func (b *BlockProcessorQueue) ConfirmedFailed(block uint64) bool
ConfirmedFailed - Confirmed block processing failed
func (*BlockProcessorQueue) ConfirmedNext ¶
func (b *BlockProcessorQueue) ConfirmedNext() (uint64, bool)
ConfirmedNext - Next block that can be processed, to get confirmation & finalised
func (*BlockProcessorQueue) Inserted ¶
func (b *BlockProcessorQueue) Inserted(block uint64) bool
Inserted - Marking this block has been inserted into DB (not updation, it's insertion)
func (*BlockProcessorQueue) Latest ¶
func (b *BlockProcessorQueue) Latest(num uint64) bool
Latest - Block head subscriber will update queue manager that latest block seen is updated
func (*BlockProcessorQueue) Published ¶
func (b *BlockProcessorQueue) Published(block uint64) bool
Published - Asks queue manager to mark that this block has been successfully published on Pub/Sub topic
Future block processing attempts (if any), are supposed to be avoiding doing this, if already done successfully
func (*BlockProcessorQueue) Put ¶
func (b *BlockProcessorQueue) Put(block uint64) bool
Put - Client is supposed to be invoking this method when it's interested in putting new block to processing queue
If responded with `true`, they're good to go with execution of processing of this block
If this block is already put into queue, it'll ask client to not proceed with this number
func (*BlockProcessorQueue) Start ¶
func (b *BlockProcessorQueue) Start(ctx context.Context)
Start - You're supposed to be starting this method as an independent go routine, with will listen on multiple channels & respond back over provided channel ( by client )
func (*BlockProcessorQueue) Stat ¶
func (b *BlockProcessorQueue) Stat() StatResponse
Stat - Client's are supposed to be invoking this abstracted method for checking queue status
func (*BlockProcessorQueue) UnconfirmedDone ¶
func (b *BlockProcessorQueue) UnconfirmedDone(block uint64) bool
UnconfirmedDone - Unconfirmed block processed successfully
func (*BlockProcessorQueue) UnconfirmedFailed ¶
func (b *BlockProcessorQueue) UnconfirmedFailed(block uint64) bool
UnconfirmedFailed - Unconfirmed block processing failed
func (*BlockProcessorQueue) UnconfirmedNext ¶
func (b *BlockProcessorQueue) UnconfirmedNext() (uint64, bool)
UnconfirmedNext - Next block that can be processed, present in unconfirmed block queue
type Next ¶
Next - Block to be processed next, asked by sending this request when receptor detects so, will attempt to find out what should be next processed and send that block number is response over channel specified by client
type Request ¶
Request - Any request to be placed into queue's channels in this form client can also receive response/ confirmation over channel that they specify
type Stat ¶
type Stat struct {
ResponseChan chan StatResponse
}
Stat - Clients can query how many blocks present in queue currently