Skip to content

Commit

Permalink
log: reduce debug output and minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: p4u <[email protected]>
  • Loading branch information
p4u committed Nov 7, 2023
1 parent e0a1a53 commit f788706
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 0 additions & 2 deletions vochain/ist/ist.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func (c *Controller) Schedule(height uint32, id []byte, action Action) error {
actions[string(id)] = action

// store the IST actions
log.Debugw("schedule IST action", "height", height, "id", fmt.Sprintf("%x", id), "action", ActionsToString[action.ID])
return c.storeToNoState(dbIndex(height), actions.encode())
}

Expand Down Expand Up @@ -236,7 +235,6 @@ func (c *Controller) Commit(height uint32) error {
action.ElectionID, err)
}
case ActionUpdateValidatorScore:
log.Debugw("update validator score", "height", height, "id", fmt.Sprintf("%x", id), "action", ActionsToString[action.ID])
if err := c.updateValidatorScore(action.ValidatorVotes, action.ValidatorProposer); err != nil {
return fmt.Errorf("cannot update validator score: %w", err)
}
Expand Down
4 changes: 0 additions & 4 deletions vochain/ist/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package ist

import (
"bytes"
"encoding/hex"
"fmt"

"go.vocdoni.io/dvote/log"
)

/*
Expand Down Expand Up @@ -64,7 +61,6 @@ func (c *Controller) updateValidatorScore(voteAddresses [][]byte, proposer []byt
return fmt.Errorf("cannot update validator score: %w", err)
}
// get the validator score
log.Debugw("update validator score", "totalVoters", len(voteAddresses), "proposer", hex.EncodeToString(proposer))
for _, voteAddr := range voteAddresses {
validator := ""
for k, v := range validators {
Expand Down
14 changes: 11 additions & 3 deletions vochain/offchaindatahandler/offchaindatahandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ type importItem struct {
censusRoot string
}

var itemTypesToString = map[int]string{
itemTypeExternalCensus: "external census",
itemTypeOrganizationMetadata: "organization metadata",
itemTypeElectionMetadata: "election metadata",
itemTypeAccountMetadata: "account metadata",
}

// TBD: A startup process for importing on-going process census
// TBD: a mechanism for removing already finished census?

Expand Down Expand Up @@ -57,6 +64,7 @@ func NewOffChainDataHandler(v *vochain.BaseApplication, d *downloader.Downloader
return &od
}

// Rollback is called when a new block is reverted, so we revert the import actions.
func (d *OffChainDataHandler) Rollback() {
d.queueLock.Lock()
d.queue = make([]importItem, 0)
Expand All @@ -72,14 +80,14 @@ func (d *OffChainDataHandler) Commit(_ uint32) error {
for _, item := range d.queue {
switch item.itemType {
case itemTypeExternalCensus:
log.Infow("importing data", "type", "external census", "uri", item.uri)
log.Infow("importing data", "type", itemTypesToString[item.itemType], "uri", item.uri)
// AddToQueue() writes to a channel that might be full, so we don't want to block the main thread.
go d.enqueueOffchainCensus(item.censusRoot, item.uri)
case itemTypeElectionMetadata, itemTypeAccountMetadata:
log.Infow("importing metadata", "type", item.itemType, "uri", item.uri)
log.Infow("importing data", "type", itemTypesToString[item.itemType], "uri", item.uri)
go d.enqueueMetadata(item.uri)
default:
log.Errorf("unknown item %d", item.itemType)
log.Errorf("unknown import item %d", item.itemType)
}
}
return nil
Expand Down
2 changes: 0 additions & 2 deletions vochain/transaction/account_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/ethereum/go-ethereum/common"
"go.vocdoni.io/dvote/crypto/ethereum"
"go.vocdoni.io/dvote/log"
"go.vocdoni.io/dvote/tree/arbo"
"go.vocdoni.io/dvote/types"
vstate "go.vocdoni.io/dvote/vochain/state"
Expand Down Expand Up @@ -312,7 +311,6 @@ func (t *TransactionHandler) RegisterSIKTxCheck(vtx *vochaintx.Tx) (common.Addre
if err != nil {
return common.Address{}, nil, nil, false, fmt.Errorf("cannot extract address from public key: %w", err)
}
log.Info(txAddress.String())
// check if the address is already registered
if _, err := t.state.GetAccount(txAddress, false); err != nil {
return common.Address{}, nil, nil, false, fmt.Errorf("cannot get the account for the tx address: %w", err)
Expand Down

0 comments on commit f788706

Please sign in to comment.