|
|
|
@ -124,9 +124,10 @@ type BlockChain struct { |
|
|
|
|
scope event.SubscriptionScope |
|
|
|
|
genesisBlock *types.Block |
|
|
|
|
|
|
|
|
|
mu sync.RWMutex // global mutex for locking chain operations
|
|
|
|
|
chainmu sync.RWMutex // blockchain insertion lock
|
|
|
|
|
procmu sync.RWMutex // block processor lock
|
|
|
|
|
mu sync.RWMutex // global mutex for locking chain operations
|
|
|
|
|
chainmu sync.RWMutex // blockchain insertion lock
|
|
|
|
|
procmu sync.RWMutex // block processor lock
|
|
|
|
|
pendingCrossLinksMutex sync.RWMutex // pending crosslinks lock
|
|
|
|
|
|
|
|
|
|
checkpoint int // checkpoint counts towards the new checkpoint
|
|
|
|
|
currentBlock atomic.Value // Current head of the block chain
|
|
|
|
@ -1282,7 +1283,6 @@ func (bc *BlockChain) WriteBlockWithState( |
|
|
|
|
} |
|
|
|
|
bc.LastContinuousCrossLink(crossLink) |
|
|
|
|
|
|
|
|
|
// NOTE: Uptime stats is not mission critical code. Should move to offchain server
|
|
|
|
|
// Writing validator stats (for uptime recording) for other shards
|
|
|
|
|
if bc.chainConfig.IsStaking(crossLink.Epoch()) { |
|
|
|
|
shardState, err := bc.ReadShardState(crossLink.Epoch()) |
|
|
|
@ -2317,6 +2317,9 @@ func (bc *BlockChain) WritePendingCrossLinks(crossLinks []types.CrossLink) error |
|
|
|
|
|
|
|
|
|
// AddPendingCrossLinks appends pending crosslinks
|
|
|
|
|
func (bc *BlockChain) AddPendingCrossLinks(pendingCLs []types.CrossLink) (int, error) { |
|
|
|
|
bc.pendingCrossLinksMutex.Lock() |
|
|
|
|
defer bc.pendingCrossLinksMutex.Unlock() |
|
|
|
|
|
|
|
|
|
cls, err := bc.ReadPendingCrossLinks() |
|
|
|
|
if err != nil || len(cls) == 0 { |
|
|
|
|
err := bc.WritePendingCrossLinks(pendingCLs) |
|
|
|
@ -2329,6 +2332,9 @@ func (bc *BlockChain) AddPendingCrossLinks(pendingCLs []types.CrossLink) (int, e |
|
|
|
|
|
|
|
|
|
// DeleteCommittedFromPendingCrossLinks delete pending crosslinks that already committed (i.e. passed in the params)
|
|
|
|
|
func (bc *BlockChain) DeleteCommittedFromPendingCrossLinks(crossLinks []types.CrossLink) (int, error) { |
|
|
|
|
bc.pendingCrossLinksMutex.Lock() |
|
|
|
|
defer bc.pendingCrossLinksMutex.Unlock() |
|
|
|
|
|
|
|
|
|
cls, err := bc.ReadPendingCrossLinks() |
|
|
|
|
if err != nil || len(cls) == 0 { |
|
|
|
|
return 0, err |
|
|
|
|