Skip to content

Commit

Permalink
Merge pull request #321 from h1sk1/event_trigger
Browse files Browse the repository at this point in the history
Update Event trigger
  • Loading branch information
ncying authored Sep 6, 2024
2 parents d5aa2ac + 355c839 commit a1d7d2f
Show file tree
Hide file tree
Showing 136 changed files with 14,512 additions and 702 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This matrix builds VSYS with various JDKs and will be expanded to cover many more cases.

name: Build VSYS
on: [push,pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: install scala
run: |
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get update
sudo apt-get install sbt
- uses: actions/checkout@v2

- name: Build and Package
run: sbt packageAll



6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ test/*/data/*
src/test/**/.DS_Store

*.sublime-*

# metals
.metals/
.bloop/
.ammonite/
project/metals.sbt
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enablePlugins(sbtdocker.DockerPlugin, JavaServerAppPackaging, JDebPackaging, Sys

name := "vsys"
organization := "systems.v"
version := "0.3.1"
version := "0.4.2"
scalaVersion in ThisBuild := "2.12.6"
crossPaths := false
publishArtifact in (Compile, packageDoc) := false
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object Dependencies {
)

lazy val logging = Seq(
"ch.qos.logback" % "logback-classic" % "1.2.3",
"ch.qos.logback" % "logback-classic" % "1.2.9",
"org.slf4j" % "slf4j-api" % "1.7.25",
"org.slf4j" % "jul-to-slf4j" % "1.7.25",
"net.logstash.logback" % "logstash-logback-encoder" % "4.11"
Expand Down
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resolvers ++= Seq(
"Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
"Artima Maven Repository" at "http://repo.artima.com/releases",
"Typesafe repository" at "https://repo.scala-sbt.org",
"Artima Maven Repository" at "https://repo.artima.com/releases",
"JBoss" at "https://repository.jboss.org",
Resolver.sbtPluginRepo("releases")
)
Expand Down
13 changes: 7 additions & 6 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ vsys {
# In some cases, you may both set `decalred-address` and enable UPnP (e.g. when IGD can't reliably determine its
# external IP address). In such cases the node will attempt to configure an IGD to pass traffic from external port
# to `bind-address:port`. Please note, however, that this setup is not recommended.
# declared-address = "1.2.3.4:9923"
# declared-address = "1.2.3.4:9921"

# Network address
bind-address = "0.0.0.0"

# Port number
port = 9923
port = 9921

# Node name to send during handshake. Comment this string out to set random node name.
# node-name = "default-node-name"
Expand All @@ -43,7 +43,7 @@ vsys {
# nonce = 0

# List of IP addresses of well known nodes.
known-peers = []
known-peers = ["gemmer.vcoin.systems:9921","vnode.vcoin.systems:9921","gemmer.vos.systems:9921","vnode.vos.systems:9921"]

# How long the information about peer stays in database after the last communication with it
peers-data-residence-time = 1d
Expand Down Expand Up @@ -110,8 +110,8 @@ vsys {
# Min buffer size. Fast rollback is possible up to this value.
minimum-in-memory-diff-blocks = 3600

# Blockchain type. Could be TESTNET | MAINNET | CUSTOM. Default value is TESTNET.
type = TESTNET
# Blockchain type. Could be TESTNET | MAINNET | CUSTOM. Default value is MAINNET.
type = MAINNET

# 'custom' section present only if CUSTOM blockchain type is set. It's impossible to overwrite predefined 'testnet' and 'mainnet' configurations.
# custom {
Expand Down Expand Up @@ -159,7 +159,8 @@ vsys {
# !IMPORTANT if you change the settings below in state, rebuilding of state is required, which means you need to clean the data and resync the block at current version
state {
# turn on/off the state of transactions grouped by address and transaction type
tx-type-account-tx-ids = on
tx-type-account-tx-ids = off
tx-contract-tx-ids = off
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/scala/vsys/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class Application(val actorSystem: ActorSystem, val settings: VsysSettings) exte
// on unexpected shutdown
sys.addShutdownHook {
network.shutdown()
peerDatabase.close()
shutdown()
}

Expand Down
47 changes: 33 additions & 14 deletions src/main/scala/vsys/api/http/BlocksApiRoute.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package vsys.api.http

import javax.ws.rs.Path

import akka.http.scaladsl.marshalling.ToResponseMarshallable
import akka.http.scaladsl.server.Route
import io.netty.channel.group.ChannelGroup
Expand All @@ -13,7 +12,6 @@ import vsys.blockchain.state.ByteStr
import vsys.blockchain.transaction.TransactionParser
import vsys.network._
import vsys.settings.{CheckpointsSettings, RestAPISettings}

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

Expand All @@ -31,7 +29,10 @@ case class BlocksApiRoute(settings: RestAPISettings, checkpointsSettings: Checkp
}

@Path("/address/{address}/{from}/{to}")
@ApiOperation(value = "Address", notes = "Get list of blocks generated by specified address", httpMethod = "GET")
@ApiOperation(value = "Address", notes = "Get a block list generated by a specified `address` and a block height range (`from`/`to`)", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json response of the block list or error")
))
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "from", value = "Start block height", required = true, dataType = "integer", paramType = "path"),
new ApiImplicitParam(name = "to", value = "End block height", required = true, dataType = "integer", paramType = "path"),
Expand All @@ -52,10 +53,13 @@ case class BlocksApiRoute(settings: RestAPISettings, checkpointsSettings: Checkp
}

@Path("/child/{signature}")
@ApiOperation(value = "Child", notes = "Get children of specified block", httpMethod = "GET")
@ApiOperation(value = "Child", notes = "Get children of a specified block by the base58-encoded `signature`", httpMethod = "GET")
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "signature", value = "Base58-encoded signature", required = true, dataType = "string", paramType = "path")
))
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json response of the child block information or error")
))
def child: Route = (path("child" / Segment) & get) { encodedSignature =>
withBlock(history, encodedSignature) { block =>
complete(history.child(block).map(_.json + ("transaction count" -> Json.toJson(block.transactionData.length))).getOrElse[JsObject](
Expand All @@ -65,7 +69,7 @@ case class BlocksApiRoute(settings: RestAPISettings, checkpointsSettings: Checkp

@Path("/delay/{signature}/{blockNum}")
@ApiOperation(value = "Average delay",
notes = "Average delay in milliseconds between last `blockNum` blocks starting from block with `signature`", httpMethod = "GET")
notes = "Get the average delay in milliseconds between last `blockNum` blocks starting from block with `signature`", httpMethod = "GET", response = classOf[Long])
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "signature", value = "Base58-encoded signature", required = true, dataType = "string", paramType = "path"),
new ApiImplicitParam(name = "blockNum", value = "Number of blocks to count delay", required = true, dataType = "string", paramType = "path")
Expand All @@ -78,7 +82,7 @@ case class BlocksApiRoute(settings: RestAPISettings, checkpointsSettings: Checkp
}

@Path("/height/{signature}")
@ApiOperation(value = "Height", notes = "Get height of a block by its Base58-encoded signature", httpMethod = "GET")
@ApiOperation(value = "Height", notes = "Get the **block height** by its Base58-encoded `signature`", httpMethod = "GET", response = classOf[Int])
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "signature", value = "Base58-encoded signature", required = true, dataType = "string", paramType = "path")
))
Expand All @@ -95,13 +99,16 @@ case class BlocksApiRoute(settings: RestAPISettings, checkpointsSettings: Checkp
}

@Path("/height")
@ApiOperation(value = "Height", notes = "Get blockchain height", httpMethod = "GET")
@ApiOperation(value = "Height", notes = "Get blockchain height", httpMethod = "GET", response=classOf[Int])
def height: Route = (path("height") & get) {
complete(Json.obj("height" -> history.height()))
}

@Path("/at/{height}")
@ApiOperation(value = "At", notes = "Get block at specified height", httpMethod = "GET")
@ApiOperation(value = "At", notes = "Get block at specified `height`", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json response of a block details at a specified height or error")
))
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "height", value = "Block height", required = true, dataType = "integer", paramType = "path")
))
Expand All @@ -113,7 +120,10 @@ case class BlocksApiRoute(settings: RestAPISettings, checkpointsSettings: Checkp
}

@Path("/seq/{from}/{to}")
@ApiOperation(value = "Seq", notes = "Get block at specified heights", httpMethod = "GET")
@ApiOperation(value = "Seq", notes = "Get block at the specified height range (`from`/`to`)", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json response of the block list or error")
))
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "from", value = "Start block height", required = true, dataType = "integer", paramType = "path"),
new ApiImplicitParam(name = "to", value = "End block height", required = true, dataType = "integer", paramType = "path")
Expand All @@ -130,21 +140,30 @@ case class BlocksApiRoute(settings: RestAPISettings, checkpointsSettings: Checkp


@Path("/last")
@ApiOperation(value = "Last", notes = "Get last block data", httpMethod = "GET")
@ApiOperation(value = "Last", notes = "Get the **last block** data", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json response of the last block information or error")
))
def last: Route = (path("last") & get) {
val height = history.height()
val lastBlock = history.blockAt(height).get
complete(lastBlock.json + ("height" -> Json.toJson(height)) + ("transaction count" -> Json.toJson(lastBlock.transactionData.length)))
}

@Path("/first")
@ApiOperation(value = "First", notes = "Get genesis block data", httpMethod = "GET")
@ApiOperation(value = "First", notes = "Get the **genesis block** data", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json response of the first block details or error")
))
def first: Route = (path("first") & get) {
complete(history.genesis.json + ("height" -> Json.toJson(1)) + ("transaction count" -> Json.toJson(history.genesis.transactionData.length)))
}

@Path("/signature/{signature}")
@ApiOperation(value = "Signature", notes = "Get block by a specified Base58-encoded signature", httpMethod = "GET")
@ApiOperation(value = "Signature", notes = "Get block by a specified Base58-encoded `signature`", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json response of the block details or error")
))
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "signature", value = "Base58-encoded signature", required = true, dataType = "string", paramType = "path")
))
Expand All @@ -159,13 +178,13 @@ case class BlocksApiRoute(settings: RestAPISettings, checkpointsSettings: Checkp
}

@Path("/checkpoint")
@ApiOperation(value = "Checkpoint", notes = "Broadcast checkpoint of blocks", httpMethod = "POST")
@ApiOperation(value = "Checkpoint", notes = "Broadcast the checkpoint of blocks", httpMethod = "POST")
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "message", value = "Checkpoint message", required = true, paramType = "body",
dataType = "vsys.network.Checkpoint")
))
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json with response or error")
new ApiResponse(code = 200, message = "Successful Operation")
))
def checkpoint: Route = (path("checkpoint") & post) {
json[Checkpoint] { checkpoint =>
Expand Down
12 changes: 9 additions & 3 deletions src/main/scala/vsys/api/http/NodeApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ case class NodeApiRoute(settings: RestAPISettings,
}

@Path("/version")
@ApiOperation(value = "Version", notes = "Get VSYS node version", httpMethod = "GET")
@ApiOperation(value = "Version", notes = "Get VSYS node version", httpMethod = "GET", response = classOf[String])
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json VSYS node version")
new ApiResponse(code = 200, message = "Json response of VSYS node version")
))
def version: Route = (get & path("version")) {
complete(Json.obj("version" -> Constants.AgentName))
Expand All @@ -35,14 +35,20 @@ case class NodeApiRoute(settings: RestAPISettings,
@Path("/stop")
@ApiOperation(value = "Stop", notes = "Stop the node", httpMethod = "POST",
authorizations = Array(new Authorization("api_key")))
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Successful Operation")
))
def stop: Route = (post & path("stop") & withAuth) {
log.info("Request to stop application")
application.shutdown()
complete(Json.obj("stopped" -> true))
}

@Path("/status")
@ApiOperation(value = "Status", notes = "Get status of the running core", httpMethod = "GET")
@ApiOperation(value = "Status", notes = "Get **status** of the running core", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json response of the node status or error")
))
def status: Route = (get & path("status")) {
val lastUpdated = history.lastBlock.get.timestamp
complete(
Expand Down
26 changes: 14 additions & 12 deletions src/main/scala/vsys/api/http/PeersApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ case class PeersApiRoute(
}

@Path("/all")
@ApiOperation(value = "Peer list", notes = "Peer list", httpMethod = "GET")
@ApiOperation(value = "Peer list", notes = "Get the peer list", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json with peer list or error")
new ApiResponse(code = 200, message = "Json response of a peer list or error")
))
def allPeers: Route = (path("all") & get) {
complete(Json.obj("peers" ->
Expand All @@ -44,9 +44,9 @@ case class PeersApiRoute(
}

@Path("/connected")
@ApiOperation(value = "Connected peers list", notes = "Connected peers list", httpMethod = "GET")
@ApiOperation(value = "Connected peers list", notes = "Get the connected peers list", httpMethod = "GET")
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Json with connected peers or error")
new ApiResponse(code = 200, message = "Json response of a connected peers list or error")
))
def connectedPeers: Route = (path("connected") & get) {
val peers = establishedConnections.values().stream().map[JsValue](pi => Json.obj(
Expand All @@ -64,14 +64,16 @@ case class PeersApiRoute(
@Path("/connect")
@ApiOperation(value = "Connect to peer", notes = "Connect to peer", httpMethod = "POST",
authorizations = Array(new Authorization("api_key")))
@ApiResponses(Array(
new ApiResponse(code = 200, message = "Successful Operation")
))
@ApiImplicitParams(Array(
new ApiImplicitParam(
name = "body",
value = "Json with data",
value = "Peer host settings",
required = true,
paramType = "body",
dataType = "string",
defaultValue = "{\n\t\"host\":\"127.0.0.1\",\n\t\"port\":\"9084\"\n}"
dataType = "vsys.network.PeerNetworkConnection",
)
))
def connect: Route = (path("connect") & post & withAuth) {
Expand All @@ -84,10 +86,10 @@ case class PeersApiRoute(
}

@Path("/blacklisted")
@ApiOperation(value = "Blacklisted peers list", notes = "Blacklisted peers list", httpMethod = "GET")
@ApiOperation(value = "Blacklisted peers list", notes = "Get the blacklisted peers list", httpMethod = "GET")
@ApiResponses(
Array(
new ApiResponse(code = 200, message = "Json with blacklisted peers or error")
new ApiResponse(code = 200, message = "Json response of the blacklisted peers or error")
))
def blacklistedPeers: Route = (path("blacklisted") & get) {
complete(
Expand All @@ -99,10 +101,10 @@ case class PeersApiRoute(
}

@Path("/suspended")
@ApiOperation(value = "Suspended peers list", notes = "Suspended peers list", httpMethod = "GET")
@ApiOperation(value = "Suspended peers list", notes = "Get the suspended peers list", httpMethod = "GET")
@ApiResponses(
Array(
new ApiResponse(code = 200, message = "JSON with suspended peers or error")
new ApiResponse(code = 200, message = "JSON response of a suspended peer list or error")
))
def suspendedPeers: Route = (path("suspended") & get) {
complete(
Expand All @@ -115,7 +117,7 @@ case class PeersApiRoute(
authorizations = Array(new Authorization("api_key")))
@ApiResponses(
Array(
new ApiResponse(code = 200, message = "200")
new ApiResponse(code = 200, message = "Successful Operation")
))
def clearBlacklist: Route = (path("clearblacklist") & post & withAuth) {
peerDatabase.clearBlacklist()
Expand Down
Loading

1 comment on commit a1d7d2f

@fukvsys
Copy link

@fukvsys fukvsys commented on a1d7d2f Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

垃圾,畜生,诈骗狗,你们在开发SK和杨狗妈逼链吗?一地鸡毛!

vsystems is the most shameless and rubbish scam dog in the entire network.

970,000 new vsys scam coins are issued, and only 30 vsys are destroyed every day.

vsys has no applications, no users, and dead chain with no on-chain transactions!

Please sign in to comment.