Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/rollkit/rollkit into chandi…
Browse files Browse the repository at this point in the history
…ni/avail-da
  • Loading branch information
chandiniv1 committed Aug 23, 2023
2 parents 773fb54 + 3ae761f commit f0ab456
Show file tree
Hide file tree
Showing 29 changed files with 546 additions and 244 deletions.
17 changes: 17 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pull_request_rules:
- name: backport patches to v0.11.x branch
conditions:
- base=main
- label=backport:v0.11.x
actions:
backport:
branches:
- v0.11.x
- name: backport patches to v0.10.x branch
conditions:
- base=main
- label=backport:v0.10.x
actions:
backport:
branches:
- v0.10.x-lts
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
**/**.go
go.mod
go.sum
- uses: golangci/golangci-lint-action@v3.6.0
- uses: golangci/golangci-lint-action@v3.7.0
with:
version: latest
args: --timeout 10m
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ Please join our [Community Discord](https://discord.com/invite/YsnTPcSfWQ) to as

## Dependency Graph

To see our progress and a possible future of Rollkit visit our [Dependency Graph](./docs/specification/rollkit-dependency-graph.md).
To see our progress and a possible future of Rollkit visit our [Dependency
Graph](./docs/specification/rollkit-dependency-graph.md).

## Code of Conduct

Expand Down
60 changes: 60 additions & 0 deletions block/block_cache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package block

import (
"sync"

"github.com/rollkit/rollkit/types"
)

type BlockCache struct {
blocks map[uint64]*types.Block
hashes map[string]bool
hardConfirmations map[string]bool
mtx *sync.RWMutex
}

func NewBlockCache() *BlockCache {
return &BlockCache{
blocks: make(map[uint64]*types.Block),
hashes: make(map[string]bool),
hardConfirmations: make(map[string]bool),
mtx: new(sync.RWMutex),
}
}

func (bc *BlockCache) getBlock(height uint64) (*types.Block, bool) {
bc.mtx.Lock()
defer bc.mtx.Unlock()
block, ok := bc.blocks[height]
return block, ok
}

func (bc *BlockCache) setBlock(height uint64, block *types.Block) {
bc.mtx.Lock()
defer bc.mtx.Unlock()
bc.blocks[height] = block
}

func (bc *BlockCache) deleteBlock(height uint64) {
bc.mtx.Lock()
defer bc.mtx.Unlock()
delete(bc.blocks, height)
}

func (bc *BlockCache) isSeen(hash string) bool {
bc.mtx.Lock()
defer bc.mtx.Unlock()
return bc.hashes[hash]
}

func (bc *BlockCache) setSeen(hash string) {
bc.mtx.Lock()
defer bc.mtx.Unlock()
bc.hashes[hash] = true
}

func (bc *BlockCache) setHardConfirmed(hash string) {
bc.mtx.Lock()
defer bc.mtx.Unlock()
bc.hardConfirmations[hash] = true
}
Loading

0 comments on commit f0ab456

Please sign in to comment.