Skip to content

Commit

Permalink
Merge pull request #129 from akakou/refactor/first-to-last
Browse files Browse the repository at this point in the history
Refactor/first to last
  • Loading branch information
akakou authored Sep 23, 2024
2 parents 3784008 + 58574a5 commit 3127567
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions verifier/monitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type CrtshMonitor struct {
ctstream *CrtshStream
ctx context.Context
lastLogger *goutils.File[int]
first int
last int
}

func NewCrtshMonitor(ctx context.Context) *CrtshMonitor {
Expand Down Expand Up @@ -111,14 +111,14 @@ func (a *CrtshMonitor) Run(verifier *core.Verifier) {

fmt.Printf("[received] crtid: %v, domain: %v\n", option.ID, domain)

if option.ID > a.first {
a.first = option.ID
if option.ID > a.last {
a.last = option.ID
}

clientsLen := len(a.ctstream.Client.Clients)
lastClient := a.ctstream.Client.Clients[clientsLen-1]
if option.Client.Domain == lastClient.Domain {
err := a.lastLogger.Store(&a.first)
err := a.lastLogger.Store(&a.last)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion verifier/monitor/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ func (a *CrtshMonitor) loadFirst() error {

func (a *CrtshMonitor) loadFirstToClient() {
for _, c := range a.ctstream.Client.Clients {
c.ID = a.first
c.ID = a.last
}
}

0 comments on commit 3127567

Please sign in to comment.