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('
");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 | 
26 | ##### Web本地操作台
27 | 基本功能同上
28 | 
29 | 
30 | 
31 | 
32 |
33 | #### 结构与框架
34 | 1、流程图
35 | 
36 | 2、区块链结构图,类似于比特币的数据结构,文件作为每组Merkle树的叶子节点数据的来源
37 | 
38 | 3、技术框架
39 | 
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 |
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 | *