├── .idea ├── .gitignore ├── vcs.xml ├── modules.xml └── encodings.xml ├── src ├── main │ ├── resources │ │ ├── static │ │ │ ├── api │ │ │ │ ├── clear.json │ │ │ │ ├── upload.json │ │ │ │ ├── lightboard │ │ │ │ │ └── block.json │ │ │ │ └── tableSelect.json │ │ │ ├── images │ │ │ │ ├── bg.jpg │ │ │ │ ├── home.png │ │ │ │ ├── logo.png │ │ │ │ ├── captcha.jpg │ │ │ │ ├── favicon.ico │ │ │ │ └── donate_qrcode.png │ │ │ ├── lib │ │ │ │ ├── layui-v2.5.5 │ │ │ │ │ ├── font │ │ │ │ │ │ ├── iconfont.eot │ │ │ │ │ │ ├── iconfont.ttf │ │ │ │ │ │ ├── iconfont.woff │ │ │ │ │ │ └── iconfont.woff2 │ │ │ │ │ ├── images │ │ │ │ │ │ └── face │ │ │ │ │ │ │ ├── 0.gif │ │ │ │ │ │ │ ├── 1.gif │ │ │ │ │ │ │ ├── 10.gif │ │ │ │ │ │ │ ├── 11.gif │ │ │ │ │ │ │ ├── 12.gif │ │ │ │ │ │ │ ├── 13.gif │ │ │ │ │ │ │ ├── 14.gif │ │ │ │ │ │ │ ├── 15.gif │ │ │ │ │ │ │ ├── 16.gif │ │ │ │ │ │ │ ├── 17.gif │ │ │ │ │ │ │ ├── 18.gif │ │ │ │ │ │ │ ├── 19.gif │ │ │ │ │ │ │ ├── 2.gif │ │ │ │ │ │ │ ├── 20.gif │ │ │ │ │ │ │ ├── 21.gif │ │ │ │ │ │ │ ├── 22.gif │ │ │ │ │ │ │ ├── 23.gif │ │ │ │ │ │ │ ├── 24.gif │ │ │ │ │ │ │ ├── 25.gif │ │ │ │ │ │ │ ├── 26.gif │ │ │ │ │ │ │ ├── 27.gif │ │ │ │ │ │ │ ├── 28.gif │ │ │ │ │ │ │ ├── 29.gif │ │ │ │ │ │ │ ├── 3.gif │ │ │ │ │ │ │ ├── 30.gif │ │ │ │ │ │ │ ├── 31.gif │ │ │ │ │ │ │ ├── 32.gif │ │ │ │ │ │ │ ├── 33.gif │ │ │ │ │ │ │ ├── 34.gif │ │ │ │ │ │ │ ├── 35.gif │ │ │ │ │ │ │ ├── 36.gif │ │ │ │ │ │ │ ├── 37.gif │ │ │ │ │ │ │ ├── 38.gif │ │ │ │ │ │ │ ├── 39.gif │ │ │ │ │ │ │ ├── 4.gif │ │ │ │ │ │ │ ├── 40.gif │ │ │ │ │ │ │ ├── 41.gif │ │ │ │ │ │ │ ├── 42.gif │ │ │ │ │ │ │ ├── 43.gif │ │ │ │ │ │ │ ├── 44.gif │ │ │ │ │ │ │ ├── 45.gif │ │ │ │ │ │ │ ├── 46.gif │ │ │ │ │ │ │ ├── 47.gif │ │ │ │ │ │ │ ├── 48.gif │ │ │ │ │ │ │ ├── 49.gif │ │ │ │ │ │ │ ├── 5.gif │ │ │ │ │ │ │ ├── 50.gif │ │ │ │ │ │ │ ├── 51.gif │ │ │ │ │ │ │ ├── 52.gif │ │ │ │ │ │ │ ├── 53.gif │ │ │ │ │ │ │ ├── 54.gif │ │ │ │ │ │ │ ├── 55.gif │ │ │ │ │ │ │ ├── 56.gif │ │ │ │ │ │ │ ├── 57.gif │ │ │ │ │ │ │ ├── 58.gif │ │ │ │ │ │ │ ├── 59.gif │ │ │ │ │ │ │ ├── 6.gif │ │ │ │ │ │ │ ├── 60.gif │ │ │ │ │ │ │ ├── 61.gif │ │ │ │ │ │ │ ├── 62.gif │ │ │ │ │ │ │ ├── 63.gif │ │ │ │ │ │ │ ├── 64.gif │ │ │ │ │ │ │ ├── 65.gif │ │ │ │ │ │ │ ├── 66.gif │ │ │ │ │ │ │ ├── 67.gif │ │ │ │ │ │ │ ├── 68.gif │ │ │ │ │ │ │ ├── 69.gif │ │ │ │ │ │ │ ├── 7.gif │ │ │ │ │ │ │ ├── 70.gif │ │ │ │ │ │ │ ├── 71.gif │ │ │ │ │ │ │ ├── 8.gif │ │ │ │ │ │ │ └── 9.gif │ │ │ │ │ ├── css │ │ │ │ │ │ └── modules │ │ │ │ │ │ │ ├── layer │ │ │ │ │ │ │ └── default │ │ │ │ │ │ │ │ ├── icon.png │ │ │ │ │ │ │ │ ├── icon-ext.png │ │ │ │ │ │ │ │ ├── loading-0.gif │ │ │ │ │ │ │ │ ├── loading-1.gif │ │ │ │ │ │ │ │ └── loading-2.gif │ │ │ │ │ │ │ └── code.css │ │ │ │ │ └── lay │ │ │ │ │ │ └── modules │ │ │ │ │ │ ├── code.js │ │ │ │ │ │ ├── laytpl.js │ │ │ │ │ │ ├── flow.js │ │ │ │ │ │ └── rate.js │ │ │ │ └── font-awesome-4.7.0 │ │ │ │ │ ├── fonts │ │ │ │ │ ├── FontAwesome.otf │ │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ │ └── fontawesome-webfont.woff2 │ │ │ │ │ ├── less │ │ │ │ │ ├── fixed-width.less │ │ │ │ │ ├── screen-reader.less │ │ │ │ │ ├── larger.less │ │ │ │ │ ├── list.less │ │ │ │ │ ├── core.less │ │ │ │ │ ├── stacked.less │ │ │ │ │ ├── font-awesome.less │ │ │ │ │ ├── bordered-pulled.less │ │ │ │ │ ├── rotated-flipped.less │ │ │ │ │ ├── path.less │ │ │ │ │ ├── animated.less │ │ │ │ │ └── mixins.less │ │ │ │ │ ├── scss │ │ │ │ │ ├── _fixed-width.scss │ │ │ │ │ ├── _screen-reader.scss │ │ │ │ │ ├── _larger.scss │ │ │ │ │ ├── _list.scss │ │ │ │ │ ├── _core.scss │ │ │ │ │ ├── font-awesome.scss │ │ │ │ │ ├── _stacked.scss │ │ │ │ │ ├── _bordered-pulled.scss │ │ │ │ │ ├── _rotated-flipped.scss │ │ │ │ │ ├── _path.scss │ │ │ │ │ ├── _animated.scss │ │ │ │ │ └── _mixins.scss │ │ │ │ │ └── HELP-US-OUT.txt │ │ │ ├── js │ │ │ │ ├── lay-module │ │ │ │ │ ├── wangEditor │ │ │ │ │ │ └── fonts │ │ │ │ │ │ │ └── w-e-icon.woff │ │ │ │ │ ├── treetable-lay │ │ │ │ │ │ └── treetable.css │ │ │ │ │ ├── layuimini │ │ │ │ │ │ └── miniTongji.js │ │ │ │ │ └── step-lay │ │ │ │ │ │ └── step.css │ │ │ │ ├── test.html │ │ │ │ ├── common.js │ │ │ │ ├── lay-config.js │ │ │ │ └── index.js │ │ │ ├── css │ │ │ │ ├── public.css │ │ │ │ └── page │ │ │ │ │ └── login-1.css │ │ │ └── page │ │ │ │ ├── memberBoard.html │ │ │ │ ├── gossipBoard.html │ │ │ │ └── heartBeatBoard.html │ │ ├── log4j.properties │ │ ├── application.properties │ │ └── META-INF │ │ │ └── MANIFEST.MF │ └── java │ │ ├── com │ │ └── timvanx │ │ │ ├── cmd │ │ │ └── Constant.java │ │ │ ├── BlockChainStarter.java │ │ │ ├── blockchain │ │ │ ├── model │ │ │ │ └── POW.java │ │ │ └── Test.java │ │ │ ├── Application.java │ │ │ ├── web │ │ │ ├── config │ │ │ │ ├── LightDiskHungrySingleton.java │ │ │ │ ├── MyWebMvcConfigurer.java │ │ │ │ └── LoginHandlerInterceptor.java │ │ │ ├── service │ │ │ │ ├── TransactionServiceImpl.java │ │ │ │ └── BlockServiceImpl.java │ │ │ ├── dao │ │ │ │ ├── TransactionDAO.java │ │ │ │ └── BlockDAO.java │ │ │ └── controller │ │ │ │ └── TransactionController.java │ │ │ ├── gossip │ │ │ ├── impl │ │ │ │ └── ImplCrdtOperator.java │ │ │ └── model │ │ │ │ └── NodeURI.java │ │ │ └── model │ │ │ └── ResponseJson.java │ │ └── org │ │ └── apache │ │ └── com │ │ └── timvanx │ │ └── gossip │ │ ├── model │ │ ├── Message.java │ │ ├── Response.java │ │ ├── ActiveGossipOk.java │ │ ├── NotAMemberFault.java │ │ ├── Fault.java │ │ ├── SignedPayload.java │ │ ├── ActiveGossipMessage.java │ │ ├── PerNodeDataBulkMessage.java │ │ ├── SharedDataBulkMessage.java │ │ ├── ShutdownMessage.java │ │ ├── Base.java │ │ ├── Member.java │ │ ├── SharedDataMessage.java │ │ └── PerNodeDataMessage.java │ │ ├── manager │ │ ├── Clock.java │ │ ├── PassiveGossipConstants.java │ │ ├── SystemClock.java │ │ ├── handlers │ │ │ ├── MessageHandler.java │ │ │ ├── SharedDataMessageHandler.java │ │ │ ├── PerNodeDataMessageHandler.java │ │ │ ├── ResponseHandler.java │ │ │ ├── SharedDataBulkMessageHandler.java │ │ │ ├── PerNodeDataBulkMessageHandler.java │ │ │ ├── ShutdownMessageHandler.java │ │ │ └── TypedMessageHandler.java │ │ ├── GossipCoreConstants.java │ │ └── RingStatePersister.java │ │ ├── crdt │ │ ├── CrdtCounter.java │ │ ├── CrdtSet.java │ │ ├── CrdtAddRemoveSet.java │ │ ├── Crdt.java │ │ └── CrdtBiFunctionMerge.java │ │ ├── event │ │ ├── GossipListener.java │ │ ├── GossipState.java │ │ └── data │ │ │ ├── UpdateSharedDataEventHandler.java │ │ │ ├── UpdateNodeDataEventHandler.java │ │ │ └── DataEventConstants.java │ │ ├── udp │ │ ├── Trackable.java │ │ ├── UdpActiveGossipOk.java │ │ ├── UdpNotAMemberFault.java │ │ ├── UdpActiveGossipMessage.java │ │ ├── UdpPerNodeDataMessage.java │ │ ├── UdpPerNodeDataBulkMessage.java │ │ ├── UdpSharedDataBulkMessage.java │ │ └── UdpSharedDataMessage.java │ │ ├── lock │ │ ├── vote │ │ │ ├── VoteSelector.java │ │ │ ├── RandomVoteSelector.java │ │ │ ├── Vote.java │ │ │ └── VoteCandidate.java │ │ └── exceptions │ │ │ └── VoteFailedException.java │ │ ├── replication │ │ ├── NotReplicable.java │ │ ├── AllReplicable.java │ │ ├── Replicable.java │ │ ├── WhiteListReplicable.java │ │ ├── BlackListReplicable.java │ │ └── DataCenterReplicable.java │ │ ├── protocol │ │ └── ProtocolManager.java │ │ ├── RemoteMember.java │ │ ├── transport │ │ └── TransportManager.java │ │ ├── secure │ │ └── KeyTool.java │ │ ├── utils │ │ └── ReflectionUtils.java │ │ └── LocalMember.java └── test │ └── java │ └── TestApacheGossip.java ├── doc └── references.txt ├── README.en.md └── README.md /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml -------------------------------------------------------------------------------- /src/main/resources/static/api/clear.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 1, 3 | "msg": "服务端清理缓存成功" 4 | } -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/log4j.properties -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/application.properties -------------------------------------------------------------------------------- /src/main/resources/static/images/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/images/bg.jpg -------------------------------------------------------------------------------- /src/main/resources/static/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/images/home.png -------------------------------------------------------------------------------- /src/main/resources/static/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/images/logo.png -------------------------------------------------------------------------------- /src/main/resources/static/images/captcha.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/images/captcha.jpg -------------------------------------------------------------------------------- /src/main/resources/static/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/images/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/static/images/donate_qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/images/donate_qrcode.png -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/font/iconfont.eot -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/font/iconfont.ttf -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/font/iconfont.woff -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/0.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/1.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/10.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/11.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/12.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/13.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/14.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/15.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/16.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/17.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/18.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/19.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/2.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/20.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/21.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/22.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/23.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/24.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/25.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/26.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/27.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/28.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/29.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/3.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/30.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/31.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/32.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/33.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/34.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/35.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/36.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/37.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/38.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/39.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/4.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/40.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/41.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/42.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/43.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/44.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/45.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/46.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/47.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/48.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/49.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/5.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/50.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/51.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/52.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/53.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/54.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/55.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/56.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/57.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/58.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/59.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/6.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/60.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/61.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/62.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/63.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/64.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/65.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/66.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/67.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/68.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/69.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/7.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/70.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/71.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/8.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/images/face/9.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/font/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/font/iconfont.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/js/lay-module/wangEditor/fonts/w-e-icon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/js/lay-module/wangEditor/fonts/w-e-icon.woff -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/font-awesome-4.7.0/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/fixed-width.less: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .@{fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/screen-reader.less: -------------------------------------------------------------------------------- 1 | // Screen Readers 2 | // ------------------------- 3 | 4 | .sr-only { .sr-only(); } 5 | .sr-only-focusable { .sr-only-focusable(); } 6 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_fixed-width.scss: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .#{$fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /src/main/resources/static/api/upload.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 1, 3 | "msg": "上传成功", 4 | "data": { 5 | "url": [ 6 | "../images/logo.png", 7 | "../images/captcha.jpg" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimVan1596/LightDisk/HEAD/src/main/resources/static/lib/layui-v2.5.5/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_screen-reader.scss: -------------------------------------------------------------------------------- 1 | // Screen Readers 2 | // ------------------------- 3 | 4 | .sr-only { @include sr-only(); } 5 | .sr-only-focusable { @include sr-only-focusable(); } 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/test/java/TestApacheGossip.java: -------------------------------------------------------------------------------- 1 | /** 2 | *

BlockChain

3 | *

4 | * 5 | * @author : TimVan 6 | * @date : 2020-03-27 18:27 7 | **/ 8 | public class TestApacheGossip { 9 | public static void main(String[] args) { 10 | System.out.println("Hello World"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/resources/static/api/lightboard/block.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 0, 3 | "msg": "", 4 | "count": 1000, 5 | "data": [ 6 | { 7 | "height": 3, 8 | "timestamp": "1588478071007", 9 | "nonce": "92996", 10 | "transactions": 1, 11 | "difficultyTarget": 3, 12 | "hash": "000d017dd863e8505bfbe98a39aece1c001a925b252c46b5112058b403f4a050" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/HELP-US-OUT.txt: -------------------------------------------------------------------------------- 1 | I hope you love Font Awesome. If you've found it useful, please do me a favor and check out my latest project, 2 | Fort Awesome (https://fortawesome.com). It makes it easy to put the perfect icons on your website. Choose from our awesome, 3 | comprehensive icon sets or copy and paste your own. 4 | 5 | Please. Check it out. 6 | 7 | -Dave Gandy 8 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/cmd/Constant.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.cmd; 2 | 3 | /** 4 | *

BlockChain

5 | *

常量类

6 | * 7 | * @author : TimVan 8 | * @date : 2020-04-28 20:51 9 | **/ 10 | public class Constant { 11 | 12 | /** 13 | * VERSION = 版本号 14 | * SOFT_NAME = 软件名 15 | * */ 16 | final static String VERSION = "0.4"; 17 | final static String SOFT_NAME = "LightDisk命令行"; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/static/js/lay-module/treetable-lay/treetable.css: -------------------------------------------------------------------------------- 1 | .treeTable-empty { 2 | width: 20px; 3 | display: inline-block; 4 | } 5 | 6 | .treeTable-icon { 7 | cursor: pointer; 8 | } 9 | 10 | .treeTable-icon .layui-icon-triangle-d:before { 11 | content: "\e623"; 12 | } 13 | 14 | .treeTable-icon.open .layui-icon-triangle-d:before { 15 | content: "\e625"; 16 | background-color: transparent; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /doc/references.txt: -------------------------------------------------------------------------------- 1 | 1、https://www.cnblogs.com/jieerma666/p/10342435.html 2 | 用JAVA分别实现WebSocket客户端与服务端 3 | 4 | 2、https://blog.51cto.com/4577390/2114116 5 | BLOCKCHAIN 区块链的去中心化P2P服务的JAVA代码的实现 6 | 7 | 8 | 3、https://www.jianshu.com/p/ad47595e7e4f 9 | 比特币学习之-P2P网络 10 | 11 | 12 | 4、https://blog.csdn.net/shangsongwww/article/details/89096460 13 | 比特币的P2P网络协议 14 | 15 | 16 | 5、https://lvsq.net/2019/12/jgossip/ 17 | Jgossip - gossip协议的开源实现 18 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/larger.less: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .@{fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .@{fa-css-prefix}-2x { font-size: 2em; } 11 | .@{fa-css-prefix}-3x { font-size: 3em; } 12 | .@{fa-css-prefix}-4x { font-size: 4em; } 13 | .@{fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_larger.scss: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .#{$fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .#{$fa-css-prefix}-2x { font-size: 2em; } 11 | .#{$fa-css-prefix}-3x { font-size: 3em; } 12 | .#{$fa-css-prefix}-4x { font-size: 4em; } 13 | .#{$fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/list.less: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: @fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: (-@fa-li-width + (4em / 14)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_list.scss: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: $fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .#{$fa-css-prefix}-li { 11 | position: absolute; 12 | left: -$fa-li-width; 13 | width: $fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.#{$fa-css-prefix}-lg { 17 | left: -$fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/core.less: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/@fa-line-height-base FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_core.scss: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/#{$fa-line-height-base} FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/BlockChainStarter.java: -------------------------------------------------------------------------------- 1 | package com.timvanx; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | *

BlockChain

7 | *

启动类

8 | * 9 | * @author : TimVan 10 | * @date : 2020-03-27 20:43 11 | **/ 12 | public class BlockChainStarter { 13 | public static void main(String[] args) throws IOException { 14 | String ip = "192.168.0.103"; 15 | int port = 5401; 16 | String[] split = ip.split("\\."); 17 | String id = split[3]+port; 18 | 19 | System.out.println("id="+id); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/font-awesome.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables"; 7 | @import "mixins"; 8 | @import "path"; 9 | @import "core"; 10 | @import "larger"; 11 | @import "fixed-width"; 12 | @import "list"; 13 | @import "bordered-pulled"; 14 | @import "animated"; 15 | @import "rotated-flipped"; 16 | @import "stacked"; 17 | @import "icons"; 18 | @import "screen-reader"; 19 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/blockchain/model/POW.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.blockchain.model; 2 | 3 | /** 4 | *

BlockChain

5 | *

工作量证明

6 | * 7 | * @author : TimVan 8 | * @date : 2020-04-28 17:56 9 | **/ 10 | public class POW { 11 | public static boolean checkHashByDifficultTarget(String hash,long target){ 12 | StringBuilder stringBuffer = new StringBuilder(); 13 | for (int i = 0; i < target; i++) { 14 | stringBuffer.append("0"); 15 | } 16 | return hash.startsWith(stringBuffer.toString()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_stacked.scss: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .#{$fa-css-prefix}-stack-1x, .#{$fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .#{$fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .#{$fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .#{$fa-css-prefix}-inverse { color: $fa-inverse; } 21 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/font-awesome.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables.less"; 7 | @import "mixins.less"; 8 | @import "path.less"; 9 | @import "core.less"; 10 | @import "larger.less"; 11 | @import "fixed-width.less"; 12 | @import "list.less"; 13 | @import "bordered-pulled.less"; 14 | @import "animated.less"; 15 | @import "rotated-flipped.less"; 16 | @import "stacked.less"; 17 | @import "icons.less"; 18 | @import "screen-reader.less"; 19 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/Application.java: -------------------------------------------------------------------------------- 1 | package com.timvanx; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 7 | import org.springframework.cache.annotation.EnableCaching; 8 | 9 | 10 | /** 11 | * @author 87702 12 | */ 13 | @SpringBootApplication 14 | @EnableCaching // 启用缓存 15 | public class Application extends SpringBootServletInitializer { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(Application.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/bordered-pulled.less: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em @fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .@{fa-css-prefix}-pull-left { float: left; } 11 | .@{fa-css-prefix}-pull-right { float: right; } 12 | 13 | .@{fa-css-prefix} { 14 | &.@{fa-css-prefix}-pull-left { margin-right: .3em; } 15 | &.@{fa-css-prefix}-pull-right { margin-left: .3em; } 16 | } 17 | 18 | /* Deprecated as of 4.4.0 */ 19 | .pull-right { float: right; } 20 | .pull-left { float: left; } 21 | 22 | .@{fa-css-prefix} { 23 | &.pull-left { margin-right: .3em; } 24 | &.pull-right { margin-left: .3em; } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_bordered-pulled.scss: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em $fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .#{$fa-css-prefix}-pull-left { float: left; } 11 | .#{$fa-css-prefix}-pull-right { float: right; } 12 | 13 | .#{$fa-css-prefix} { 14 | &.#{$fa-css-prefix}-pull-left { margin-right: .3em; } 15 | &.#{$fa-css-prefix}-pull-right { margin-left: .3em; } 16 | } 17 | 18 | /* Deprecated as of 4.4.0 */ 19 | .pull-right { float: right; } 20 | .pull-left { float: left; } 21 | 22 | .#{$fa-css-prefix} { 23 | &.pull-left { margin-right: .3em; } 24 | &.pull-right { margin-left: .3em; } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/rotated-flipped.less: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-rotate-90 { .fa-icon-rotate(90deg, 1); } 5 | .@{fa-css-prefix}-rotate-180 { .fa-icon-rotate(180deg, 2); } 6 | .@{fa-css-prefix}-rotate-270 { .fa-icon-rotate(270deg, 3); } 7 | 8 | .@{fa-css-prefix}-flip-horizontal { .fa-icon-flip(-1, 1, 0); } 9 | .@{fa-css-prefix}-flip-vertical { .fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .@{fa-css-prefix}-rotate-90, 15 | :root .@{fa-css-prefix}-rotate-180, 16 | :root .@{fa-css-prefix}-rotate-270, 17 | :root .@{fa-css-prefix}-flip-horizontal, 18 | :root .@{fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/static/js/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_rotated-flipped.scss: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } 5 | .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } 6 | .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } 7 | 8 | .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } 9 | .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .#{$fa-css-prefix}-rotate-90, 15 | :root .#{$fa-css-prefix}-rotate-180, 16 | :root .#{$fa-css-prefix}-rotate-270, 17 | :root .#{$fa-css-prefix}-flip-horizontal, 18 | :root .#{$fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('@{fa-font-path}/fontawesome-webfont.eot?v=@{fa-version}'); 7 | src: url('@{fa-font-path}/fontawesome-webfont.eot?#iefix&v=@{fa-version}') format('embedded-opentype'), 8 | url('@{fa-font-path}/fontawesome-webfont.woff2?v=@{fa-version}') format('woff2'), 9 | url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff'), 10 | url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype'), 11 | url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_path.scss: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); 7 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), 8 | url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), 9 | url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), 10 | url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), 11 | url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/blockchain/Test.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.blockchain; 2 | 3 | /** 4 | *

BlockChain

5 | *

LightDisk的测试类

6 | * 7 | * @author : TimVan 8 | * @date : 2020-04-21 10:41 9 | **/ 10 | public class Test { 11 | public static void main(String[] args) { 12 | // ECKey key = new ECKey(); 13 | // System.out.format("私钥 => %s\n", key.getPrivateKeyAsHex()); 14 | // System.out.format("公钥 => %s\n", key.getPublicKeyAsHex()); 15 | // System.out.format("地址 => %s\n", key.toString()); 16 | String str = "[sdfsfdgdf,胜多负少的]"; 17 | int index= str.indexOf(','); 18 | if(index > 0){ 19 | str = str.substring(1,index); 20 | } 21 | else{ 22 | str = str.substring(1,str.length()-1); 23 | } 24 | 25 | System.out.println("str = "+str); 26 | 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/animated.less: -------------------------------------------------------------------------------- 1 | // Animated Icons 2 | // -------------------------- 3 | 4 | .@{fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .@{fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_animated.scss: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .#{$fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .#{$fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/web/config/LightDiskHungrySingleton.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.web.config; 2 | 3 | import com.timvanx.gossip.model.NodeURI; 4 | import com.timvanx.lightdisk.LightDisk; 5 | import lombok.Getter; 6 | 7 | /** 8 | *

BlockChain

9 | *

LaughDisk实例的饿汉式单例模式

10 | * 11 | * @author : TimVan 12 | * @date : 2020-05-02 08:05 13 | **/ 14 | public class LightDiskHungrySingleton { 15 | private static final LightDiskHungrySingleton LAUGH_DISK_SINGLETON = new LightDiskHungrySingleton(); 16 | @Getter 17 | private static LightDisk lightDisk; 18 | 19 | private LightDiskHungrySingleton() { 20 | } 21 | 22 | public static void initial(NodeURI uri,NodeURI seedNode, String publicKey,String privateKey){ 23 | lightDisk = new LightDisk(uri, seedNode); 24 | 25 | } 26 | 27 | public static LightDiskHungrySingleton getInstance() { 28 | return LAUGH_DISK_SINGLETON; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/web/config/MyWebMvcConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.web.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | *

BlockChain

9 | *

10 | * 11 | * @author : TimVan 12 | * @date : 2020-05-16 21:37 13 | **/ 14 | @Configuration 15 | public class MyWebMvcConfigurer implements WebMvcConfigurer { 16 | 17 | 18 | @Override 19 | public void addInterceptors(InterceptorRegistry registry) { 20 | registry.addInterceptor(new LoginHandlerInterceptor()) 21 | .addPathPatterns("/**") 22 | .excludePathPatterns("/login", "/registry","/page/login-1.html","/page/newwallet.html","/getLocalIP") 23 | .excludePathPatterns("/assets/**","/lib/**","/js/**" 24 | ,"/css/**","/images/**","/api/**"); 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/Message.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | public class Message extends Base { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /README.en.md: -------------------------------------------------------------------------------- 1 | # BlockChain 2 | 3 | #### Description 4 | The Times 03/Jan/2009 Chancellor on brink of second bailout for banks. 5 | 6 | #### Software Architecture 7 | Software architecture description 8 | 9 | #### Installation 10 | 11 | 1. xxxx 12 | 2. xxxx 13 | 3. xxxx 14 | 15 | #### Instructions 16 | 17 | 1. xxxx 18 | 2. xxxx 19 | 3. xxxx 20 | 21 | #### Contribution 22 | 23 | 1. Fork the repository 24 | 2. Create Feat_xxx branch 25 | 3. Commit your code 26 | 4. Create Pull Request 27 | 28 | 29 | #### Gitee Feature 30 | 31 | 1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md 32 | 2. Gitee blog [blog.gitee.com](https://blog.gitee.com) 33 | 3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) 34 | 4. The most valuable open source project [GVP](https://gitee.com/gvp) 35 | 5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) 36 | 6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | public abstract class Response extends Base { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/static/api/tableSelect.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 0, 3 | "msg": "", 4 | "count": 16, 5 | "data": [ 6 | { "id":"001", "username":"张玉林", "sex":"女" }, 7 | { "id":"002", "username":"刘晓军", "sex":"男" }, 8 | { "id":"003", "username":"张恒", "sex":"男" }, 9 | { "id":"004", "username":"朱一", "sex":"男" }, 10 | { "id":"005", "username":"刘佳能", "sex":"女" }, 11 | { "id":"006", "username":"晓梅", "sex":"女" }, 12 | { "id":"007", "username":"马冬梅", "sex":"女" }, 13 | { "id":"008", "username":"刘晓庆", "sex":"女" }, 14 | { "id":"009", "username":"刘晓庆", "sex":"女" }, 15 | { "id":"010", "username":"刘晓庆", "sex":"女" }, 16 | { "id":"011", "username":"刘晓庆", "sex":"女" }, 17 | { "id":"012", "username":"刘晓庆", "sex":"女" }, 18 | { "id":"013", "username":"刘晓庆", "sex":"女" }, 19 | { "id":"014", "username":"刘晓庆", "sex":"女" }, 20 | { "id":"015", "username":"刘晓庆", "sex":"女" }, 21 | { "id":"016", "username":"刘晓庆", "sex":"女" } 22 | ] 23 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/ActiveGossipOk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | public class ActiveGossipOk extends Response { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/static/js/common.js: -------------------------------------------------------------------------------- 1 | //退出登录 2 | function logout() { 3 | layui.data('block', null); //删除test表 4 | layui.data('cache', null); //删除test表 5 | //加载层-风格2 6 | layer.load(1); 7 | //请求完关闭 8 | $.ajax({ 9 | type: "post", 10 | url: "/shutdown", 11 | data: { 12 | }, 13 | success: function (ret) { 14 | 15 | layer.closeAll('loading'); 16 | 17 | ret = eval("(" + ret + ")"); 18 | if (ret['code'] === 0) { 19 | layer.msg("清除缓存和Gossip成功"); 20 | window.location.href="/"; 21 | } else { 22 | layer.msg(ret['msg'], { 23 | }); 24 | 25 | //延时2秒 26 | setTimeout(function (){ 27 | window.location.href="/"; 28 | }, 1500); 29 | } 30 | 31 | }, 32 | error: function () { 33 | layer.closeAll('loading'); 34 | layer.msg("请求注销失败"); 35 | } 36 | }); 37 | 38 | 39 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/Clock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager; 19 | 20 | public interface Clock { 21 | 22 | long currentTimeMillis(); 23 | long nanoTime(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} -------------------------------------------------------------------------------- /src/main/java/com/timvanx/gossip/impl/ImplCrdtOperator.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.gossip.impl; 2 | 3 | /** 4 | *

BlockChain

5 | *

Crdt数据类型-增删改查-接口

6 | * 7 | * @author : TimVan 8 | * @date : 2020-4-1 16:08:01 9 | **/ 10 | public interface ImplCrdtOperator { 11 | /** 向对应主键命名空间,添加值 12 | * @param val 待添加值 13 | * @param key 对应命名空间名称 14 | * @return 是否添加成功 15 | * */ 16 | boolean push(String val , String key); 17 | 18 | /** 向对应主键命名空间,删除值 19 | * @param val 待添加值 20 | * @param key 对应命名空间名称 21 | * @return 是否删除成功 22 | * */ 23 | boolean remove(String val , String key); 24 | 25 | /** 向对应主键命名空间,获取值 26 | * @param key 对应命名空间名称 27 | * @return 返回对应值 28 | * */ 29 | String get(String key); 30 | 31 | /** 向对应累加器,添加数字, acc = accumulator(累加器) 32 | * @param val 待添加值 33 | * @param key 对应命名空间名称 34 | * @return 是否添加成功 35 | * * */ 36 | boolean accAdd(String val , String key); 37 | 38 | /** 向对应累加器,获取值 39 | * @param key 对应命名空间名称 40 | * @return 获取的值 * */ 41 | String accGet(String key); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/crdt/CrdtCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.crdt; 19 | 20 | public interface CrdtCounter> 21 | extends Crdt { 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/event/GossipListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.event; 19 | 20 | import org.apache.com.timvanx.gossip.Member; 21 | 22 | public interface GossipListener { 23 | void gossipEvent(Member member, GossipState state); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/crdt/CrdtSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.crdt; 19 | 20 | import java.util.Set; 21 | 22 | public interface CrdtSet, R extends CrdtSet> 23 | extends Crdt { 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/udp/Trackable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.udp; 19 | 20 | public interface Trackable { 21 | 22 | String getUriFrom(); 23 | 24 | void setUriFrom(String uriFrom); 25 | 26 | String getUuid(); 27 | 28 | void setUuid(String uuid); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/static/js/lay-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * date:2019/08/16 3 | * author:Mr.Chung 4 | * description:此处放layui自定义扩展 5 | * version:2.0.4 6 | */ 7 | 8 | window.rootPath = (function (src) { 9 | src = document.scripts[document.scripts.length - 1].src; 10 | return src.substring(0, src.lastIndexOf("/") + 1); 11 | })(); 12 | 13 | layui.config({ 14 | base: rootPath + "lay-module/", 15 | version: true 16 | }).extend({ 17 | miniAdmin: "layuimini/miniAdmin", // layuimini后台扩展 18 | miniMenu: "layuimini/miniMenu", // layuimini菜单扩展 19 | miniTab: "layuimini/miniTab", // layuimini tab扩展 20 | miniTheme: "layuimini/miniTheme", // layuimini 主题扩展 21 | miniTongji: "layuimini/miniTongji", // layuimini 统计扩展 22 | step: 'step-lay/step', // 分步表单扩展 23 | treetable: 'treetable-lay/treetable', //table树形扩展 24 | tableSelect: 'tableSelect/tableSelect', // table选择扩展 25 | iconPickerFa: 'iconPicker/iconPickerFa', // fa图标选择扩展 26 | echarts: 'echarts/echarts', // echarts图表扩展 27 | echartsTheme: 'echarts/echartsTheme', // echarts图表主题扩展 28 | wangEditor: 'wangEditor/wangEditor', // wangEditor富文本扩展 29 | layarea: 'layarea/layarea', // 省市县区三级联动下拉选择器 30 | }); 31 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/NotAMemberFault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | public class NotAMemberFault extends Fault { 21 | 22 | public NotAMemberFault(){ 23 | 24 | } 25 | 26 | public NotAMemberFault(String message){ 27 | this.setException(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/event/GossipState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.event; 19 | 20 | public enum GossipState { 21 | UP("up"), DOWN("down"); 22 | @SuppressWarnings("unused") 23 | private final String state; 24 | 25 | private GossipState(String state) { 26 | this.state = state; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/PassiveGossipConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager; 19 | 20 | public interface PassiveGossipConstants { 21 | String SIGNED_MESSAGE = "com.timvanx.gossip.passive.signed_message"; 22 | String UNSIGNED_MESSAGE = "com.timvanx.gossip.passive.unsigned_message"; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
  1. '+o.replace(/[\r\t\n]+/g,"
  2. ")+"
"),c.find(">.layui-code-h3")[0]||c.prepend('

'+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/SystemClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager; 19 | 20 | public class SystemClock implements Clock { 21 | 22 | @Override 23 | public long currentTimeMillis() { 24 | return System.currentTimeMillis(); 25 | } 26 | 27 | @Override 28 | public long nanoTime() { 29 | return System.nanoTime(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/static/js/lay-module/layuimini/miniTongji.js: -------------------------------------------------------------------------------- 1 | /** 2 | * date:2020/03/01 3 | * author:Mr.Chung 4 | * version:2.0 5 | * description:layuimini 统计框架扩展 6 | */ 7 | layui.define(["jquery"], function (exports) { 8 | var $ = layui.$; 9 | 10 | var miniTongji = { 11 | 12 | /** 13 | * 初始化 14 | * @param options 15 | */ 16 | render: function (options) { 17 | options.specific = options.specific || false; 18 | options.domains = options.domains || []; 19 | var domain = window.location.hostname; 20 | if (options.specific === false || (options.specific === true && options.domains.indexOf(domain) >=0)) { 21 | miniTongji.listen(); 22 | } 23 | }, 24 | 25 | /** 26 | * 监听统计代码 27 | */ 28 | listen: function () { 29 | var _hmt = _hmt || []; 30 | (function () { 31 | var hm = document.createElement("script"); 32 | hm.src = "https://hm.baidu.com/hm.js?d97abf6d61c21d773f97835defbdef4e"; 33 | var s = document.getElementsByTagName("script")[0]; 34 | s.parentNode.insertBefore(hm, s); 35 | })(); 36 | } 37 | }; 38 | 39 | exports("miniTongji", miniTongji); 40 | }); -------------------------------------------------------------------------------- /src/main/java/com/timvanx/web/service/TransactionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.web.service; 2 | 3 | import com.timvanx.web.dao.TransactionDAO; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | *

BlockChain

11 | *

交易列表服务层

12 | * 13 | * @author : TimVan 14 | * @date : 2020-05-03 12:09 15 | **/ 16 | @Service 17 | public class TransactionServiceImpl { 18 | 19 | /**构造器注入*/ 20 | final TransactionDAO transactionDAO; 21 | 22 | @Autowired 23 | public TransactionServiceImpl(TransactionDAO transactionDAO) { 24 | this.transactionDAO = transactionDAO; 25 | } 26 | 27 | /** 28 | * 获取分页的本地交易列表 29 | * @param page 当前页 30 | * @param limit 每页显示的条数 31 | */ 32 | public Map selectTransaction(int page, int limit){ 33 | 34 | return transactionDAO.selectTransaction(page,limit); 35 | } 36 | 37 | 38 | /** 39 | * 通过公钥,获取分页的本地交易列表 40 | * @param publicKey 公钥 41 | * @param page 当前页 42 | * @param limit 每页显示的条数 43 | */ 44 | public Map selectTransaction(String publicKey,int page, int limit){ 45 | 46 | return transactionDAO.selectTransaction(publicKey,page,limit); 47 | } 48 | 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/Fault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | public abstract class Fault extends Response { 21 | 22 | private String exception; 23 | 24 | public Fault(){} 25 | 26 | public String getException() { 27 | return exception; 28 | } 29 | 30 | public void setException(String exception) { 31 | this.exception = exception; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "Fault [exception=" + exception + "]"; 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/SignedPayload.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | public class SignedPayload extends Base { 21 | private byte [] data; 22 | private byte [] signature; 23 | public byte[] getData() { 24 | return data; 25 | } 26 | public void setData(byte[] data) { 27 | this.data = data; 28 | } 29 | public byte[] getSignature() { 30 | return signature; 31 | } 32 | public void setSignature(byte[] signature) { 33 | this.signature = signature; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/ActiveGossipMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | public class ActiveGossipMessage extends Base { 24 | 25 | private List members = new ArrayList<>(); 26 | 27 | public ActiveGossipMessage(){ 28 | 29 | } 30 | 31 | public List getMembers() { 32 | return members; 33 | } 34 | 35 | public void setMembers(List members) { 36 | this.members = members; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/crdt/CrdtAddRemoveSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.crdt; 19 | 20 | import java.util.Set; 21 | 22 | // Interface extends CrdtSet interface with add and remove operation that are guaranteed to be immutable. 23 | // If your implementation provide immutable add/remove operations you can extend AbstractCRDTStringSetTest to check it in the most ways. 24 | 25 | public interface CrdtAddRemoveSet, R extends CrdtAddRemoveSet> extends CrdtSet { 26 | R add(T element); 27 | 28 | R remove(T element); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/handlers/MessageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager.handlers; 19 | 20 | import org.apache.com.timvanx.gossip.manager.GossipCore; 21 | import org.apache.com.timvanx.gossip.manager.GossipManager; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | 24 | public interface MessageHandler { 25 | /** 26 | * @param gossipCore context. 27 | * @param gossipManager context. 28 | * @param base message reference. 29 | * @return boolean indicating success. 30 | */ 31 | boolean invoke(GossipCore gossipCore, GossipManager gossipManager, Base base); 32 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/lock/vote/VoteSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.lock.vote; 19 | 20 | import java.util.Set; 21 | 22 | /** 23 | * This interface defines vote selection algorithm for the vote based locking. 24 | */ 25 | public interface VoteSelector { 26 | /** 27 | * This method get call by the lock manager of a node to decide which candidate need to be choose for voting. 28 | * 29 | * @param voteCandidateIds node id set for the vote candidates 30 | * @return selected node id to vote from the given vote candidate set. 31 | */ 32 | String getVoteCandidateId(Set voteCandidateIds); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/lock/vote/RandomVoteSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.lock.vote; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | import java.util.Random; 23 | import java.util.Set; 24 | 25 | /** 26 | * VoteSelector implementation which randomly select a voting node. 27 | */ 28 | public class RandomVoteSelector implements VoteSelector { 29 | 30 | @Override 31 | public String getVoteCandidateId(Set voteCandidateIds) { 32 | List voteCandidatesIds = new ArrayList<>(voteCandidateIds); 33 | return voteCandidatesIds.get(new Random().nextInt(voteCandidatesIds.size())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/udp/UdpActiveGossipOk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.udp; 19 | 20 | import org.apache.com.timvanx.gossip.model.ActiveGossipOk; 21 | 22 | public class UdpActiveGossipOk extends ActiveGossipOk implements Trackable { 23 | 24 | 25 | private String uriFrom; 26 | private String uuid; 27 | 28 | public String getUriFrom() { 29 | return uriFrom; 30 | } 31 | 32 | public void setUriFrom(String uriFrom) { 33 | this.uriFrom = uriFrom; 34 | } 35 | 36 | public String getUuid() { 37 | return uuid; 38 | } 39 | 40 | public void setUuid(String uuid) { 41 | this.uuid = uuid; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/web/service/BlockServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.web.service; 2 | 3 | import com.timvanx.blockchain.model.Block; 4 | import com.timvanx.web.dao.BlockDAO; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Collections; 9 | import java.util.List; 10 | 11 | /** 12 | *

BlockChain

13 | *

区块服务层

14 | * 15 | * @author : TimVan 16 | * @date : 2020-05-03 12:09 17 | **/ 18 | @Service 19 | public class BlockServiceImpl { 20 | 21 | /**构造器注入*/ 22 | final BlockDAO blockDAO; 23 | 24 | @Autowired 25 | public BlockServiceImpl(BlockDAO blockDAO) { 26 | this.blockDAO = blockDAO; 27 | } 28 | 29 | /** 30 | * 获取所有的本地区块 31 | * 并处理为倒序 32 | */ 33 | public List selectLocalBlock(){ 34 | List blockList = blockDAO.selectLocalBlock(); 35 | // 倒序排列 36 | // Collections.reverse(blockList); 37 | return blockList; 38 | } 39 | 40 | 41 | /** 42 | * 获取分页的本地区块 43 | * @param page 当前页 44 | * @param limit 每页显示的条数 45 | */ 46 | public List selectLocalBlock(int page,int limit){ 47 | List blockList = blockDAO.selectLocalBlock(page,limit); 48 | // // 倒序排列 49 | // Collections.reverse(blockList); 50 | return blockList; 51 | } 52 | 53 | /** 54 | * 获得区块链的长度 55 | */ 56 | public int getBlockListSize(){ 57 | return blockDAO.getBlockListSize(); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/replication/NotReplicable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.replication; 19 | 20 | import org.apache.com.timvanx.gossip.LocalMember; 21 | import org.apache.com.timvanx.gossip.model.Base; 22 | 23 | /** 24 | * Replicable implementation which never replicates data on any node 25 | * 26 | * @param A subtype of the class {@link org.apache.com.timvanx.gossip.model.Base} which uses this interface 27 | * @see Replicable 28 | */ 29 | public class NotReplicable implements Replicable { 30 | 31 | @Override 32 | public boolean shouldReplicate(LocalMember me, LocalMember destination, T message) { 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/crdt/Crdt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.crdt; 19 | /** 20 | * 21 | * Immutable type 22 | * 23 | * @param 24 | * @param 25 | */ 26 | public interface Crdt> { 27 | 28 | 29 | MergeReturnType merge(MergeReturnType other); 30 | SetType value(); 31 | /** 32 | * Called to self optimize. Some CRDTs may use some mechanism to clean up be 33 | * removing obsolete data outside the scope of merging. IE this could clean up 34 | * temporal values, old copies etc. 35 | * @return the Crdt structure optimized 36 | */ 37 | MergeReturnType optimize(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/udp/UdpNotAMemberFault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.udp; 19 | 20 | import org.apache.com.timvanx.gossip.model.NotAMemberFault; 21 | 22 | public class UdpNotAMemberFault extends NotAMemberFault implements Trackable { 23 | 24 | public UdpNotAMemberFault(){ 25 | 26 | } 27 | private String uriFrom; 28 | private String uuid; 29 | 30 | public String getUriFrom() { 31 | return uriFrom; 32 | } 33 | 34 | public void setUriFrom(String uriFrom) { 35 | this.uriFrom = uriFrom; 36 | } 37 | 38 | public String getUuid() { 39 | return uuid; 40 | } 41 | 42 | public void setUuid(String uuid) { 43 | this.uuid = uuid; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/event/data/UpdateSharedDataEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.event.data; 19 | 20 | /** 21 | * Event handler interface for shared data items. 22 | * Classes which implement this interface get notifications when shared data get changed. 23 | */ 24 | public interface UpdateSharedDataEventHandler { 25 | /** 26 | * This method get called when shared data get changed. 27 | * 28 | * @param key key of the shared data item 29 | * @param oldValue previous value or null if the data is discovered for the first time 30 | * @param newValue updated value of the data item 31 | */ 32 | void onUpdate(String key, Object oldValue, Object newValue); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/protocol/ProtocolManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.protocol; 19 | 20 | import org.apache.com.timvanx.gossip.model.Base; 21 | 22 | import java.io.IOException; 23 | 24 | /** interface for managing message marshaling. */ 25 | public interface ProtocolManager { 26 | 27 | /** serialize a message 28 | * @param message 29 | * @return serialized message. 30 | * @throws IOException 31 | */ 32 | byte[] write(Base message) throws IOException; 33 | 34 | /** 35 | * Reads the next message from a byte source. 36 | * @param buf 37 | * @return a com.timvanx.gossip message. 38 | * @throws IOException 39 | */ 40 | Base read(byte[] buf) throws IOException; 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/PerNodeDataBulkMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | import java.util.stream.Collectors; 23 | 24 | public class PerNodeDataBulkMessage extends Base { 25 | private List messages = new ArrayList<>(); 26 | 27 | public void addMessage(PerNodeDataMessage msg) { 28 | messages.add(msg); 29 | } 30 | 31 | public List getMessages() { 32 | return messages; 33 | } 34 | 35 | @Override public String toString() { 36 | return "GossipDataBulkMessage[" + messages.stream().map(Object::toString) 37 | .collect(Collectors.joining(",")) + "]"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/SharedDataBulkMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | import java.util.stream.Collectors; 23 | 24 | public class SharedDataBulkMessage extends Base { 25 | private List messages = new ArrayList<>(); 26 | 27 | public void addMessage(SharedDataMessage msg) { 28 | messages.add(msg); 29 | } 30 | 31 | public List getMessages() { 32 | return messages; 33 | } 34 | 35 | @Override public String toString() { 36 | return "SharedGossipDataBulkMessage[" + messages.stream().map(Object::toString) 37 | .collect(Collectors.joining(",")) + "]"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/replication/AllReplicable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.replication; 19 | 20 | import org.apache.com.timvanx.gossip.LocalMember; 21 | import org.apache.com.timvanx.gossip.model.Base; 22 | 23 | /** 24 | * Replicable implementation which replicates data to any node. This is the default replication 25 | * strategy if a data item not specified its replication behaviour. 26 | * 27 | * @param A subtype of the class {@link org.apache.com.timvanx.gossip.model.Base} which uses this interface 28 | * @see Replicable 29 | */ 30 | public class AllReplicable implements Replicable { 31 | 32 | @Override 33 | public boolean shouldReplicate(LocalMember me, LocalMember destination, T message) { 34 | return true; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/resources/static/css/public.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 15px 15px 15px 15px; 3 | background: #f2f2f2; 4 | } 5 | 6 | .layuimini-container { 7 | border: 1px solid #f2f2f2; 8 | border-radius: 5px; 9 | background-color: #ffffff 10 | } 11 | 12 | .layuimini-main { 13 | margin: 10px 10px 10px 10px; 14 | } 15 | 16 | /**必填红点 */ 17 | .layuimini-form > .layui-form-item > .required:after { 18 | content: '*'; 19 | color: red; 20 | position: absolute; 21 | margin-left: 4px; 22 | font-weight: bold; 23 | line-height: 1.8em; 24 | top: 6px; 25 | right: 5px; 26 | } 27 | 28 | .layuimini-form > .layui-form-item > .layui-form-label { 29 | width: 120px !important; 30 | } 31 | 32 | .layuimini-form > .layui-form-item > .layui-input-block { 33 | margin-left: 150px !important; 34 | } 35 | 36 | .layuimini-form > .layui-form-item > .layui-input-block > tip { 37 | display: inline-block; 38 | margin-top: 10px; 39 | line-height: 10px; 40 | font-size: 10px; 41 | color: #a29c9c; 42 | } 43 | 44 | /**搜索框*/ 45 | .layuimini-container .table-search-fieldset { 46 | margin: 0; 47 | border: 1px solid #e6e6e6; 48 | padding: 10px 20px 5px 20px; 49 | color: #6b6b6b; 50 | } 51 | 52 | /**自定义滚动条样式 */ 53 | ::-webkit-scrollbar { 54 | width: 6px; 55 | height: 6px 56 | } 57 | 58 | ::-webkit-scrollbar-track { 59 | background-color: transparent; 60 | -webkit-border-radius: 2em; 61 | -moz-border-radius: 2em; 62 | border-radius: 2em; 63 | } 64 | 65 | ::-webkit-scrollbar-thumb { 66 | background-color: #9c9da0; 67 | -webkit-border-radius: 2em; 68 | -moz-border-radius: 2em; 69 | border-radius: 2em 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/GossipCoreConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager; 19 | 20 | public interface GossipCoreConstants { 21 | String PER_NODE_DATA_SIZE = "com.timvanx.gossip.core.pernodedata.size"; 22 | String SHARED_DATA_SIZE = "com.timvanx.gossip.core.shareddata.size"; 23 | String REQUEST_SIZE = "com.timvanx.gossip.core.requests.size"; 24 | String THREADPOOL_ACTIVE = "com.timvanx.gossip.core.threadpool.active"; 25 | String THREADPOOL_SIZE = "com.timvanx.gossip.core.threadpool.size"; 26 | String MESSAGE_SERDE_EXCEPTION = "com.timvanx.gossip.core.message_serde_exception"; 27 | String MESSAGE_TRANSMISSION_EXCEPTION = "com.timvanx.gossip.core.message_transmission_exception"; 28 | String MESSAGE_TRANSMISSION_SUCCESS = "com.timvanx.gossip.core.message_transmission_success"; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/static/js/lay-module/step-lay/step.css: -------------------------------------------------------------------------------- 1 | .lay-step { 2 | font-size: 0; 3 | width: 400px; 4 | margin: 0 auto; 5 | max-width: 100%; 6 | padding-left: 200px; 7 | } 8 | 9 | .step-item { 10 | display: inline-block; 11 | line-height: 26px; 12 | position: relative; 13 | font-size: 14px; 14 | } 15 | 16 | .step-item-tail { 17 | width: 100%; 18 | padding: 0 10px; 19 | position: absolute; 20 | left: 0; 21 | top: 13px; 22 | } 23 | 24 | .step-item-tail i { 25 | display: inline-block; 26 | width: 100%; 27 | height: 1px; 28 | vertical-align: top; 29 | background: #c2c2c2; 30 | position: relative; 31 | } 32 | 33 | .step-item-tail .step-item-tail-done { 34 | background: #009688; 35 | } 36 | 37 | .step-item-head { 38 | position: relative; 39 | display: inline-block; 40 | height: 26px; 41 | width: 26px; 42 | text-align: center; 43 | vertical-align: top; 44 | color: #009688; 45 | border: 1px solid #009688; 46 | border-radius: 50%; 47 | background: #ffffff; 48 | } 49 | 50 | .step-item-head.step-item-head-active { 51 | background: #009688; 52 | color: #ffffff; 53 | } 54 | 55 | .step-item-main { 56 | display: block; 57 | position: relative; 58 | margin-left: -50%; 59 | margin-right: 50%; 60 | padding-left: 26px; 61 | text-align: center; 62 | } 63 | 64 | .step-item-main-title { 65 | font-weight: bolder; 66 | color: #555555; 67 | } 68 | 69 | .step-item-main-desc { 70 | color: #aaaaaa; 71 | } 72 | 73 | .lay-step + [carousel-item]:before { 74 | display: none; 75 | } 76 | 77 | .lay-step + [carousel-item] > * { 78 | background-color: transparent; 79 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/event/data/UpdateNodeDataEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.event.data; 19 | 20 | /** 21 | * Event handler interface for the per node data items. 22 | * Classes which implement this interface get notifications when per node data item get changed. 23 | */ 24 | public interface UpdateNodeDataEventHandler { 25 | 26 | /** 27 | * This method get called when a per node datum get changed. 28 | * 29 | * @param nodeId id of the node that change the value 30 | * @param key key of the datum 31 | * @param oldValue previous value of the datum or null if the datum is discovered 32 | * for the first time 33 | * @param newValue updated value of the datum 34 | */ 35 | void onUpdate(String nodeId, String key, Object oldValue, Object newValue); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LightDisk 2 | The Times 03/Jan/2009 Chancellor on brink of second bailout for banks. 3 | 4 | #### 介绍 5 | 一个基于区块链的存储系统,可以在多个节点(设备)中,为用户生成非对称加密的公私钥对,并使用此密钥对,对数据进行加密上传,和解密下载。 6 | 7 | #### Bug列表 8 | 1、局域网内外互联,未实现NAT穿透连接 9 | 2、局域网内有一定几率存活节点被发现死亡 10 | 3、仅支持Coinbase交易(普通交易开发中) 11 | 12 | #### 软件架构 13 | JDK 1.8+ 14 | Spring Boot 2.0.1 15 | [Apache Gossip](https://gitee.com/TimVanX/incubator-retired-gossip) 16 | 17 | #### 安装教程 18 | 1、命令行界面:配置JDK或JRE本地环境变量(版本号1.8+),解压并打开运行“open.bat”。 19 | 2、Web本地操作台:暂无war包,需要使用Git导入此项目到 IntelliJ IDEA ,运行com.timvanx.Application入口,启动Spring Boot项目,默认入口地址为http://localhost:8080/。 20 | 21 | #### 使用说明 22 | ##### 命令行界面 23 | 1. 若无种子节点,可以运行“作为种子节点登入”,将本机作为种子节点。 24 | 2. 若存在种子节点,可以选择“作为普通节点登入”,并输入种子节点的IP地址与端口号。 25 | ![命令行界面](https://images.gitee.com/uploads/images/2020/0528/114044_075ad114_1464254.jpeg "控制台.jpg") 26 | ##### Web本地操作台 27 | 基本功能同上 28 | ![登录](https://images.gitee.com/uploads/images/2020/0528/114151_cbbfbde0_1464254.jpeg "登录.jpg") 29 | ![主页](https://images.gitee.com/uploads/images/2020/0528/114205_bcc49299_1464254.jpeg "主页.jpg") 30 | ![挖矿(上传文件)](https://images.gitee.com/uploads/images/2020/0528/114220_54149cad_1464254.jpeg "挖矿.jpg") 31 | ![新区块信息](https://images.gitee.com/uploads/images/2020/0528/114240_7357a944_1464254.jpeg "新区块界面.jpg") 32 | 33 | #### 结构与框架 34 | 1、流程图 35 | ![输入图片说明](https://images.gitee.com/uploads/images/2020/0528/121839_565cfe2a_1464254.jpeg "流程图‘.jpg") 36 | 2、区块链结构图,类似于比特币的数据结构,文件作为每组Merkle树的叶子节点数据的来源 37 | ![输入图片说明](https://images.gitee.com/uploads/images/2020/0528/121855_5fd1e006_1464254.jpeg "区块链结构图.jpg") 38 | 3、技术框架 39 | ![输入图片说明](https://images.gitee.com/uploads/images/2020/0528/121904_40af6539_1464254.jpeg "技术框架.jpg") 40 | 41 | #### 参与贡献 42 | 1、TimVan 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/lock/exceptions/VoteFailedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.lock.exceptions; 19 | 20 | /** 21 | * This exception is thrown when the lock based voting is failed. 22 | */ 23 | public class VoteFailedException extends Exception { 24 | /** 25 | * Constructs a new VoteFailedException with the specified detail message. 26 | * 27 | * @param message the detail message. 28 | */ 29 | public VoteFailedException(String message) { 30 | super(message); 31 | } 32 | 33 | /** 34 | * Constructs a new VoteFailedException with the specified detail message and 35 | * cause. 36 | * 37 | * @param message the detail message 38 | * @param cause the cause for this exception 39 | */ 40 | public VoteFailedException(String message, Throwable cause) { 41 | super(message, cause); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/model/ResponseJson.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.model; 2 | 3 | /** 4 | *

BlockChain

5 | *

接口返回值response统一标准格式

6 | * 7 | * @author : TimVan 8 | * @date : 2020-04-01 17:49 9 | **/ 10 | public class ResponseJson { 11 | /** SUCCESSFUL_CODE = 请求成功 12 | * FAIL_CODE = 默认请求失败 13 | * */ 14 | private final static int SUCCESSFUL_CODE = 0; 15 | private final static int FAIL_CODE = 1; 16 | 17 | 18 | /** 19 | * code = 状态码 20 | * */ 21 | private int code; 22 | private String msg; 23 | private String data; 24 | 25 | public ResponseJson(int code, String msg, String data) { 26 | this.code = code; 27 | this.msg = msg; 28 | this.data = data; 29 | } 30 | 31 | public ResponseJson() { 32 | this.code = FAIL_CODE; 33 | this.msg = ""; 34 | this.data = null; 35 | } 36 | 37 | public int getCode() { 38 | return code; 39 | } 40 | 41 | public void setCodeSuccessful() { 42 | this.code = SUCCESSFUL_CODE; 43 | } 44 | 45 | public void setCodeFailed() { 46 | this.code = FAIL_CODE; 47 | } 48 | 49 | public String getMsg() { 50 | return msg; 51 | } 52 | 53 | public void setMsg(String msg) { 54 | this.msg = msg; 55 | } 56 | 57 | public String getData() { 58 | return data; 59 | } 60 | 61 | public void setData(String data) { 62 | this.data = data; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return "ResponseJson{" + 68 | "code=" + code + 69 | ", msg='" + msg + '\'' + 70 | ", data=" + data + 71 | '}'; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/udp/UdpActiveGossipMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.udp; 19 | 20 | import org.apache.com.timvanx.gossip.model.ActiveGossipMessage; 21 | 22 | public class UdpActiveGossipMessage extends ActiveGossipMessage implements Trackable { 23 | 24 | private String uriFrom; 25 | private String uuid; 26 | 27 | public String getUriFrom() { 28 | return uriFrom; 29 | } 30 | 31 | public void setUriFrom(String uriFrom) { 32 | this.uriFrom = uriFrom; 33 | } 34 | 35 | public String getUuid() { 36 | return uuid; 37 | } 38 | 39 | public void setUuid(String uuid) { 40 | this.uuid = uuid; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "UdpActiveGossipMessage [uriFrom=" + uriFrom + ", uuid=" + uuid + ", getMembers()=" 46 | + getMembers() + "]"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/udp/UdpPerNodeDataMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.udp; 19 | 20 | import org.apache.com.timvanx.gossip.model.PerNodeDataMessage; 21 | 22 | public class UdpPerNodeDataMessage extends PerNodeDataMessage implements Trackable { 23 | 24 | private String uriFrom; 25 | private String uuid; 26 | 27 | public String getUriFrom() { 28 | return uriFrom; 29 | } 30 | 31 | public void setUriFrom(String uriFrom) { 32 | this.uriFrom = uriFrom; 33 | } 34 | 35 | public String getUuid() { 36 | return uuid; 37 | } 38 | 39 | public void setUuid(String uuid) { 40 | this.uuid = uuid; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "UdpGossipDataMessage [uriFrom=" + uriFrom + ", uuid=" + uuid 46 | + ", getReplicable()=" + getReplicable() + "]"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/udp/UdpPerNodeDataBulkMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.udp; 19 | 20 | import org.apache.com.timvanx.gossip.model.PerNodeDataBulkMessage; 21 | 22 | public class UdpPerNodeDataBulkMessage extends PerNodeDataBulkMessage implements Trackable { 23 | 24 | private String uriFrom; 25 | private String uuid; 26 | 27 | public String getUriFrom() { 28 | return uriFrom; 29 | } 30 | 31 | public void setUriFrom(String uriFrom) { 32 | this.uriFrom = uriFrom; 33 | } 34 | 35 | public String getUuid() { 36 | return uuid; 37 | } 38 | 39 | public void setUuid(String uuid) { 40 | this.uuid = uuid; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "UdpGossipDataMessage [uriFrom=" + uriFrom + ", uuid=" + uuid 46 | + ", messages=[" + super.toString() + "] ]"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/handlers/SharedDataMessageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager.handlers; 19 | 20 | import org.apache.com.timvanx.gossip.manager.GossipCore; 21 | import org.apache.com.timvanx.gossip.manager.GossipManager; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | import org.apache.com.timvanx.gossip.udp.UdpSharedDataMessage; 24 | 25 | public class SharedDataMessageHandler implements MessageHandler{ 26 | 27 | /** 28 | * @param gossipCore context. 29 | * @param gossipManager context. 30 | * @param base message reference. 31 | * @return boolean indicating success. 32 | */ 33 | @Override 34 | public boolean invoke(GossipCore gossipCore, GossipManager gossipManager, Base base) { 35 | UdpSharedDataMessage message = (UdpSharedDataMessage) base; 36 | gossipCore.addSharedData(message); 37 | return true; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/handlers/PerNodeDataMessageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager.handlers; 19 | 20 | import org.apache.com.timvanx.gossip.manager.GossipCore; 21 | import org.apache.com.timvanx.gossip.manager.GossipManager; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | import org.apache.com.timvanx.gossip.udp.UdpPerNodeDataMessage; 24 | 25 | public class PerNodeDataMessageHandler implements MessageHandler { 26 | 27 | /** 28 | * @param gossipCore context. 29 | * @param gossipManager context. 30 | * @param base message reference. 31 | * @return boolean indicating success. 32 | */ 33 | @Override 34 | public boolean invoke(GossipCore gossipCore, GossipManager gossipManager, Base base) { 35 | UdpPerNodeDataMessage message = (UdpPerNodeDataMessage) base; 36 | gossipCore.addPerNodeData(message); 37 | return true; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/udp/UdpSharedDataBulkMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.udp; 19 | 20 | import org.apache.com.timvanx.gossip.model.SharedDataBulkMessage; 21 | 22 | public class UdpSharedDataBulkMessage extends SharedDataBulkMessage implements Trackable { 23 | 24 | private String uriFrom; 25 | private String uuid; 26 | 27 | public String getUriFrom() { 28 | return uriFrom; 29 | } 30 | 31 | public void setUriFrom(String uriFrom) { 32 | this.uriFrom = uriFrom; 33 | } 34 | 35 | public String getUuid() { 36 | return uuid; 37 | } 38 | 39 | public void setUuid(String uuid) { 40 | this.uuid = uuid; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "UdpSharedGossipDataMessage [uriFrom=" + uriFrom + ", uuid=" + uuid + ", getNodeId()=" 46 | + ", messages=[" + super.toString() + "] ]"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/ShutdownMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | public class ShutdownMessage extends Message { 21 | 22 | public static final String PER_NODE_KEY = "gossipcore.shutdowmessage"; 23 | private long shutdownAtNanos; 24 | private String nodeId; 25 | 26 | public ShutdownMessage(){ 27 | 28 | } 29 | 30 | public String getNodeId() { 31 | return nodeId; 32 | } 33 | 34 | public void setNodeId(String nodeId) { 35 | this.nodeId = nodeId; 36 | } 37 | 38 | public long getShutdownAtNanos() { 39 | return shutdownAtNanos; 40 | } 41 | 42 | public void setShutdownAtNanos(long shutdownAtNanos) { 43 | this.shutdownAtNanos = shutdownAtNanos; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "ShutdownMessage [shutdownAtNanos=" + shutdownAtNanos + ", nodeId=" + nodeId + "]"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/RemoteMember.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip; 19 | 20 | import java.net.URI; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | /** 25 | * The object represents a com.timvanx.gossip member with the properties as received from a remote com.timvanx.gossip 26 | * member. 27 | * 28 | */ 29 | public class RemoteMember extends Member { 30 | 31 | /** 32 | * Constructor. 33 | * 34 | * @param uri 35 | * A URI object containing IP/hostname and port 36 | * @param heartbeat 37 | * The current heartbeat 38 | */ 39 | public RemoteMember(String clusterName, URI uri, String id, long heartbeat, Map properties) { 40 | super(clusterName, uri, id, heartbeat, properties); 41 | } 42 | 43 | public RemoteMember(String clusterName, URI uri, String id) { 44 | super(clusterName, uri, id, System.nanoTime(), new HashMap()); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/handlers/ResponseHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager.handlers; 19 | 20 | import org.apache.com.timvanx.gossip.manager.GossipCore; 21 | import org.apache.com.timvanx.gossip.manager.GossipManager; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | import org.apache.com.timvanx.gossip.udp.Trackable; 24 | 25 | public class ResponseHandler implements MessageHandler { 26 | 27 | /** 28 | * @param gossipCore context. 29 | * @param gossipManager context. 30 | * @param base message reference. 31 | * @return boolean indicating success. 32 | */ 33 | @Override 34 | public boolean invoke(GossipCore gossipCore, GossipManager gossipManager, Base base) { 35 | if (base instanceof Trackable) { 36 | Trackable t = (Trackable) base; 37 | gossipCore.handleResponse(t.getUuid() + "/" + t.getUriFrom(), (Base) t); 38 | return true; 39 | } 40 | return false; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/transport/TransportManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.transport; 19 | 20 | import java.io.IOException; 21 | import java.net.URI; 22 | 23 | /** interface for manager that sends and receives messages that have already been serialized. */ 24 | public interface TransportManager { 25 | 26 | /** starts the active com.timvanx.gossip thread responsible for reaching out to remote nodes. Not related to `startEndpoint()` */ 27 | void startActiveGossiper(); 28 | 29 | /** starts the passive com.timvanx.gossip thread that receives messages from remote nodes. Not related to `startActiveGossiper()` */ 30 | void startEndpoint(); 31 | 32 | /** attempts to shutdown all threads. */ 33 | void shutdown(); 34 | 35 | /** sends a payload to an endpoint. */ 36 | void send(URI endpoint, byte[] buf) throws IOException; 37 | 38 | /** gets the next payload being sent to this node */ 39 | byte[] read() throws IOException; 40 | } 41 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/replication/Replicable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.replication; 19 | 20 | import org.apache.com.timvanx.gossip.LocalMember; 21 | import org.apache.com.timvanx.gossip.model.Base; 22 | 23 | /** 24 | * This interface is used to determine whether a data item needs to be replicated to 25 | * another com.timvanx.gossip member. 26 | * 27 | * @param A subtype of the class {@link org.apache.com.timvanx.gossip.model.Base} which uses this interface 28 | */ 29 | public interface Replicable { 30 | /** 31 | * Test for a given data item needs to be replicated. 32 | * @param me node that the data item is going to transmit from. 33 | * @param destination target node to replicate. 34 | * @param message this parameter is currently ignored 35 | * @return true if the data item needs to be replicated to the destination. Otherwise false. 36 | */ 37 | boolean shouldReplicate(LocalMember me, LocalMember destination, T message); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/less/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | .fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal @fa-font-size-base/@fa-line-height-base FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | 14 | .fa-icon-rotate(@degrees, @rotation) { 15 | -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=@{rotation})"; 16 | -webkit-transform: rotate(@degrees); 17 | -ms-transform: rotate(@degrees); 18 | transform: rotate(@degrees); 19 | } 20 | 21 | .fa-icon-flip(@horiz, @vert, @rotation) { 22 | -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=@{rotation}, mirror=1)"; 23 | -webkit-transform: scale(@horiz, @vert); 24 | -ms-transform: scale(@horiz, @vert); 25 | transform: scale(@horiz, @vert); 26 | } 27 | 28 | 29 | // Only display content to screen readers. A la Bootstrap 4. 30 | // 31 | // See: http://a11yproject.com/posts/how-to-hide-content/ 32 | 33 | .sr-only() { 34 | position: absolute; 35 | width: 1px; 36 | height: 1px; 37 | padding: 0; 38 | margin: -1px; 39 | overflow: hidden; 40 | clip: rect(0,0,0,0); 41 | border: 0; 42 | } 43 | 44 | // Use in conjunction with .sr-only to only display content when it's focused. 45 | // 46 | // Useful for "Skip to main content" links; see http://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1 47 | // 48 | // Credit: HTML5 Boilerplate 49 | 50 | .sr-only-focusable() { 51 | &:active, 52 | &:focus { 53 | position: static; 54 | width: auto; 55 | height: auto; 56 | margin: 0; 57 | overflow: visible; 58 | clip: auto; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/handlers/SharedDataBulkMessageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager.handlers; 19 | 20 | import org.apache.com.timvanx.gossip.manager.GossipCore; 21 | import org.apache.com.timvanx.gossip.manager.GossipManager; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | import org.apache.com.timvanx.gossip.model.SharedDataMessage; 24 | import org.apache.com.timvanx.gossip.udp.UdpSharedDataBulkMessage; 25 | 26 | public class SharedDataBulkMessageHandler implements MessageHandler{ 27 | 28 | /** 29 | * @param gossipCore context. 30 | * @param gossipManager context. 31 | * @param base message reference. 32 | * @return boolean indicating success. 33 | */ 34 | @Override 35 | public boolean invoke(GossipCore gossipCore, GossipManager gossipManager, Base base) { 36 | UdpSharedDataBulkMessage udpMessage = (UdpSharedDataBulkMessage) base; 37 | for (SharedDataMessage dataMsg: udpMessage.getMessages()) 38 | gossipCore.addSharedData(dataMsg); 39 | return true; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/handlers/PerNodeDataBulkMessageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager.handlers; 19 | 20 | import org.apache.com.timvanx.gossip.manager.GossipCore; 21 | import org.apache.com.timvanx.gossip.manager.GossipManager; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | import org.apache.com.timvanx.gossip.model.PerNodeDataMessage; 24 | import org.apache.com.timvanx.gossip.udp.UdpPerNodeDataBulkMessage; 25 | 26 | public class PerNodeDataBulkMessageHandler implements MessageHandler { 27 | 28 | /** 29 | * @param gossipCore context. 30 | * @param gossipManager context. 31 | * @param base message reference. 32 | * @return boolean indicating success. 33 | */ 34 | @Override 35 | public boolean invoke(GossipCore gossipCore, GossipManager gossipManager, Base base) { 36 | UdpPerNodeDataBulkMessage udpMessage = (UdpPerNodeDataBulkMessage) base; 37 | for (PerNodeDataMessage dataMsg: udpMessage.getMessages()) 38 | gossipCore.addPerNodeData(dataMsg); 39 | return true; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/gossip/model/NodeURI.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.gossip.model; 2 | 3 | import java.net.InetAddress; 4 | 5 | /** 6 | *

BlockChain

7 | *

IP地址和端口号的实体类

8 | * 9 | * @author : TimVan 10 | * @date : 2020-04-01 15:10 11 | **/ 12 | public class NodeURI { 13 | private String ipAddress; 14 | private String id; 15 | 16 | public NodeURI(String ipAddress, String id) { 17 | this.ipAddress = ipAddress; 18 | this.id = id; 19 | } 20 | 21 | /** 22 | * @param ip ip地址,如192.168.1.1 23 | * @param port 端口号 24 | * @param id id号 25 | * */ 26 | public NodeURI(String ip,int port, String id) { 27 | //udp://localhost:5400 28 | this.ipAddress = "udp://" + ip + ":" + port; 29 | this.id = id; 30 | } 31 | 32 | 33 | public String getIpAddress() { 34 | return ipAddress; 35 | } 36 | 37 | public void setIpAddress(String ipAddress) { 38 | this.ipAddress = ipAddress; 39 | } 40 | 41 | public String getId() { 42 | return id; 43 | } 44 | 45 | public void setId(String id) { 46 | this.id = id; 47 | } 48 | 49 | /** 获取本地IP地址 */ 50 | public static String getLocalIP() { 51 | // TODO Auto-generated method stub 52 | InetAddress ia=null; 53 | try { 54 | ia= InetAddress.getLocalHost(); 55 | return ia.getHostAddress(); 56 | } catch (Exception e) { 57 | // TODO Auto-generated catch block 58 | e.printStackTrace(); 59 | } 60 | return "localhost"; 61 | } 62 | 63 | public static void main(String[] args) { 64 | 65 | System.out.println(getLocalIP()); 66 | } 67 | 68 | 69 | @Override 70 | public String toString() { 71 | return "NodeURI{" + 72 | "ip='" + ipAddress + '\'' + 73 | ", port='" + id + '\'' + 74 | '}'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/udp/UdpSharedDataMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.udp; 19 | 20 | import org.apache.com.timvanx.gossip.model.SharedDataMessage; 21 | 22 | public class UdpSharedDataMessage extends SharedDataMessage implements Trackable { 23 | 24 | private String uriFrom; 25 | private String uuid; 26 | 27 | public String getUriFrom() { 28 | return uriFrom; 29 | } 30 | 31 | public void setUriFrom(String uriFrom) { 32 | this.uriFrom = uriFrom; 33 | } 34 | 35 | public String getUuid() { 36 | return uuid; 37 | } 38 | 39 | public void setUuid(String uuid) { 40 | this.uuid = uuid; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "UdpSharedGossipDataMessage [uriFrom=" + uriFrom + ", uuid=" + uuid + ", getNodeId()=" 46 | + getNodeId() + ", getKey()=" + getKey() + ", getPayload()=" + getPayload() 47 | + ", getTimestamp()=" + getTimestamp() + ", getExpireAt()=" + getExpireAt() 48 | + ", getReplicable()=" + getReplicable() + "]"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/font-awesome-4.7.0/scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | @mixin fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/#{$fa-line-height-base} FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | 12 | } 13 | 14 | @mixin fa-icon-rotate($degrees, $rotation) { 15 | -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation})"; 16 | -webkit-transform: rotate($degrees); 17 | -ms-transform: rotate($degrees); 18 | transform: rotate($degrees); 19 | } 20 | 21 | @mixin fa-icon-flip($horiz, $vert, $rotation) { 22 | -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}, mirror=1)"; 23 | -webkit-transform: scale($horiz, $vert); 24 | -ms-transform: scale($horiz, $vert); 25 | transform: scale($horiz, $vert); 26 | } 27 | 28 | 29 | // Only display content to screen readers. A la Bootstrap 4. 30 | // 31 | // See: http://a11yproject.com/posts/how-to-hide-content/ 32 | 33 | @mixin sr-only { 34 | position: absolute; 35 | width: 1px; 36 | height: 1px; 37 | padding: 0; 38 | margin: -1px; 39 | overflow: hidden; 40 | clip: rect(0,0,0,0); 41 | border: 0; 42 | } 43 | 44 | // Use in conjunction with .sr-only to only display content when it's focused. 45 | // 46 | // Useful for "Skip to main content" links; see http://www.w3.org/TR/2013/NOTE-WCAG20-TECHS-20130905/G1 47 | // 48 | // Credit: HTML5 Boilerplate 49 | 50 | @mixin sr-only-focusable { 51 | &:active, 52 | &:focus { 53 | position: static; 54 | width: auto; 55 | height: auto; 56 | margin: 0; 57 | overflow: visible; 58 | clip: auto; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/resources/static/page/memberBoard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | layui 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |
17 |
18 | 存活节点 19 |
20 |
21 |
22 | 23 | 26 |
27 | 28 |
29 |
30 |
31 | 死亡节点 32 |
33 |
34 |
35 | 36 | 39 |
40 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); -------------------------------------------------------------------------------- /src/main/resources/static/page/gossipBoard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | layui 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 | 28 | 29 |
30 | 31 |
32 |
33 | 34 | 35 | 36 | 39 |
40 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/crdt/CrdtBiFunctionMerge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.crdt; 19 | 20 | import java.util.function.BiFunction; 21 | 22 | @SuppressWarnings("rawtypes") 23 | public class CrdtBiFunctionMerge implements BiFunction { 24 | 25 | @SuppressWarnings("unchecked") 26 | @Override 27 | public Crdt apply(Crdt t, Crdt u) { 28 | if (t == null && u == null){ 29 | return null; 30 | } else if (t == null){ 31 | return u; 32 | } else if (u == null){ 33 | return t; 34 | } 35 | if (! u.getClass().equals(t.getClass())){ 36 | throw new IllegalArgumentException( "Can not merge " + t.getClass() + " "+ u.getClass()); 37 | } 38 | return t.merge(u); 39 | } 40 | 41 | @SuppressWarnings("unchecked") 42 | public static Crdt applyStatic(Crdt t, Crdt u){ 43 | if (t == null && u == null){ 44 | return null; 45 | } else if (t == null){ 46 | return u; 47 | } else if (u == null){ 48 | return t; 49 | } 50 | if (! u.getClass().equals(t.getClass())){ 51 | throw new IllegalArgumentException( "Can not merge " + t.getClass() + " "+ u.getClass()); 52 | } 53 | return t.merge(u); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/handlers/ShutdownMessageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager.handlers; 19 | 20 | import org.apache.com.timvanx.gossip.manager.GossipCore; 21 | import org.apache.com.timvanx.gossip.manager.GossipManager; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | import org.apache.com.timvanx.gossip.model.PerNodeDataMessage; 24 | import org.apache.com.timvanx.gossip.model.ShutdownMessage; 25 | 26 | public class ShutdownMessageHandler implements MessageHandler { 27 | 28 | /** 29 | * @param gossipCore context. 30 | * @param gossipManager context. 31 | * @param base message reference. 32 | * @return boolean indicating success. 33 | */ 34 | @Override 35 | public boolean invoke(GossipCore gossipCore, GossipManager gossipManager, Base base) { 36 | ShutdownMessage s = (ShutdownMessage) base; 37 | PerNodeDataMessage m = new PerNodeDataMessage(); 38 | m.setKey(ShutdownMessage.PER_NODE_KEY); 39 | m.setNodeId(s.getNodeId()); 40 | m.setPayload(base); 41 | m.setTimestamp(System.currentTimeMillis()); 42 | m.setExpireAt(System.currentTimeMillis() + 30L * 1000L); 43 | gossipCore.addPerNodeData(m); 44 | return true; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/replication/WhiteListReplicable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.replication; 19 | 20 | import org.apache.com.timvanx.gossip.LocalMember; 21 | import org.apache.com.timvanx.gossip.model.Base; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | /** 27 | * Replicable implementation which replicates data to given set of nodes. 28 | * 29 | * @param A subtype of the class {@link org.apache.com.timvanx.gossip.model.Base} which uses this interface 30 | * @see Replicable 31 | */ 32 | public class WhiteListReplicable implements Replicable { 33 | 34 | private final List whiteListMembers; 35 | 36 | public WhiteListReplicable(List whiteListMembers) { 37 | if (whiteListMembers == null) { 38 | this.whiteListMembers = new ArrayList<>(); 39 | } else { 40 | this.whiteListMembers = whiteListMembers; 41 | } 42 | } 43 | 44 | public List getWhiteListMembers() { 45 | return whiteListMembers; 46 | } 47 | 48 | @Override 49 | public boolean shouldReplicate(LocalMember me, LocalMember destination, T message) { 50 | return whiteListMembers.contains(destination); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/replication/BlackListReplicable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.replication; 19 | 20 | import org.apache.com.timvanx.gossip.LocalMember; 21 | import org.apache.com.timvanx.gossip.model.Base; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | /** 27 | * Replicable implementation which does not replicate data to given set of nodes. 28 | * 29 | * @param A subtype of the class {@link org.apache.com.timvanx.gossip.model.Base} which uses this interface 30 | * @see Replicable 31 | */ 32 | public class BlackListReplicable implements Replicable { 33 | 34 | private final List blackListMembers; 35 | 36 | public BlackListReplicable(List blackListMembers) { 37 | if (blackListMembers == null) { 38 | this.blackListMembers = new ArrayList<>(); 39 | } else { 40 | this.blackListMembers = blackListMembers; 41 | } 42 | } 43 | 44 | public List getBlackListMembers() { 45 | return blackListMembers; 46 | } 47 | 48 | @Override 49 | public boolean shouldReplicate(LocalMember me, LocalMember destination, T message) { 50 | return !blackListMembers.contains(destination); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/web/dao/TransactionDAO.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.web.dao; 2 | 3 | import cn.hutool.core.util.ObjectUtil; 4 | import com.timvanx.lightdisk.HeartBeatLog; 5 | import com.timvanx.lightdisk.LightDisk; 6 | import com.timvanx.web.config.LightDiskHungrySingleton; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | /** 13 | *

BlockChain

14 | *

交易列表mapper

15 | * 16 | * @author : TimVan 17 | * @date : 2020-05-03 12:28 18 | **/ 19 | @Repository 20 | public class TransactionDAO { 21 | 22 | /** 获取所有的本地交易列表 */ 23 | public List selectTransaction() { 24 | LightDisk lightDisk = LightDiskHungrySingleton.getLightDisk(); 25 | 26 | if(ObjectUtil.isNull(lightDisk)){ 27 | System.out.println("in selectTransaction:lightDisk为空"); 28 | return null; 29 | } 30 | 31 | return lightDisk.getLocalHeartbeatList(); 32 | 33 | } 34 | 35 | 36 | /** 37 | * 获取分页的本地交易列表 38 | * @param page 当前页 39 | * @param limit 每页显示的条数 40 | */ 41 | public Map selectTransaction(int page, int limit) { 42 | LightDisk lightDisk = LightDiskHungrySingleton.getLightDisk(); 43 | 44 | if(ObjectUtil.isNull(lightDisk)){ 45 | System.out.println("in selectTransaction(int page, int limit):lightDisk为空"); 46 | return null; 47 | } 48 | return lightDisk.getTransactionList(page, limit); 49 | } 50 | 51 | /** 52 | * 通过公钥,获取分页的本地交易列表 53 | * @param publicKey 公钥 54 | * @param page 当前页 55 | * @param limit 每页显示的条数 56 | */ 57 | public Map selectTransaction(String publicKey,int page, int limit) { 58 | LightDisk lightDisk = LightDiskHungrySingleton.getLightDisk(); 59 | 60 | if(ObjectUtil.isNull(lightDisk)){ 61 | System.out.println("in selectTransaction(int page, int limit):lightDisk为空"); 62 | return null; 63 | } 64 | return lightDisk.getTransactionListByPublicKey(publicKey,page, limit); 65 | } 66 | 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/secure/KeyTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.secure; 19 | 20 | import java.io.File; 21 | import java.io.FileOutputStream; 22 | import java.io.IOException; 23 | import java.security.*; 24 | 25 | public class KeyTool { 26 | 27 | public static void generatePubandPrivateKeyFiles(String path, String id) 28 | throws NoSuchAlgorithmException, NoSuchProviderException, IOException{ 29 | SecureRandom r = new SecureRandom(); 30 | KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN"); 31 | keyGen.initialize(1024, r); 32 | KeyPair pair = keyGen.generateKeyPair(); 33 | PrivateKey priv = pair.getPrivate(); 34 | PublicKey pub = pair.getPublic(); 35 | { 36 | FileOutputStream sigfos = new FileOutputStream(new File(path, id)); 37 | sigfos.write(priv.getEncoded()); 38 | sigfos.close(); 39 | } 40 | { 41 | FileOutputStream sigfos = new FileOutputStream(new File(path, id + ".pub")); 42 | sigfos.write(pub.getEncoded()); 43 | sigfos.close(); 44 | } 45 | } 46 | 47 | public static void main (String [] args) throws 48 | NoSuchAlgorithmException, NoSuchProviderException, IOException{ 49 | generatePubandPrivateKeyFiles(args[0], args[1]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/handlers/TypedMessageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager.handlers; 19 | 20 | import org.apache.com.timvanx.gossip.manager.GossipCore; 21 | import org.apache.com.timvanx.gossip.manager.GossipManager; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | 24 | public class TypedMessageHandler implements MessageHandler { 25 | final private Class messageClass; 26 | final private MessageHandler messageHandler; 27 | 28 | public TypedMessageHandler(Class messageClass, MessageHandler messageHandler) { 29 | if (messageClass == null || messageHandler == null) { 30 | throw new NullPointerException(); 31 | } 32 | this.messageClass = messageClass; 33 | this.messageHandler = messageHandler; 34 | } 35 | 36 | /** 37 | * @param gossipCore context. 38 | * @param gossipManager context. 39 | * @param base message reference. 40 | * @return true if types match, false otherwise. 41 | */ 42 | @Override 43 | public boolean invoke(GossipCore gossipCore, GossipManager gossipManager, Base base) { 44 | if (messageClass.isAssignableFrom(base.getClass())) { 45 | messageHandler.invoke(gossipCore, gossipManager, base); 46 | return true; 47 | } else { 48 | return false; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/event/data/DataEventConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.event.data; 19 | 20 | public class DataEventConstants { 21 | 22 | // MetricRegistry 23 | public static final String PER_NODE_DATA_SUBSCRIBERS_SIZE 24 | = "com.timvanx.gossip.event.data.pernode.subscribers.size"; 25 | public static final String PER_NODE_DATA_SUBSCRIBERS_QUEUE_SIZE 26 | = "com.timvanx.gossip.event.data.pernode.subscribers.queue.size"; 27 | public static final String SHARED_DATA_SUBSCRIBERS_SIZE 28 | = "com.timvanx.gossip.event.data.shared.subscribers.size"; 29 | public static final String SHARED_DATA_SUBSCRIBERS_QUEUE_SIZE 30 | = "com.timvanx.gossip.event.data.shared.subscribers.queue.size"; 31 | 32 | // Thread pool 33 | public static final int PER_NODE_DATA_QUEUE_SIZE = 64; 34 | public static final int PER_NODE_DATA_CORE_POOL_SIZE = 1; 35 | public static final int PER_NODE_DATA_MAX_POOL_SIZE = 30; 36 | public static final int PER_NODE_DATA_KEEP_ALIVE_TIME_SECONDS = 1; 37 | public static final int SHARED_DATA_QUEUE_SIZE = 64; 38 | public static final int SHARED_DATA_CORE_POOL_SIZE = 1; 39 | public static final int SHARED_DATA_MAX_POOL_SIZE = 30; 40 | public static final int SHARED_DATA_KEEP_ALIVE_TIME_SECONDS = 1; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/Base.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | import com.fasterxml.jackson.annotation.JsonSubTypes; 21 | import com.fasterxml.jackson.annotation.JsonSubTypes.Type; 22 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 23 | import org.apache.com.timvanx.gossip.udp.*; 24 | 25 | 26 | @JsonTypeInfo( 27 | use = JsonTypeInfo.Id.CLASS, 28 | include = JsonTypeInfo.As.PROPERTY, 29 | property = "type") 30 | @JsonSubTypes({ 31 | @Type(value = ActiveGossipMessage.class, name = "ActiveGossipMessage"), 32 | @Type(value = Fault.class, name = "Fault"), 33 | @Type(value = ActiveGossipOk.class, name = "ActiveGossipOk"), 34 | @Type(value = UdpActiveGossipOk.class, name = "UdpActiveGossipOk"), 35 | @Type(value = UdpActiveGossipMessage.class, name = "UdpActiveGossipMessage"), 36 | @Type(value = UdpNotAMemberFault.class, name = "UdpNotAMemberFault"), 37 | @Type(value = PerNodeDataMessage.class, name = "PerNodeDataMessage"), 38 | @Type(value = UdpPerNodeDataBulkMessage.class, name = "UdpPerNodeDataMessage"), 39 | @Type(value = SharedDataMessage.class, name = "SharedDataMessage"), 40 | @Type(value = UdpSharedDataBulkMessage.class, name = "UdpSharedDataMessage") 41 | }) 42 | public class Base { 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/web/dao/BlockDAO.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.web.dao; 2 | 3 | import cn.hutool.core.util.ObjectUtil; 4 | import com.timvanx.blockchain.model.Block; 5 | import com.timvanx.lightdisk.LightDisk; 6 | import com.timvanx.web.config.LightDiskHungrySingleton; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | *

BlockChain

13 | *

区块mapper

14 | * 15 | * @author : TimVan 16 | * @date : 2020-05-03 12:28 17 | **/ 18 | @Repository 19 | public class BlockDAO { 20 | 21 | /** 获取所有的本地区块 */ 22 | public List selectLocalBlock() { 23 | LightDisk lightDisk = LightDiskHungrySingleton.getLightDisk(); 24 | 25 | if(ObjectUtil.isNull(lightDisk)){ 26 | System.out.println("lightDisk为空"); 27 | return null; 28 | } 29 | // System.out.println("height="+lightDisk.getLocalChainHeight()); 30 | 31 | return lightDisk.getLocalBlockList(); 32 | 33 | } 34 | 35 | 36 | /** 37 | * 获取分页的本地区块 38 | * @param page 当前页 39 | * @param limit 每页显示的条数 40 | */ 41 | public List selectLocalBlock(int page,int limit) { 42 | LightDisk lightDisk = LightDiskHungrySingleton.getLightDisk(); 43 | 44 | if(ObjectUtil.isNull(lightDisk)){ 45 | System.out.println("lightDisk为空"); 46 | return null; 47 | } 48 | 49 | return lightDisk.getLocalBlockList( page, limit); 50 | 51 | } 52 | 53 | /** 54 | * 获得区块链的长度 55 | */ 56 | public int getBlockListSize(){ 57 | LightDisk lightDisk = LightDiskHungrySingleton.getLightDisk(); 58 | 59 | if(ObjectUtil.isNull(lightDisk)){ 60 | System.out.println("lightDisk为空"); 61 | return 0; 62 | } 63 | 64 | return lightDisk.getBlockListSize(); 65 | } 66 | 67 | public List mineBlock() { 68 | LightDisk lightDisk = LightDiskHungrySingleton.getLightDisk(); 69 | 70 | if(ObjectUtil.isNull(lightDisk)){ 71 | return null; 72 | } 73 | System.out.println("height="+lightDisk.getLocalChainHeight()); 74 | 75 | return lightDisk.getLocalBlockList(); 76 | 77 | 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/web/config/LoginHandlerInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.web.config; 2 | 3 | import cn.hutool.core.util.StrUtil; 4 | import com.timvanx.gossip.GossipCommunicateLayer; 5 | import com.timvanx.lightdisk.LightDisk; 6 | import org.springframework.web.servlet.HandlerInterceptor; 7 | import org.springframework.web.servlet.ModelAndView; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | import javax.servlet.http.HttpSession; 12 | 13 | /** 14 | *

BlockChain

15 | *

登录拦截

16 | * 17 | * @author : TimVan 18 | * @date : 2020-05-16 19:07 19 | **/ 20 | public class LoginHandlerInterceptor implements HandlerInterceptor { 21 | 22 | /** 23 | * 目标方法执行之前 24 | */ 25 | @Override 26 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 27 | 28 | 29 | HttpSession session = request.getSession(); 30 | 31 | String publickey = (String) session.getAttribute("publicKey"); 32 | 33 | if (StrUtil.hasEmpty(publickey) || (publickey.length() < 2)) { 34 | 35 | session.setAttribute("publicKey", ""); 36 | session.setAttribute("privateKey", ""); 37 | 38 | try { 39 | LightDisk lightDisk = 40 | LightDiskHungrySingleton.getLightDisk(); 41 | if (lightDisk != null) { 42 | //关闭lightDisk 43 | lightDisk.shutDown(); 44 | } 45 | 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | 50 | request.getRequestDispatcher("/page/login-1.html").forward(request, response); 51 | return false; 52 | } else { 53 | // 已登录,放行 54 | return true; 55 | } 56 | } 57 | 58 | @Override 59 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 60 | 61 | } 62 | 63 | @Override 64 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/replication/DataCenterReplicable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.replication; 19 | 20 | import org.apache.com.timvanx.gossip.LocalMember; 21 | import org.apache.com.timvanx.gossip.manager.DatacenterRackAwareActiveGossiper; 22 | import org.apache.com.timvanx.gossip.model.Base; 23 | 24 | /** 25 | * Replicable implementation which does replicate data only in the same data center. 26 | * 27 | * @param A subtype of the class {@link org.apache.com.timvanx.gossip.model.Base} which uses this interface 28 | * @see Replicable 29 | */ 30 | public class DataCenterReplicable implements Replicable { 31 | 32 | @Override 33 | public boolean shouldReplicate(LocalMember me, LocalMember destination, T message) { 34 | if (!me.getProperties().containsKey(DatacenterRackAwareActiveGossiper.DATACENTER)) { 35 | // replicate to others if I am not belong to any data center 36 | return true; 37 | } else if (!destination.getProperties() 38 | .containsKey(DatacenterRackAwareActiveGossiper.DATACENTER)) { 39 | // Do not replicate if the destination data center is not defined 40 | return false; 41 | } else { 42 | return me.getProperties().get(DatacenterRackAwareActiveGossiper.DATACENTER) 43 | .equals(destination.getProperties().get(DatacenterRackAwareActiveGossiper.DATACENTER)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/timvanx/web/controller/TransactionController.java: -------------------------------------------------------------------------------- 1 | package com.timvanx.web.controller; 2 | 3 | import cn.hutool.core.util.StrUtil; 4 | import com.alibaba.fastjson.JSON; 5 | import com.timvanx.web.config.ReqContants; 6 | import com.timvanx.web.service.TransactionServiceImpl; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import java.io.IOException; 15 | import java.util.Map; 16 | 17 | /** 18 | *

BlockChain

19 | *

交易列表相关控制器

20 | * 21 | * @author : TimVan 22 | * @date : 2020-05-03 12:45 23 | **/ 24 | @Controller 25 | @RequestMapping(value = ReqContants.REQ_TRANSACTION) 26 | public class TransactionController { 27 | 28 | /** 29 | * 构造器注入 30 | */ 31 | final TransactionServiceImpl transactionService; 32 | 33 | @Autowired 34 | public TransactionController(TransactionServiceImpl transactionService) { 35 | this.transactionService = transactionService; 36 | } 37 | 38 | /** 39 | * 获得交易列表列表 /transaction/GetTransactionList 40 | */ 41 | @PostMapping(ReqContants.REQ_TRANSACTION_GET_TRANSACTION_LIST) 42 | public void GetBlockList(HttpServletRequest request, HttpServletResponse response) throws IOException { 43 | // get解决中文乱码 44 | response.setContentType("application/text; charset=utf-8"); 45 | 46 | //page: 2 limit: 10 47 | int page = Integer.parseInt(request.getParameter("page")); 48 | int limit = Integer.parseInt(request.getParameter("limit")); 49 | String publicKey = (String)(request.getParameter("publicKey")); 50 | 51 | Map mjs = null; 52 | if(StrUtil.hasEmpty(publicKey)){ 53 | mjs = transactionService.selectTransaction(page,limit); 54 | }else{ 55 | publicKey = publicKey.trim(); 56 | mjs = transactionService.selectTransaction(publicKey,page,limit); 57 | } 58 | 59 | 60 | // 把数据转化为json格式 61 | String json = JSON.toJSONString(mjs); 62 | response.getWriter().write(json); 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/lock/vote/Vote.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.lock.vote; 19 | 20 | import java.util.List; 21 | 22 | /** 23 | * Store a voter details. 24 | */ 25 | public class Vote { 26 | private final String votingNode; 27 | private final Boolean voteValue; // TODO: 7/16/17 weight? 28 | private Boolean voteExchange; 29 | private final List liveMembers; 30 | private final List deadMembers; 31 | 32 | public Vote(String votingNode, Boolean voteValue, Boolean voteExchange, List liveMembers, 33 | List deadMembers) { 34 | this.votingNode = votingNode; 35 | this.voteValue = voteValue; 36 | this.voteExchange = voteExchange; 37 | this.liveMembers = liveMembers; 38 | this.deadMembers = deadMembers; 39 | } 40 | 41 | public String getVotingNode() { 42 | return votingNode; 43 | } 44 | 45 | public Boolean getVoteValue() { 46 | return voteValue; 47 | } 48 | 49 | public Boolean getVoteExchange() { 50 | return voteExchange; 51 | } 52 | 53 | public void setVoteExchange(Boolean voteExchange) { 54 | this.voteExchange = voteExchange; 55 | } 56 | 57 | public List getLiveMembers() { 58 | return liveMembers; 59 | } 60 | 61 | public List getDeadMembers() { 62 | return deadMembers; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return "votingNode=" + votingNode + ", voteValue=" + voteValue + ", liveMembers=" + liveMembers 68 | + ", deadMembers= " + deadMembers; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: com.timvanx.cmd.Launcher 3 | Class-Path: spring-aop-5.0.5.RELEASE.jar bitcoinj-core-0.15.8.jar netty- 4 | codec-dns-4.1.23.Final.jar spring-web-5.0.5.RELEASE.jar javax.annotatio 5 | n-api-1.3.2.jar hutool-all-5.3.2.jar netty-handler-proxy-4.1.23.Final.j 6 | ar slf4j-api-1.7.25.jar bcprov-jdk15to18-1.63.jar spring-boot-starter-l 7 | ogging-2.0.1.RELEASE.jar hibernate-validator-6.0.9.Final.jar spring-boo 8 | t-autoconfigure-2.0.1.RELEASE.jar netty-codec-socks-4.1.23.Final.jar ne 9 | tty-resolver-dns-4.1.23.Final.jar spring-boot-devtools-2.0.1.RELEASE.ja 10 | r spring-boot-2.0.1.RELEASE.jar tomcat-embed-core-8.5.29.jar spring-bea 11 | ns-5.0.5.RELEASE.jar spring-boot-starter-tomcat-2.0.1.RELEASE.jar okio- 12 | 1.15.0.jar netty-transport-4.1.23.Final.jar netty-common-4.1.23.Final.j 13 | ar spring-boot-starter-2.0.1.RELEASE.jar jackson-core-2.8.5.jar netty-r 14 | esolver-4.1.23.Final.jar jackson-module-parameter-names-2.8.5.jar anima 15 | l-sniffer-annotations-1.17.jar snakeyaml-1.19.jar log4j-api-2.10.0.jar 16 | netty-codec-4.1.23.Final.jar tomcat-embed-websocket-8.5.29.jar jackson- 17 | annotations-2.8.5.jar listenablefuture-9999.0-empty-to-avoid-conflict-w 18 | ith-guava.jar jackson-datatype-jdk8-2.8.5.jar error_prone_annotations-2 19 | .2.0.jar guava-27.1-jre.jar fastjson-1.2.68.jar jcip-annotations-1.0.ja 20 | r protobuf-java-3.11.4.jar spring-boot-starter-json-2.0.1.RELEASE.jar g 21 | son-2.8.2.jar jul-to-slf4j-1.7.25.jar log4j-1.2.17.jar logback-core-1.2 22 | .3.jar netty-buffer-4.1.23.Final.jar spring-context-5.0.5.RELEASE.jar f 23 | ailureaccess-1.0.1.jar log4j-to-slf4j-2.10.0.jar vertx-core-3.5.4.jar j 24 | boss-logging-3.3.2.Final.jar commons-math-1.2.jar netty-codec-http-4.1. 25 | 23.Final.jar validation-api-2.0.1.Final.jar jsr305-3.0.2.jar spring-exp 26 | ression-5.0.5.RELEASE.jar jgossip-1.3.2.jar classmate-1.3.4.jar Base58- 27 | 2019.01.27.jar metrics-core-3.1.2.jar jackson-datatype-jsr310-2.8.5.jar 28 | checker-qual-2.5.2.jar bcprov-jdk15on-1.56.jar netty-handler-4.1.23.Fi 29 | nal.jar j2objc-annotations-1.1.jar spring-jcl-5.0.5.RELEASE.jar jackson 30 | -databind-2.8.5.jar tomcat-embed-el-8.5.29.jar netty-codec-http2-4.1.23 31 | .Final.jar spring-boot-starter-web-2.0.1.RELEASE.jar logback-classic-1. 32 | 2.3.jar spring-webmvc-5.0.5.RELEASE.jar commons-codec-1.12.jar spring-c 33 | ore-5.0.5.RELEASE.jar okhttp-3.12.8.jar 34 | 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/utils/ReflectionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.utils; 19 | 20 | import java.lang.reflect.Constructor; 21 | import java.lang.reflect.InvocationTargetException; 22 | 23 | public class ReflectionUtils { 24 | 25 | /** 26 | * Create an instance of a thing. This method essentially makes code more readable by handing the various exception 27 | * trapping. 28 | * @param className 29 | * @param constructorTypes 30 | * @param constructorArgs 31 | * @param 32 | * @return constructed instance of a thing. 33 | */ 34 | @SuppressWarnings("unchecked") 35 | public static T constructWithReflection(String className, Class[] constructorTypes, Object[] constructorArgs) { 36 | try { 37 | Constructor c = Class.forName(className).getConstructor(constructorTypes); 38 | c.setAccessible(true); 39 | return (T) c.newInstance(constructorArgs); 40 | } catch (InvocationTargetException e) { 41 | // catch ITE and throw the target if it is a RTE. 42 | if (e.getTargetException() != null && RuntimeException.class.isAssignableFrom(e.getTargetException().getClass())) { 43 | throw (RuntimeException) e.getTargetException(); 44 | } else { 45 | throw new RuntimeException(e); 46 | } 47 | } catch (ReflectiveOperationException others) { 48 | // Note: No class in the above list should be a descendent of RuntimeException. Otherwise, we're just wrapping 49 | // and making stack traces confusing. 50 | throw new RuntimeException(others); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/lock/vote/VoteCandidate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.lock.vote; 19 | 20 | import java.util.Map; 21 | import java.util.Objects; 22 | 23 | /** 24 | * Stores the vote candidate details and its votes. 25 | */ 26 | public class VoteCandidate { 27 | 28 | private final String candidateNodeId; 29 | private final String votingKey; 30 | private final Map votes; 31 | 32 | public VoteCandidate(String candidateNodeId, String votingKey, Map votes) { 33 | 34 | this.candidateNodeId = candidateNodeId; 35 | this.votingKey = votingKey; 36 | this.votes = votes; 37 | } 38 | 39 | public String getCandidateNodeId() { 40 | return candidateNodeId; 41 | } 42 | 43 | public String getVotingKey() { 44 | return votingKey; 45 | } 46 | 47 | public Map getVotes() { 48 | return votes; 49 | } 50 | 51 | public void addVote(Vote vote) { 52 | votes.put(vote.getVotingNode(), vote); 53 | } 54 | 55 | @Override 56 | public int hashCode() { 57 | return Objects.hash(candidateNodeId, votingKey); 58 | } 59 | 60 | @Override 61 | public boolean equals(Object obj) { 62 | if (!(obj instanceof VoteCandidate)) 63 | return false; 64 | if (obj == this) 65 | return true; 66 | VoteCandidate other = (VoteCandidate) obj; 67 | return this.candidateNodeId.equals(other.candidateNodeId) && this.votingKey 68 | .equals(other.votingKey); 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return "candidateNodeId=" + candidateNodeId + ", votingKey=" + votingKey + ", votes= " + votes; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/Member.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | import java.util.Map; 21 | 22 | public class Member { 23 | 24 | private String cluster; 25 | private String uri; 26 | private String id; 27 | private Long heartbeat; 28 | private Map properties; 29 | 30 | public Member(){ 31 | 32 | } 33 | 34 | public Member(String cluster, String uri, String id, Long heartbeat){ 35 | this.cluster = cluster; 36 | this.uri = uri; 37 | this.id = id; 38 | this.heartbeat = heartbeat; 39 | } 40 | 41 | public String getCluster() { 42 | return cluster; 43 | } 44 | 45 | public void setCluster(String cluster) { 46 | this.cluster = cluster; 47 | } 48 | 49 | public String getUri() { 50 | return uri; 51 | } 52 | 53 | public void setUri(String uri) { 54 | this.uri = uri; 55 | } 56 | 57 | public String getId() { 58 | return id; 59 | } 60 | 61 | public void setId(String id) { 62 | this.id = id; 63 | } 64 | 65 | public Long getHeartbeat() { 66 | return heartbeat; 67 | } 68 | 69 | public void setHeartbeat(Long heartbeat) { 70 | this.heartbeat = heartbeat; 71 | } 72 | 73 | public Map getProperties() { 74 | return properties; 75 | } 76 | 77 | public void setProperties(Map properties) { 78 | this.properties = properties; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return "Member [cluster=" + cluster + ", uri=" + uri + ", id=" + id + ", heartbeat=" 84 | + heartbeat + ", properties=" + properties + "]"; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/LocalMember.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip; 19 | 20 | import org.apache.com.timvanx.gossip.accrual.FailureDetector; 21 | 22 | import java.net.URI; 23 | import java.util.Map; 24 | 25 | /** 26 | * This object represent a com.timvanx.gossip member with the properties known locally. These objects are stored 27 | * in the local list of com.timvanx.gossip members. 28 | * 29 | */ 30 | public class LocalMember extends Member { 31 | /** The failure detector for this member */ 32 | private transient FailureDetector detector; 33 | 34 | /** 35 | * 36 | * @param uri 37 | * The uri of the member 38 | * @param id 39 | * id of the node 40 | * @param heartbeat 41 | * The current heartbeat 42 | */ 43 | public LocalMember(String clusterName, URI uri, String id, 44 | long heartbeat, Map properties, int windowSize, int minSamples, String distribution) { 45 | super(clusterName, uri, id, heartbeat, properties ); 46 | detector = new FailureDetector(minSamples, windowSize, distribution); 47 | } 48 | 49 | protected LocalMember(){ 50 | 51 | } 52 | 53 | public void recordHeartbeat(long now){ 54 | detector.recordHeartbeat(now); 55 | } 56 | 57 | public Double detect(long now) { 58 | return detector.computePhiMeasure(now); 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | Double d = null; 64 | try { 65 | d = detect(System.nanoTime()); 66 | } catch (RuntimeException ex) {} 67 | return "LocalGossipMember [uri=" + uri + ", heartbeat=" + heartbeat + ", clusterName=" 68 | + clusterName + ", id=" + id + ", currentdetect=" + d +" ]"; 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/SharedDataMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | import org.apache.com.timvanx.gossip.replication.Replicable; 21 | 22 | public class SharedDataMessage extends Base { 23 | 24 | private String nodeId; 25 | private String key; 26 | private Object payload; 27 | private Long timestamp; 28 | private Long expireAt; 29 | private Replicable replicable; 30 | 31 | public String getNodeId() { 32 | return nodeId; 33 | } 34 | public void setNodeId(String nodeId) { 35 | this.nodeId = nodeId; 36 | } 37 | public String getKey() { 38 | return key; 39 | } 40 | public void setKey(String key) { 41 | this.key = key; 42 | } 43 | public Object getPayload() { 44 | return payload; 45 | } 46 | public void setPayload(Object payload) { 47 | this.payload = payload; 48 | } 49 | public Long getTimestamp() { 50 | return timestamp; 51 | } 52 | public void setTimestamp(Long timestamp) { 53 | this.timestamp = timestamp; 54 | } 55 | public Long getExpireAt() { 56 | return expireAt; 57 | } 58 | public void setExpireAt(Long expireAt) { 59 | this.expireAt = expireAt; 60 | } 61 | 62 | public Replicable getReplicable() { 63 | return replicable; 64 | } 65 | 66 | public void setReplicable(Replicable replicable) { 67 | this.replicable = replicable; 68 | } 69 | 70 | @Override 71 | public String toString() { 72 | return "SharedGossipDataMessage [nodeId=" + nodeId + ", key=" + key + ", payload=" + payload 73 | + ", timestamp=" + timestamp + ", expireAt=" + expireAt 74 | + ", replicable=" + replicable + "]"; 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/model/PerNodeDataMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.model; 19 | 20 | import org.apache.com.timvanx.gossip.replication.Replicable; 21 | 22 | public class PerNodeDataMessage extends Base { 23 | 24 | private String nodeId; 25 | private String key; 26 | private Object payload; 27 | private Long timestamp; 28 | private Long expireAt; 29 | private Replicable replicable; 30 | 31 | public String getNodeId() { 32 | return nodeId; 33 | } 34 | public void setNodeId(String nodeId) { 35 | this.nodeId = nodeId; 36 | } 37 | public String getKey() { 38 | return key; 39 | } 40 | public void setKey(String key) { 41 | this.key = key; 42 | } 43 | public Object getPayload() { 44 | return payload; 45 | } 46 | public void setPayload(Object payload) { 47 | this.payload = payload; 48 | } 49 | public Long getTimestamp() { 50 | return timestamp; 51 | } 52 | public void setTimestamp(Long timestamp) { 53 | this.timestamp = timestamp; 54 | } 55 | public Long getExpireAt() { 56 | return expireAt; 57 | } 58 | public void setExpireAt(Long expireAt) { 59 | this.expireAt = expireAt; 60 | } 61 | 62 | public Replicable getReplicable() { 63 | return replicable; 64 | } 65 | 66 | public void setReplicable(Replicable replicable) { 67 | this.replicable = replicable; 68 | } 69 | 70 | @Override 71 | public String toString() { 72 | return "GossipDataMessage [nodeId=" + nodeId + ", key=" + key + ", payload=" + payload 73 | + ", timestamp=" + timestamp + ", expireAt=" + expireAt 74 | + ", replicable=" + replicable + "]"; 75 | } 76 | 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/resources/static/js/index.js: -------------------------------------------------------------------------------- 1 | layui.use('layer', function () { 2 | var layer = layui.layer; 3 | }); 4 | 5 | 6 | $(function () { 7 | 8 | // //获取余额 9 | // //检查"#li_indexHtml"是否加载,若加载则高亮,否则一直循环 10 | // var isLoadPage = setInterval(function(){ 11 | // var mod = $("#public-key").text(); 12 | // if(mod.length > 2){ 13 | // clearInterval(isLoadPage); 14 | // } 15 | // },100); 16 | 17 | 18 | //获取账户信息 19 | getWallet(); 20 | //获取IP地址和种子节点 21 | getIP(); 22 | 23 | }); 24 | 25 | //获取账户信息 26 | function getWallet() { 27 | $.post("/common/GetWallet", 28 | {} 29 | , function (ret) { 30 | ret = eval("(" + ret + ")"); 31 | if (ret['code'] === 0) { 32 | $("#public-key").text(ret["data"]["publickey"]); 33 | $("#private-key").text(ret["data"]["privatekey"]); 34 | } else { 35 | layer.msg('信息加载失败'); 36 | logout(); 37 | 38 | } 39 | }); 40 | } 41 | 42 | //获取IP地址和种子节点 43 | function getIP(){ 44 | $.post("/common/GetIP", 45 | {} 46 | , function (ret) { 47 | ret = eval("(" + ret + ")"); 48 | if (ret['code'] === 0) { 49 | $("#uri").text(ret["data"]["URI"]); 50 | $("#id").text(ret["data"]["id"]); 51 | $("#seedNode").text(ret["data"]["SeedNode"]); 52 | $("#seedNodeID").text(ret["data"]["SeedNodeID"]); 53 | } else { 54 | layer.msg('信息加载失败'); 55 | logout(); 56 | 57 | } 58 | }); 59 | } 60 | 61 | //隐藏秘钥控件 62 | function displayPrivateKey(){ 63 | let privateKeyID=document.getElementById("private-key"); 64 | let hiddenID=document.getElementById("private-key-hidden"); 65 | let privateKeyHiddenTextID=document.getElementById("privateKey-hidden-text"); 66 | //图标 67 | let privateKeyHiddenFacID=document.getElementById("privateKey-hidden-i"); 68 | 69 | 70 | if(privateKeyID.style.display==="none"){ 71 | privateKeyID.style.display=""; 72 | hiddenID.style.display="none"; 73 | privateKeyHiddenTextID.innerHTML="隐藏"; 74 | 75 | privateKeyHiddenFacID.classList.add("fa-toggle-on"); 76 | privateKeyHiddenFacID.classList.remove("fa-toggle-off"); 77 | }else{ 78 | privateKeyID.style.display="none"; 79 | hiddenID.style.display=""; 80 | privateKeyHiddenTextID.innerHTML="显示"; 81 | privateKeyHiddenFacID.classList.add("fa-toggle-off"); 82 | privateKeyHiddenFacID.classList.remove("fa-toggle-on"); 83 | } 84 | } 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/main/resources/static/css/page/login-1.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | width: 100%; 3 | height: 100%; 4 | overflow: hidden 5 | } 6 | 7 | body { 8 | background: #1E9FFF; 9 | } 10 | 11 | body:after { 12 | content: ''; 13 | background-repeat: no-repeat; 14 | background-size: cover; 15 | -webkit-filter: blur(3px); 16 | -moz-filter: blur(3px); 17 | -o-filter: blur(3px); 18 | -ms-filter: blur(3px); 19 | filter: blur(3px); 20 | position: absolute; 21 | top: 0; 22 | left: 0; 23 | right: 0; 24 | bottom: 0; 25 | z-index: -1; 26 | } 27 | 28 | .layui-container { 29 | width: 100%; 30 | height: 100%; 31 | overflow: hidden 32 | } 33 | 34 | .admin-login-background { 35 | width: 360px; 36 | height: 300px; 37 | position: absolute; 38 | left: 50%; 39 | top: 20%; 40 | margin-left: -180px; 41 | margin-top: -100px; 42 | } 43 | 44 | .logo-title { 45 | text-align: center; 46 | letter-spacing: 2px; 47 | padding: 14px 0; 48 | } 49 | 50 | .logo-title h1 { 51 | color: #1E9FFF; 52 | font-size: 25px; 53 | font-weight: bold; 54 | } 55 | 56 | .logo-title h3 { 57 | color: #1E9FFF; 58 | font-size: 20px; 59 | } 60 | 61 | .login-form { 62 | background-color: #fff; 63 | border: 1px solid #fff; 64 | border-radius: 3px; 65 | padding: 14px 20px; 66 | box-shadow: 0 0 8px #eeeeee; 67 | } 68 | 69 | .login-form .layui-form-item { 70 | position: relative; 71 | } 72 | 73 | .login-form .layui-form-item label { 74 | position: absolute; 75 | left: 1px; 76 | top: 1px; 77 | width: 38px; 78 | line-height: 36px; 79 | text-align: center; 80 | color: #d2d2d2; 81 | } 82 | 83 | .layui-form-label { 84 | border-color: #e6e6e6; 85 | width: 110px; 86 | padding: 8px 15px; 87 | height: 38px; 88 | line-height: 20px; 89 | border-width: 1px; 90 | border-style: solid; 91 | border-radius: 2px 0 0 2px; 92 | text-align: center; 93 | background-color: #FBFBFB; 94 | overflow: hidden; 95 | box-sizing: border-box; 96 | color: black; 97 | } 98 | 99 | .IPInput { 100 | display: inline !important; 101 | width: 19%; 102 | clear: none; 103 | text-align: center; 104 | height: 34px; 105 | } 106 | 107 | .ip-div{ 108 | margin-left: 35% 109 | } 110 | 111 | .ip-div span{ 112 | vertical-align: super; 113 | } 114 | 115 | .ip-div input{ 116 | border-width: 1px; 117 | border-style: solid; 118 | background-color: #fff; 119 | border-radius: 2px; 120 | border-color: #e6e6e6; 121 | } -------------------------------------------------------------------------------- /src/main/java/org/apache/com/timvanx/gossip/manager/RingStatePersister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package org.apache.com.timvanx.gossip.manager; 19 | 20 | import com.fasterxml.jackson.databind.ObjectMapper; 21 | import org.apache.com.timvanx.gossip.LocalMember; 22 | import org.apache.log4j.Logger; 23 | 24 | import java.io.File; 25 | import java.io.FileInputStream; 26 | import java.io.FileOutputStream; 27 | import java.io.IOException; 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | import java.util.NavigableSet; 31 | 32 | public class RingStatePersister implements Runnable { 33 | 34 | private static final Logger LOGGER = Logger.getLogger(RingStatePersister.class); 35 | private final File path; 36 | // NOTE: this is a different instance than what gets used for message marshalling. 37 | private final ObjectMapper objectMapper; 38 | private final GossipManager manager; 39 | 40 | public RingStatePersister(File path, GossipManager manager){ 41 | this.path = path; 42 | this.objectMapper = GossipManager.metdataObjectMapper; 43 | this.manager = manager; 44 | } 45 | 46 | @Override 47 | public void run() { 48 | writeToDisk(); 49 | } 50 | 51 | void writeToDisk() { 52 | NavigableSet i = manager.getMembers().keySet(); 53 | try (FileOutputStream fos = new FileOutputStream(path)){ 54 | objectMapper.writeValue(fos, i); 55 | } catch (IOException e) { 56 | LOGGER.debug(e); 57 | } 58 | } 59 | 60 | @SuppressWarnings("unchecked") 61 | List readFromDisk() { 62 | if (!path.exists()) { 63 | return new ArrayList<>(); 64 | } 65 | try (FileInputStream fos = new FileInputStream(path)){ 66 | return objectMapper.readValue(fos, ArrayList.class); 67 | } catch (IOException e) { 68 | LOGGER.debug(e); 69 | } 70 | return new ArrayList<>(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/resources/static/page/heartBeatBoard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | layui 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | 16 |
17 | 搜索信息 18 |
19 |
20 |
21 |
22 | 23 |
24 | 25 |
26 |
27 |
28 | 31 |
32 |
33 |
34 |
35 |
36 | 37 | 43 | 44 |
45 | 46 | 49 | 50 |
51 |
52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/resources/static/lib/layui-v2.5.5/lay/modules/rate.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.5.5 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.jquery,i={config:{},index:layui.rate?layui.rate.index+1e4:0,set:function(e){var i=this;return i.config=a.extend({},i.config,e),i},on:function(e,a){return layui.onevent.call(this,n,e,a)}},l=function(){var e=this,a=e.config;return{setvalue:function(a){e.setvalue.call(e,a)},config:a}},n="rate",t="layui-rate",o="layui-icon-rate",s="layui-icon-rate-solid",u="layui-icon-rate-half",r="layui-icon-rate-solid layui-icon-rate-half",c="layui-icon-rate-solid layui-icon-rate",f="layui-icon-rate layui-icon-rate-half",v=function(e){var l=this;l.index=++i.index,l.config=a.extend({},l.config,i.config,e),l.render()};v.prototype.config={length:5,text:!1,readonly:!1,half:!1,value:0,theme:""},v.prototype.render=function(){var e=this,i=e.config,l=i.theme?'style="color: '+i.theme+';"':"";i.elem=a(i.elem),parseInt(i.value)!==i.value&&(i.half||(i.value=Math.ceil(i.value)-i.value<.5?Math.ceil(i.value):Math.floor(i.value)));for(var n='
    ",u=1;u<=i.length;u++){var r='
  • ";i.half&&parseInt(i.value)!==i.value&&u==Math.ceil(i.value)?n=n+'
  • ":n+=r}n+="
"+(i.text?''+i.value+"星":"")+"";var c=i.elem,f=c.next("."+t);f[0]&&f.remove(),e.elemTemp=a(n),i.span=e.elemTemp.next("span"),i.setText&&i.setText(i.value),c.html(e.elemTemp),c.addClass("layui-inline"),i.readonly||e.action()},v.prototype.setvalue=function(e){var a=this,i=a.config;i.value=e,a.render()},v.prototype.action=function(){var e=this,i=e.config,l=e.elemTemp,n=l.find("i").width();l.children("li").each(function(e){var t=e+1,v=a(this);v.on("click",function(e){if(i.value=t,i.half){var o=e.pageX-a(this).offset().left;o<=n/2&&(i.value=i.value-.5)}i.text&&l.next("span").text(i.value+"星"),i.choose&&i.choose(i.value),i.setText&&i.setText(i.value)}),v.on("mousemove",function(e){if(l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+t+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half){var c=e.pageX-a(this).offset().left;c<=n/2&&v.children("i").addClass(u).removeClass(s)}}),v.on("mouseleave",function(){l.find("i").each(function(){a(this).addClass(o).removeClass(r)}),l.find("i:lt("+Math.floor(i.value)+")").each(function(){a(this).addClass(s).removeClass(f)}),i.half&&parseInt(i.value)!==i.value&&l.children("li:eq("+Math.floor(i.value)+")").children("i").addClass(u).removeClass(c)})})},v.prototype.events=function(){var e=this;e.config},i.render=function(e){var a=new v(e);return l.call(a)},e(n,i)}); --------------------------------------------------------------------------------