基于区块链的毕业设计overhide-ethereum – 覆盖以太坊

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计overhide-ethereum – 覆盖以太坊 是一篇很好的国外资料

overhide-ethereum - 覆盖<a href=以太坊eth“>

overhide.io

A free and open-sourced (mostly) ecosystem of widgets, a front-end library, and back-end services — to make addition of “logins” and “in-app-purchases” (IAP) to your app as banal as possible.


overhide-ethereum

overhide-ethereum - 覆盖<a href=以太坊eth“>

Ethereum implementation of the overhide.io remuneration API.

Read about the API and play with it here:

Rinkeyby Testnet: https://rinkeby.ethereum.overhide.io/swagger.html

Mainnet: https://ethereum.overhide.io/swagger.html

About

The overhide system provides a suite of remuneration providers that implement the overhide remuenration API. This repository is the Ethereum overhide remuneration API provider.

overhide-ethereum - 覆盖<a href=以太坊eth“> Figure 1: Shows the Ethereum overhide-remuneration provider exposing the API.

Read more about this suite of tools in support of ledger-based authorization flows by playing around with the demos and reading all about the intention and motivation behind the system.

This Rinkeyby testnet provider is used in the demos.

Quick Start

These steps assume Docker is available.

On Windows, the npm run clean script assumes PowerShell is setup and provisioned: runs with @powershell. Ensure PowerShell is setup or don’t use this script.

Please review the Configuration section below as at the very least ETHERSCAN_KEY must be configured to run the tests in this package.

Read the rest of this README for details.

Quick Start With overhide-ethereum In Docker Container

Note: the npm run compose-dev step (below) builds and runs a for test only opinionated container with settings and credentials suitable to be used for downstream testing (e.g. pegged to “rinkeby” testnet).

To build a non-test container see Building Docker Image section below.

  1. npm install --global --production windows-build-tools
  2. npm install — bring in dependencies
  3. copy ./.npmrc.sample to ./npmrc.dev
  4. edit ./.npmrc.dev and set “ETHERSCAN_KEY” to your https://etherscan.io API key
  5. npm run compose-dev — build and start overhide-ethereum Docker container
  6. jump to “First Time DB Setup” section for the first-time DB setup
  7. jump to “Database Evolutions” section, especially the “For Docker” subsection
  8. your oh-eth container failed since your DB wasn’t setup–now it is–find your oh-eth container name: docker ps -a; look for oh-eth with an “Exited” status.
  9. npm test — run tests against above
  10. point browser at http://editor.swagger.io/?url=http://localhost:8080/swagger.json — to use the API

From now on you’ll need to use the following commands to stop/restart things:

  • npm run clean — stop overhide-ethereum Docker container and remove image

Quick Start With overhide-ethereum Running Locally

  1. npm install --global --production windows-build-tools
  2. npm install — bring in dependencies
  3. jump to “First Time DB Setup” section for the first-time DB setup
  4. jump to “Database Evolutions” section, especially the “For Docker” subsection
  5. npm config set overhide-ethereum:ETHERSCAN_KEY=... — replace ‘…’ with your https://etherscan.io API key
  6. npm config set overhide-ethereum:OH_ETH_PORT=8081 — (optional) only necessary if you have a port conflict
  7. npm run start — start overhide-ethereum on localhost
  8. npm test — in another terminal; run tests against above:
  9. point browser at http://editor.swagger.io/?url=http://localhost:8081/swagger.json — to use the API

Security

The service uses Authorization headers with Bearer .. tokens for all endpoints.

By default, the ./main/js/lib/token.js in this distro will check provided tokens against https://token.overhide.io/swagger.html (see GET /validate). The default action takes place if a SALT value is left unconfigured.

If SALT is left unconfigured (default), your users must register for an API key with https://token.overhide.io. The API key must be used to retrieve tokens as per https://token.overhide.io/swagger.html.

If you want to leverage the SALT config when standing up an instance of this service, you’ll need to also stand-up your own instance of overhide-client-auth service to furnish the tokens for this code (just remember to modify the SALT values in both services).

Alternatively, you can rework ./main/js/lib/token.js to provide your own token-auth… it’s OSS.

The default service at https://ethereum.overhide.io/swagger.html and https://rinkeby.ethereum.overhide.io/swagger.html use tokens from the default token provider at https://token.overhide.io/register (API).

Configuration

All the configuration points for the app are listed in .npmrc.sample.

Configuration defaults in See .npmrc.sample are reasonable only for testing.

These npm configuration points are override-able with npm config edit or npm config set (see npm-config): e.g. npm config set overhide-ethereum:ETHERSCAN_KEY new-value sets a new-value for ETHERSCAN_KEY in the user’s ~/.npmrc.

For Docker compose environments configuration settings are taken from:

  • ./.npmrc.dev — for local dev
  • ./.npmrc.stage — for staging environment
  • ./.npmrc.prod — for production environment

These files are not source controlled. Create them using ./.npmrc.sample as a template.

If an environment variable of the same name is made available, the environment variable’s value precedes that of the npm config value (~/.npmrc or package.json).

Some notable configuration points for overhide-ethereum:

Configuration Point Description Sample Value
WEB3_WSS_URI The websocket web3 provider URI redacted
NETWORK_TYPE The network type (e.g. ‘mainnet’) rinkeby
ETHERSCAN_KEY The etherscan.io API key — good account summary source redacted
OH_ETH_PORT overhide-ethereum‘s port 8080
OH_ETH_HOST overhide-ethereum‘s host localhost
BASE_URL host:port base URL as used from outside (of load-balancer) to access service localhost:8080
DEBUG see ‘Logging’ section below overhide-ethereum:*,-overhide-ethereum:is-signature-valid:txs,-overhide-ethereum:get-transactions:txs
SALT Salt for bearer-token validation (see Security above) c0c0nut
TOKEN_URL Token validation URL (see Security above) https://token.overhide.io/validate
INTERNAL_TOKEN Token to use with internal services to avoid rate-limiting (just set once from https://token.overhide.io/register in all services)
KEYV_TALLY_CACHE_URI URI of cache (redis) to tally requests (back-end) redis://localhost:6379
RATE_LIMIT_FE_WINDOW_MS Duration of API rate limiting window (milliseconds) (frontend) 60000
RATE_LIMIT_FE_MAX_REQUESTS_PER_WINDOW Number of API calls per rate limiting window 30
RATE_LIMIT_BE_WINDOW_MS Duration of API rate limiting window (milliseconds) (backend) 60000
RATE_LIMIT_BE_MAX_REQUESTS_PER_WINDOW Number of API calls per rate limiting window 600
EXPECTED_CONFIRMATIONS Number of confirmations before transaction is considered valid 2
IS_WORKER Enable this on one (and only one) node — runs worker processes that use up API limits true

First Time DB Setup

All the DB connectivity configuration points assume that the DB and DB user are setup.

For localhost Docker, psql into the container:

npm run psql-dev c "oh-eth" dt 

The ‘adam’ role and ‘oh-eth’ DB should already be created and connected to with the above command (as per .npmrc.dev environment passed into docker-compose).

If not, to manually create:

postgres=# create database "oh-eth"; postgres=# create user adam with encrypted password 'c0c0nut'; postgres=# grant all privileges on database "oh-eth" to adam; 

Make sure to set the configuration points in your .npmrc appropriately.

Now you’re ready to run database evolutions on the new database.

Database Evolutions

There is a single Node file to check for and perform database evolutions.

Run it from the application node with npm run db-evolve.

It will evolve the database to whatever it needs to be for the particular application version.

The main/js/lib/database.js has an init(..) method which should check that the database is at the right evolution for that version of the app.

Consider currently running nodes before evolving: will they be able to run with the evolved DB? Perhaps stop them all before evolving.

Check

To check the database pre/post evolution (first time DB setup already done):

  • log into DB
  • list tables
npm run psql-dev dt oh-eth.* 

If you need to select role and DB:

set role oh-eth; c oh-eth; 

More commands: https://gist.github.com/apolloclark/ea5466d5929e63043dcf

Evolve

If running using Docker, jump into a container to run the evolution:

docker run -it --rm --link postgres:postgres --network oh_default oh-eth /bin/sh

Then run the evolution:

npm run db-evolve

Logging

Logging is done via the https://www.npmjs.com/package/debug module.

Logging verbosity is controlled via the DEBUG environment variable or an npm configuration point of the same name.

Non-debug (error/warning/audit) logging is programmatically enabled by default despite setting of the DEBUG variable. These are the “overhide-ethereum-log” logs.

Setting DEBUG to “overhide-ethereum:*” will enable all debug logging. This will be very verbose. It’s likely desirable to target debug logging, e.g:

npm config set overhide-ethereum:DEBUG "overhide-ethereum:*,-overhide-ethereum:is-signature-valid:txs,-overhide-ethereum:get-transactions:txs"

Notes on Running the Development Environment

To restart Node.js every time you change source files ensure to have nodemon installed:

npm install -g nodemon

Start Node.js using nodemon:

nodemon --inspect main/js/overhide-ethereum.js

Or use the npm script:

npm run dev

Configuration for Development

Default configuration in package.json is reasonable for development/testing.

You can override the configuration as per Configuration section above.

Nodemon (Remote) Debugging

If you start overhide-ethereum with npm run dev or nodemon from your command shell, you’ll need to connect your development environment to this node process explicitly for remote debugging.

Note that nodemon above is started with --inspect to allow remote debugging.

As an example, to remote-debug from VSCode use the following runtime configuration:

  "version": "0.2.0",   "configurations": [     {       "type": "node",       "request": "attach",       "name": "Node: Nodemon",       "processId": "${command:PickProcess}",       "restart": true,       "protocol": "inspector"     }   ] 

Select the “Node: Nodemon” runtime configuration in VSCode and look for a “node” process matching the PID reported by the ‘ctx_config’ console log from overhide-ethereum.

Once you see a “Debugger attached.” message in your nodemon shell you’re in business.

Testing

npm test or run the Mocha/Chai tests in ./test/js/* manually.

The tests aren’t unit tests. They do not start Node.js to run overhide-ethereum; they expect the target device-under-test overhide-ethereum to be running.

The tests should pass regardless of configuration being tested:

  • a development environment started using npm run start or npm run dev
  • a standalone Docker container started using npm run compose-dev

The OH_ETH_HOST and OH_ETH_PORT configurations points may be used to point the tests at the target overhide-ethereum for testing.

Health Check — Endpoint

This service furnishes metrics and a health check via the status.json endpoint.

Example run (with service running on localhost:8080):

curl http://localhost:8080/status.html 

Rate Limiting

Access to these APIs is gated via config points:

  • RATE_LIMIT_FE_MAX_REQUESTS_PER_WINDOW
  • RATE_LIMIT_FE_WINDOW_MS
  • RATE_LIMIT_BE_MAX_REQUESTS_PER_WINDOW
  • RATE_LIMIT_BE_WINDOW_MS

This only applies to requests with a token other than the INTERNAL_TOKEN (if set). INTERNAL_TOKEN requests are not rate-limited.

All front-end rate-limits are shared across nodes sharing the same RATE_LIMIT_FE_REDIS_NAMESPACE if RATE_LIMIT_FE_REDIS_URI is set to a redis instance. These are expected rate-limits for user client access.

All back-end rate-limits are shared across nodes sharing the same RATE_LIMIT_BE_REDIS_NAMESPACE if RATE_LIMIT_BE_REDIS_URI is set to a redis instance. These are expected rate-limits for developer’s back-end access.


overhide-ethereum - 覆盖<a href=以太坊eth“>

overhide.io

一个免费的、开源的(主要是)小部件生态系统、一个前端库和后端服务—尽可能将“登录”和“应用内购买”(IAP)添加到您的应用程序中


overhide以太坊eth

阅读API并在此处使用它:

Rinkeyby Testnet:https://rinkeby.ethereum.overhide.io/swagger.html

主网:https://ethereum.overhide.io/swagger.html

overhide系统提供了一套薪酬提供者,实现overhide薪酬API。此存储库是以太坊ethAPI提供程序

overhide-ethereum - 覆盖<a href=以太坊eth“>图1:显示了暴露API的以太坊ethoverhide提供程序

关于

通过演示和阅读系统背后的意图和动机,阅读更多关于这套支持基于分类帐的授权流的工具的信息

演示中使用了这个Rinkeyby testnet提供程序

这些步骤假设Docker可用

在Windows上,npm run clean脚本假定PowerShell已安装并配置:与@PowerShell一起运行。请确保PowerShell已安装或不使用此脚本

快速启动

请查看下面的配置部分,因为至少必须配置ETHERSCANu密钥才能运行此软件包中的测试

有关详细信息,请阅读本自述的其余部分

注意:npm run compose dev步骤(下面)构建并运行一个只用于测试的自以为是容器,其设置和凭证适合用于下游测试(例如,绑定到“rinkeby”testnet)

要构建非测试容器,请参见下面的构建Docker映像部分

Docker容器中的overhide以太坊eth快速启动

从现在起,您需要使用以下命令来停止/重新启动操作:

该服务使用带有承载的授权头。。所有终结点的标记

  1. npm安装–全局–生产windows构建工具
  2. npm安装–引入依赖项
  3. 复制./。npmrc.sample 到/npmrc.dev
  4. 编辑。/。npmrc.dev 将“ETHERSCANu KEY”设置为https://etherscan.io API 键
  5. npm run compose dev–构建并启动overhide以太坊ethDocker容器
  6. 跳转到“首次数据库设置”部分,用于首次数据库设置
  7. 跳转到“数据库”“进化”部分,尤其是“对于Docker”子部分
  8. 您的oh-eth容器失败,因为您的DB没有设置–现在是–找到您的oh-eth容器名称:Docker ps-a;寻找“退出”状态的oh eth
  9. npm test—对上述
  10. point browser at http://editor.swagger.io/?url=http://localhost:8080/swagger.json — to use the API

默认情况下,./main/js/lib/token.js 在此发行版中,将根据https://token.overhide.io/swagger.html (请参见获取/验证)。如果未配置SALT值,则会发生默认操作

  • 点浏览器运行测试http://editor.swagger.io/?url=http://localhost:8080/swagger.json –要使用API,请运行clean—停止过度隐藏以太坊ethDocker容器并删除映像—global—生产windows构建工具—引入依赖项跳转到“首次数据库设置”部分对于首次数据库设置跳转到“数据库演化”部分,特别是“for Docker”子部分-ethereum:E

本地运行的overhide以太坊eth快速启动

  1. npm install --global --production windows-build-tools
  2. npm install — bring in dependencies
  3. jump to “First Time DB Setup” section for the first-time DB setup
  4. jump to “Database Evolutions” section, especially the “For Docker” subsection
  5. npm config set overhide-ethereum:ETHERSCAN_KEY=... — replace ‘…’ with your https://etherscan.io API key
  6. npm config set overhide-ethereum:OH_ETH_PORT=8081 — (optional) only necessary if you have a port conflict
  7. npm run start — start overhide-ethereum on localhost
  8. npm test — in another terminal; run tests against above:
  9. point browser at http://editor.swagger.io/?url=http://localhost:8081/swagger.json — to use the API

安全

如果SALT未配置(默认),则用户必须使用https://token.overhide.io. API密钥必须用于根据https://token.overhide.io/swagger.html.

如果要在建立此服务的实例时利用SALT配置,还需要建立自己的overhide client auth service实例来提供此代码的令牌(请记住修改两个服务中的SALT值)

或者,您也可以返工。/main/js/lib/token.js 提供您自己的令牌身份验证。。。是OSS

的默认服务https://ethereum.overhide.io/swagger.html 以及https://rinkeby.ethereum.overhide.io/swagger.html 使用来自默认令牌提供程序的令牌https://token.overhide.io/register (API)

中列出了应用程序的所有配置点。npmrc.sample.

请参阅中的配置默认值。npmrc.sample 仅适用于测试

配置

这些npm配置点可通过npm config edit或npm config set覆盖(参见npm config):例如npm config set overhide-ethereum:ETHERSCAN_KEY new value为用户的~/.npmrc中的ETHERSCANu键设置一个新值

对于Docker compose环境,配置设置取自:

这些文件不受源代码管理。使用./创建它们。npmrc.sample 作为模板

如果提供了一个同名的环境变量,则该环境变量的值先于npm config值(~/.npmrc或package.json).

  • ./.npmrc.dev — for local dev
  • ./.npmrc.stage — for staging environment
  • ./.npmrc.prod — for production environment

过度隐藏以太坊eth的一些值得注意的配置点:

所有数据库连接配置点都假定数据库和数据库用户已设置

对于localhost Docker,将psql放入容器:

Configuration Point Description Sample Value
WEB3_WSS_URI The websocket web3 provider URI redacted
NETWORK_TYPE The network type (e.g. ‘mainnet’) rinkeby
ETHERSCAN_KEY The etherscan.io API key — good account summary source redacted
OH_ETH_PORT overhide-ethereum‘s port 8080
OH_ETH_HOST overhide-ethereum‘s host localhost
BASE_URL host:port base URL as used from outside (of load-balancer) to access service localhost:8080
DEBUG see ‘Logging’ section below overhide-ethereum:*,-overhide-ethereum:is-signature-valid:txs,-overhide-ethereum:get-transactions:txs
SALT Salt for bearer-token validation (see Security above) c0c0nut
TOKEN_URL Token validation URL (see Security above) https://token.overhide.io/validate
INTERNAL_TOKEN Token to use with internal services to avoid rate-limiting (just set once from https://token.overhide.io/register in all services)
KEYV_TALLY_CACHE_URI URI of cache (redis) to tally requests (back-end) redis://localhost:6379
RATE_LIMIT_FE_WINDOW_MS Duration of API rate limiting window (milliseconds) (frontend) 60000
RATE_LIMIT_FE_MAX_REQUESTS_PER_WINDOW Number of API calls per rate limiting window 30
RATE_LIMIT_BE_WINDOW_MS Duration of API rate limiting window (milliseconds) (backend) 60000
RATE_LIMIT_BE_MAX_REQUESTS_PER_WINDOW Number of API calls per rate limiting window 600
EXPECTED_CONFIRMATIONS Number of confirmations before transaction is considered valid 2
IS_WORKER Enable this on one (and only one) node — runs worker processes that use up API limits true

首次数据库设置

应该已经创建了’adam’角色和’oh eth’DB,并使用上述命令连接到它们(根据。npmrc.dev 环境传递到docker组件)

如果没有,手动创建:

npm run psql-dev c "oh-eth" dt 

确保在.npmrc中适当地设置配置点

现在可以在新数据库上运行数据库演化了

postgres=# create database "oh-eth"; postgres=# create user adam with encrypted password 'c0c0nut'; postgres=# grant all privileges on database "oh-eth" to adam; 

只有一个节点文件可用于检查和执行数据库演化

使用npm Run db evolve从应用程序节点运行它

数据库演化

它将使数据库进化到特定应用程序版本所需的任何位置

main/js/lib/database.js 有一个init(..)方法,该方法应该检查数据库是否处于该版本应用程序的正确版本

在进化之前考虑当前正在运行的节点:它们是否能够与进化后的数据库一起运行?也许在进化之前阻止它们

要检查数据库演化前/演化后(第一次数据库设置已完成):

如果需要选择角色和数据库:

检查

更多命令:https://gist.github.com/apolloclark/ea5466d5929e63043dcf

  • log into DB
  • list tables
npm run psql-dev dt oh-eth.* 

如果使用Docker运行,跳入一个容器来运行演进:

set role oh-eth; c oh-eth; 

docker run-it-rm-linkpostgres:postgres –network 然后运行演进:

演化

npm run db evolve

通过https://www.npmjs.com/package/debug 模块

日志详细性通过DEBUG环境变量或同名的npm配置点进行控制

非调试(错误/警告/审核)日志记录在默认情况下以编程方式启用,尽管设置了调试变量。这些是“过度隐藏以太坊eth日志”日志

日志记录

将DEBUG设置为“overhide ethereum:*”将启用所有调试日志记录。这将是非常冗长的。可能需要以调试日志记录为目标,例如:

npm config set overhide-ethereum:DEBUG “过度隐藏以太坊eth:*,-过度隐藏-ethereum:is-signature-valid:txs,-过度隐藏-ethereum:get-transactions:txs“

重新启动Node.js 每次更改源文件时,请确保已安装nodemon:

npm install-g nodemon

StartNode.js 使用nodemon:

运行开发环境的说明

nodemon—检查main/js/overhide-ethereum.js

或使用npm脚本:

npm run dev

默认值中的配置package.json 对于开发/测试来说是合理的

您可以根据上面的配置部分覆盖配置

如果从命令shell开始使用npm run dev或nodemon覆盖以太坊eth,则需要显式地将开发环境连接到此节点进程以进行远程调试

开发配置

注意,上面的nodemon以–inspect开头,以允许远程调试

例如,要从VSCode进行远程调试,请使用以下运行时配置:

节点(远程)调试

在VSCode中选择“Node:Nodemon”运行时配置,并从overhide ethereum中查找与“ctxu config”控制台日志报告的PID匹配的“Node”进程

一旦在nodemon shell中看到“Debugger attached.”消息,您就可以开始工作了

npm测试或在./test/js/*中手动运行Mocha/Chai测试

  "version": "0.2.0",   "configurations": [     {       "type": "node",       "request": "attach",       "name": "Node: Nodemon",       "processId": "${command:PickProcess}",       "restart": true,       "protocol": "inspector"     }   ] 

测试不是单元测试。它们不会启动Node.js 跑过以太坊eth;他们希望被测试的目标设备能够运行以太坊eth

无论测试的配置如何,测试都应通过:

测试

可以使用OHu ETHu主机和OHu ETHu端口配置点将测试指向目标overhide以太坊eth进行测试

此服务通过status.json 终结点

运行示例(运行服务时)localhost:8080):

  • a development environment started using npm run start or npm run dev
  • a standalone Docker container started using npm run compose-dev

通过配置点对这些API的访问进行选通:

运行状况检查–端点

这仅适用于具有内部u令牌(如果已设置)以外的令牌的请求。内部令牌请求不受速率限制

如果rateu LIMITu FEu REDISu URI设置为REDIS实例,则所有前端速率限制将在共享相同rateu LIMITu FEu REDISu命名空间的节点之间共享。这些是用户客户端访问的预期速率限制

curl http://localhost:8080/status.html 

速率限制

如果rateu LIMITu BEu REDISu URI设置为REDIS实例,则所有后端速率限制都在共享相同rateu LIMITu BEu REDISu命名空间的节点之间共享。这些是开发人员后端访问的预期速率限制

  • RATE_LIMIT_FE_MAX_REQUESTS_PER_WINDOW
  • RATE_LIMIT_FE_WINDOW_MS
  • RATE_LIMIT_BE_MAX_REQUESTS_PER_WINDOW
  • RATE_LIMIT_BE_WINDOW_MS

This only applies to requests with a token other than the INTERNAL_TOKEN (if set). INTERNAL_TOKEN requests are not rate-limited.

All front-end rate-limits are shared across nodes sharing the same RATE_LIMIT_FE_REDIS_NAMESPACE if RATE_LIMIT_FE_REDIS_URI is set to a redis instance. These are expected rate-limits for user client access.

All back-end rate-limits are shared across nodes sharing the same RATE_LIMIT_BE_REDIS_NAMESPACE if RATE_LIMIT_BE_REDIS_URI is set to a redis instance. These are expected rate-limits for developer’s back-end access.

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/21884.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计overhide-ethereum – 覆盖以太坊

提供最优质的资源集合

立即查看 了解详情