Skip to content

Commit

Permalink
Merge pull request #183 from hashcloak/patch-181
Browse files Browse the repository at this point in the history
katzenmint: prune documents if it's not corrected
  • Loading branch information
sc0Vu committed Dec 6, 2023
2 parents 090a158 + d174a00 commit c15aa5a
Show file tree
Hide file tree
Showing 33 changed files with 1,236 additions and 378 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/plugin.yml → .github/workflows/all.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Plugin
name: All

on: ["push", "pull_request"]

Expand All @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "macOS-latest"]
go: ["1.17.x", "1.18.x", "1.19.x"]
go: ["1.21.x"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
Expand All @@ -19,28 +19,29 @@ jobs:

- uses: actions/checkout@v3

- name: "Test plugin"
- name: "Test all"
run: |
cd plugin
make
make test-all
- name: "Build plugin"
- name: "Build all"
run: |
cd plugin
make build
make build-all
mkdir dist
mv meson-plugin dist
mv katzenmint/katzenmint dist
mv server/meson-server dist
mv plugin/meson-plugin dist
mv genconfig/genconfig dist
- if: runner.os == 'macOS'
name: "Setup plugin filename"
run: echo "ZIPNAME=meson_plugin_darwin_${{ matrix.go }}" >> $GITHUB_ENV
name: "Setup filename"
run: echo "ZIPNAME=meson_darwin_${{ matrix.go }}" >> $GITHUB_ENV

- if: runner.os == 'Linux'
name: "Setup plugin filename"
run: echo "ZIPNAME=meson_plugin_linux_${{ matrix.go }}" >> $GITHUB_ENV
name: "Setup filename"
run: echo "ZIPNAME=meson_linux_${{ matrix.go }}" >> $GITHUB_ENV

- name: Archive plugin
- name: Archive all
uses: actions/upload-artifact@v3
with:
name: ${{ env.ZIPNAME }}
path: plugin/dist
path: dist
24 changes: 0 additions & 24 deletions .github/workflows/client.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/katzenmint.yml

This file was deleted.

46 changes: 0 additions & 46 deletions .github/workflows/server.yml

This file was deleted.

25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,27 @@ build-docker-containers: build-docker-katzenmint build-docker-server

.PHONY: clean-docker-images
clean-docker-images:
docker rmi -f $$(docker images | grep '^<none>' | awk '{print $$3}')
docker rmi -f $$(docker images | grep '^<none>' | awk '{print $$3}')

.PHONE: test-all
test-all:
@$(MAKE) $(MAKE_FLAGS) -C client/. test
@$(MAKE) $(MAKE_FLAGS) -C genconfig/. test
@$(MAKE) $(MAKE_FLAGS) -C katzenmint/. test
@$(MAKE) $(MAKE_FLAGS) -C plugin/. test
@$(MAKE) $(MAKE_FLAGS) -C server/. test

.PHONE: build-all
build-all:
@$(MAKE) $(MAKE_FLAGS) -C genconfig/. build
@$(MAKE) $(MAKE_FLAGS) -C katzenmint/. build
@$(MAKE) $(MAKE_FLAGS) -C plugin/. build
@$(MAKE) $(MAKE_FLAGS) -C server/. build

.PHONE: all
all:
@$(MAKE) $(MAKE_FLAGS) -C client/.
@$(MAKE) $(MAKE_FLAGS) -C genconfig/.
@$(MAKE) $(MAKE_FLAGS) -C katzenmint/.
@$(MAKE) $(MAKE_FLAGS) -C plugin/.
@$(MAKE) $(MAKE_FLAGS) -C server/.
37 changes: 19 additions & 18 deletions client/minclient/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,24 +444,25 @@ func (c *connection) onWireConn(w *wire.Session) {
case <-c.fetchCh:
doFetch = true
case ctx := <-c.getConsensusCh:
c.log.Debugf("Dequeued GetConsesus for send.")
if consensusCtx != nil {
ctx.doneFn(fmt.Errorf("outstanding GetConsensus already exists: %v", consensusCtx.epoch))
} else {
consensusCtx = ctx
cmd := &commands.GetConsensus{
Epoch: ctx.epoch,
}
wireErr = w.SendCommand(cmd)
ctx.doneFn(wireErr)
if wireErr != nil {
c.log.Debugf("Failed to send GetConsensus: %v", wireErr)
return
}
c.log.Debugf("Sent GetConsensus.")
}

adjFetchDelay()
c.log.Debugf("[Deprecated] Dequeued GetConsesus for send.")
ctx.doneFn(fmt.Errorf("deprecated GetConsensus wire command"))
// if consensusCtx != nil {
// ctx.doneFn(fmt.Errorf("outstanding GetConsensus already exists: %v", consensusCtx.epoch))
// } else {
// consensusCtx = ctx
// cmd := &commands.GetConsensus{
// Epoch: ctx.epoch,
// }
// wireErr = w.SendCommand(cmd)
// ctx.doneFn(wireErr)
// if wireErr != nil {
// c.log.Debugf("Failed to send GetConsensus: %v", wireErr)
// return
// }
// c.log.Debugf("Sent GetConsensus.")
// }

// adjFetchDelay()
continue
case ctx := <-c.sendCh:
c.log.Debugf("Dequeued packet for send.")
Expand Down
13 changes: 5 additions & 8 deletions client/pkiclient/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ var (
)

type cacheEntry struct {
raw []byte
doc *pki.Document
}

Expand Down Expand Up @@ -92,7 +91,7 @@ func (c *Cache) GetEpoch(ctx context.Context) (epoch uint64, ellapsedHeight uint
func (c *Cache) GetDoc(ctx context.Context, epoch uint64) (*pki.Document, []byte, error) {
// Fast path, cache hit.
if d := c.cacheGet(epoch); d != nil {
return d.doc, d.raw, nil
return d.doc, nil, nil
}

// Exit upon halt
Expand All @@ -114,7 +113,7 @@ func (c *Cache) GetDoc(ctx context.Context, epoch uint64) (*pki.Document, []byte
return nil, nil, r
case *cacheEntry:
// Worker will handle the LRU.
return r.doc, r.raw, nil
return r.doc, nil, nil
default:
return nil, nil, fmt.Errorf("BUG: pkiclient: worker returned nonsensical result: %+v", r)
}
Expand Down Expand Up @@ -159,6 +158,7 @@ func (c *Cache) insertLRU(newEntry *cacheEntry) {
}

func (c *Cache) worker() {
// TODO: maybe implement backoff delay?
const retryTime = time.Second / 2

var epoch, height uint64
Expand All @@ -179,9 +179,6 @@ func (c *Cache) worker() {
}
ctx = context.Background()
epoch, height, err = c.impl.GetEpoch(context.Background())
if epoch == c.memEpoch && height < uint64(katzenmint.EpochInterval) {
c.memHeight = height
}
if err != nil || epoch == c.memEpoch {
c.timer.Reset(retryTime)
c.Unlock()
Expand Down Expand Up @@ -209,14 +206,14 @@ func (c *Cache) worker() {
//
// TODO: This could allow concurrent fetches at some point, but for
// most common client use cases, this shouldn't matter much.
d, raw, err := c.impl.GetDoc(ctx, epoch)
d, _, err := c.impl.GetDoc(ctx, epoch)
if err != nil {
if op != nil {
op.doneCh <- err
}
continue
}
e := &cacheEntry{doc: d, raw: raw}
e := &cacheEntry{doc: d}
c.insertLRU(e)
if op != nil {
op.doneCh <- e
Expand Down
Loading

0 comments on commit c15aa5a

Please sign in to comment.