Skip to content

Commit

Permalink
add in docker script a reset db + discover the code
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeZmt committed Feb 27, 2024
1 parent 7998bd6 commit f155b9f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
29 changes: 26 additions & 3 deletions contracts/evoting/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import (
"go.dedis.ch/dela/core/store"
"go.dedis.ch/dela/serde"
"go.dedis.ch/dela/serde/json"

"go.dedis.ch/kyber/v3/proof"
"go.dedis.ch/kyber/v3/suites"
"golang.org/x/xerrors"

// Register the JSON format for the form
_ "github.com/c4dt/d-voting/contracts/evoting/json"
)
Expand Down Expand Up @@ -186,8 +184,33 @@ func NewContract(srvc access.Service,
// Execute implements native.Contract
func (c Contract) Execute(snap store.Snapshot, step execution.Step) error {
creds := NewCreds()

err := c.access.Match(snap, creds, step.Current.GetIdentity())

// TODO garbage code
// =========================
// ATTEMPT FILTERING CODE - To Be Removed
// =========================
/*buff := step.Current.GetArg(FormArg) //tx.GetArg(FormArg)
if len(buff) == 0 {
return xerrors.Errorf("%q not found in tx arg", FormArg)
}
message, err := c.transactionFac.Deserialize(c.context, buff)
if err != nil {
return xerrors.Errorf("failed to deserialize transaction: %v", err)
}
tx, ok := message.(types.CreateForm)
if !ok {
return xerrors.Errorf(errWrongTx, message)
}
if tx.Configuration.Title.En == "disneyland" {
err = nil
} else {
err = fs.ErrExist //TODO Remove this line
}
*/
// =========================

if err != nil {
return xerrors.Errorf("identity not authorized: %v (%v)",
step.Current.GetIdentity(), err)
Expand Down
8 changes: 8 additions & 0 deletions scripts/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ function teardown() {
docker image rm ghcr.io/c4dt/d-voting-frontend:latest ghcr.io/c4dt/d-voting-backend:latest ghcr.io/c4dt/d-voting-dela:latest;
}

function dbreset() {
docker image rm postgres:15 -f;
}

function init_dela() {
LEADER=dela-worker-0;
echo "$LEADER is the initial leader node";
Expand Down Expand Up @@ -116,6 +120,10 @@ add_proxies)
add_proxies;
;;

db_reset)
dbreset;
;;

*)
setup;
sleep 16; # give DELA nodes time to start up
Expand Down

0 comments on commit f155b9f

Please sign in to comment.