Coder Social home page Coder Social logo

turbosrc-engine's Introduction

Usage

Build image and containers in detatched mode from root directory

Build.

docker build -t turbosrc-offchain-service:latest.

Launch, but perhaps build flag is redundant here (had issues of it not actually rebuilding image as thought).

docker-compose up --build

If not building, may need to pull node image:

docker pull node:16.15-bullseye

Get container id of privateStore_library_1

docker ps

Enter bash or shell session in container privateStore_library_1

docker exec -it <privateStore_library_1 id> bash *or* sh

Connect to the database, start the Graphql server, ports 5432 and 4002

npm start

New terminal window

Run tests

./test-server/run-tests.sh

N.B.:

Enter npm start again to clear database if running tests a second time.

Exit Shell or Bash session

exit

Remove containers when done:

docker-compose down

Functions and their return values if request is successful

createRepo

201

createUser

201

createPullRequest

201

setVote

201 if valid, 403 if user has voted on this pull request already

transferTokens

201

getContributorID

a string with the contributor id

getContributorName

a string with the contributor's name (github login)

getRepoStatus

a boolean, true if repo is tokenized, else false

getAuthorizedContributor

a boolean

getPRStatus

a string of either closed open or merge

getRepoToken amount

a string of 1000000

getVotePowerAmount

a string of the amount of votepower a user has in the given repo

getVoteNoTotals

a string of the total number of votes against a pull request

getVoteYesTotals

a string of the total number of votes in favor of a pull request

getVoteStatus

Use getPRStatus instead

getQuorum

a string representing the repo's quorum. default is ".34"

setQuorum

204

turbosrc-engine's People

Contributors

jex441 avatar 7db9a avatar ramirc5 avatar

Watchers

 avatar

turbosrc-engine's Issues

Duplicate vote triggered cross-repo

After voting on a pull request in "repo A" with the same repo name, github issue/pull number, commit oid, and default hash as "repo B", I was unable to vote on the "duplicate" pull requests on "repo B".

This duplicateVote triggered when looking at turbosrc-engine logs:

    const duplicateVote = await Vote.findOne({
      where: { defaultHash: defaultHash, contributor_id: contributor_id },
    });

    if (duplicateVote) {
      console.log("duplicate");
      return 403;
    } else {
      let tokens = await getVotePowerAmount(
        /*owner:*/ "",
        /*repo:*/ repo_id,
        /*defaultHash:*/ defaultHash,
        /*contributor_id:*/ contributor_id,
        /*side:*/ ""
      );

      // Should also check if tokens.status === 404
      if (tokens.amount < 1) {
        return 403;
      }

      let vote = await Vote.create({
        contributor_id: contributor_id,
        defaultHash: defaultHash,
        votePower: tokens.amount,
        side: side,
      });

      await vote.setPullrequest(pullRequest.id);

      if (side === "yes") {
        let newTotal = pullRequest.yesTokenAmount + tokens.amount;
        await pullRequest.update({
          yesTokenAmount: newTotal,
          where: { id: pullRequest.id },
        });
      }
      if (side === "no") {
        let newTotal = pullRequest.noTokenAmount + tokens.amount;
        await pullRequest.update({
          noTokenAmount: newTotal,
          where: { id: pullRequest.id },
        });
      }

      return 201;
    }
  } catch (error) {
    console.log(error);
    return 500;
  }```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.