Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasos Bitsios committed Jan 22, 2025
2 parents a1ed1be + 443b633 commit 82922d6
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 45 deletions.
12 changes: 10 additions & 2 deletions internal/algod/mac/mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,19 @@ func Upgrade(force bool) error {
if !system.CmdExists("brew") {
return errors.New("homebrew is not installed")
}

return system.RunAll(system.CmdsList{
err := system.RunAll(system.CmdsList{
{"brew", "--prefix", "algorand", "--installed"},
{"brew", "update"},
{"brew", "upgrade", "algorand", "--formula"},
})
if err != nil {
return err
}
err = Stop(false)
if err != nil {
return err
}
return Start(false)
}

// Start algorand with launchd
Expand Down
27 changes: 14 additions & 13 deletions internal/algod/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co
if !s.Watching {
break
}

// Abort on Fast-Catchup
if s.Status.State == FastCatchupState {
// Update current render
Expand All @@ -137,6 +138,9 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co
cb(s, nil)
continue
}
// Fetch Keys
s.UpdateKeys(ctx, t)
cb(s, nil)

// Wait for the next block
s.Status, _, err = s.Status.Wait(ctx)
Expand All @@ -145,9 +149,6 @@ func (s *StateModel) Watch(cb func(model *StateModel, err error), ctx context.Co
continue
}

// Fetch Keys
s.UpdateKeys(ctx, t)

if s.Status.State == SyncingState {
cb(s, nil)
continue
Expand Down Expand Up @@ -181,18 +182,18 @@ func (s *StateModel) UpdateKeys(ctx context.Context, t system.Time) {
if err == nil {
s.Admin = true
s.Accounts = ParticipationKeysToAccounts(s.ParticipationKeys)

// For each account, update the data from the RPC endpoint
for _, acct := range s.Accounts {
// For each account, update the data from the RPC endpoint
if s.Status.State == StableState {
// Skip eon errors
rpcAcct, err := GetAccount(s.Client, acct.Address)
if err != nil {
continue
}

s.Accounts[acct.Address] = s.Accounts[acct.Address].Merge(rpcAcct)
s.Accounts[acct.Address] = s.Accounts[acct.Address].UpdateExpiredTime(t, s.ParticipationKeys, int(s.Status.LastRound), s.Metrics.RoundTime)
// Skip eon errors
rpcAcct, err := GetAccount(s.Client, acct.Address)
if err != nil {
continue
}

s.Accounts[acct.Address] = s.Accounts[acct.Address].Merge(rpcAcct)
s.Accounts[acct.Address] = s.Accounts[acct.Address].UpdateExpiredTime(t, s.ParticipationKeys, int(s.Status.LastRound), s.Metrics.RoundTime)
}

}
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
var needsUpgrade = false
resp, err := api.GetNodeKitReleaseWithResponse(new(api.HttpPkg))
if err == nil && resp.ResponseCode >= 200 && resp.ResponseCode < 300 {
if resp.JSON200 != version {
if version != "dev" && resp.JSON200 != version {
needsUpgrade = true
// Warn on all commands but version
if len(os.Args) > 1 && os.Args[1] != "--version" {
Expand Down
28 changes: 14 additions & 14 deletions ui/modal/testdata/Test_Snapshot/InfoModal.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@



╭──Key Information────────────
│ Account: ABC
│ Participation ID: 123
│ Vote Key: VEVTVEtFWQ │
│ Selection Key: VEVTVEtFWQ │
│ State Proof Key: VEVTVEtFWQ
│ Vote First Valid: 0
│ Vote Last Valid: 30000
│ Vote Key Dilution: 100
╰──( (d)elete | (o)nline )────╯
╭──Key Information──────────────╮
│ Account: ABC
│ Participation ID: 123
│ Vote Key: VEVTVEtFWQ==
│ Selection Key: VEVTVEtFWQ==
│ State Proof Key: VEVTVEtFWQ== │
│ Vote First Valid: 0
│ Vote Last Valid: 30000
│ Vote Key Dilution: 100
╰────( (d)elete | (o)nline )────╯



Expand Down
6 changes: 3 additions & 3 deletions ui/modals/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func (m ViewModel) View() string {
}
account := style.Cyan.Render("Account: ") + m.Participation.Address
id := style.Cyan.Render("Participation ID: ") + m.Participation.Id
selection := style.Yellow.Render("Selection Key: ") + *utils.UrlEncodeBytesPtrOrNil(m.Participation.Key.SelectionParticipationKey[:])
vote := style.Yellow.Render("Vote Key: ") + *utils.UrlEncodeBytesPtrOrNil(m.Participation.Key.VoteParticipationKey[:])
stateProof := style.Yellow.Render("State Proof Key: ") + *utils.UrlEncodeBytesPtrOrNil(*m.Participation.Key.StateProofKey)
selection := style.Yellow.Render("Selection Key: ") + *utils.Base64EncodeBytesPtrOrNil(m.Participation.Key.SelectionParticipationKey[:])
vote := style.Yellow.Render("Vote Key: ") + *utils.Base64EncodeBytesPtrOrNil(m.Participation.Key.VoteParticipationKey[:])
stateProof := style.Yellow.Render("State Proof Key: ") + *utils.Base64EncodeBytesPtrOrNil(*m.Participation.Key.StateProofKey)
voteFirstValid := style.Purple("Vote First Valid: ") + utils.IntToStr(m.Participation.Key.VoteFirstValid)
voteLastValid := style.Purple("Vote Last Valid: ") + utils.IntToStr(m.Participation.Key.VoteLastValid)
voteKeyDilution := style.Purple("Vote Key Dilution: ") + utils.IntToStr(m.Participation.Key.VoteKeyDilution)
Expand Down
24 changes: 12 additions & 12 deletions ui/modals/info/testdata/Test_Snapshot/Visible.golden
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

Account: ABC
Participation ID: 123

Vote Key: VEVTVEtFWQ
Selection Key: VEVTVEtFWQ
State Proof Key: VEVTVEtFWQ

Vote First Valid: 0
Vote Last Valid: 30000
Vote Key Dilution: 100

Account: ABC
Participation ID: 123
Vote Key: VEVTVEtFWQ==
Selection Key: VEVTVEtFWQ==
State Proof Key: VEVTVEtFWQ==
Vote First Valid: 0
Vote Last Valid: 30000
Vote Key Dilution: 100
7 changes: 7 additions & 0 deletions ui/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import (

func toPtr[T any](constVar T) *T { return &constVar }

func Base64EncodeBytesPtrOrNil(b []byte) *string {
if b == nil || len(b) == 0 || isZeros(b) {
return nil
}
return toPtr(base64.StdEncoding.EncodeToString(b))
}

func UrlEncodeBytesPtrOrNil(b []byte) *string {
if b == nil || len(b) == 0 || isZeros(b) {
return nil
Expand Down

0 comments on commit 82922d6

Please sign in to comment.