https://www.youtube.com/watch?v=uqlUFvkyEUg
1. 折舊長 不能折舊短 代表長期經營
2. 能控制供應 多或少,像蘋果 有強大的控制供應能力,需求多不見得
3. 產品周期長
hyperledger leader peer endorsing peer committing peer
leader peer 是peer之間動態選舉選出的
endorsing peer 預設為每個peer都是,安裝chaincode後,實例化設定policy可以有變化
committing peer 預設為每個peer都是
https://medium.com/@kctheservant/transactions-in-hyperledger-fabric-50e068dda8a9
https://stackoverflow.com/questions/52893818/difference-between-endorsing-peer-and-committing-peer-in-hyperledger-fabric/52894994
endorsing peer 預設為每個peer都是,安裝chaincode後,實例化設定policy可以有變化
committing peer 預設為每個peer都是
https://medium.com/@kctheservant/transactions-in-hyperledger-fabric-50e068dda8a9
https://stackoverflow.com/questions/52893818/difference-between-endorsing-peer-and-committing-peer-in-hyperledger-fabric/52894994
kubernetes K3s Failed!
Failed reason: Node port range can't fixed!
K3s
##### install #####
curl -sfL https://get.k3s.io | sh -
##### login https://192.168.99.119:6443/ get username/password #####
more /etc/rancher/k3s/k3s.yaml
##### change node-port range #####
k3s server --kube-apiserver-arg --service-node-port-range=1-65535
##### install dashboard #####
k3s kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml --insecure-skip-tls-verify
k3s kubectl create secret generic kubernetes-dashboard-certs --from-file=certs -n kube-system
k3s kubectl apply -f dashboard-ClusterRoleBinding.yaml
k3s kubectl apply -f dashboard-adminuser.yaml
k3s kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
Find admin-user-token
https://192.168.99.119:30393/
##### kill all #####
k3s-killall.sh
k3s-uninstall.sh
##### start k3s service #####
service k3s status ## check k3s is stop
service k3s start
Replace uglifyjs-webpack-plugin with terser-webpack-plugin
https://github.com/vuejs/vue-cli/issues/2245
https://github.com/webpack-contrib/terser-webpack-plugin
https://stackoverflow.com/questions/57360588/how-to-use-terser-with-webpack
https://juejin.im/post/5cbc40ea6fb9a068b65e2aa6
https://github.com/webpack-contrib/terser-webpack-plugin
https://stackoverflow.com/questions/57360588/how-to-use-terser-with-webpack
https://juejin.im/post/5cbc40ea6fb9a068b65e2aa6
npm install npm install terser-webpack-plugin
vue.config.js
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
chainWebpack: process.env.NODE_ENV === 'production'
? config => {
config.module.rules.delete('eslint');
config.optimization.minimizer([
new TerserPlugin({
terserOptions: {
parse: {
ecma: 8
},
compress: {
ecma : 5,
warnings : false,
comparisons: false,
inline : 2
},
mangle: {
reserved: ["BigInteger","ECPair","Point"],
safari10: true
},
output: {
ecma : 5,
comments : false,
ascii_only: true
}
},
cache: true,
parallel: true,
sourceMap: false, // false 可以減少一半的js大小,sourceMap為除錯使用
})
]);
}
: config => {
config.module.rules.delete('eslint');
},
devServer: {
host: '0.0.0.0',
port: '80',
//public: '0.0.0.0:80', //無效
disableHostCheck: true,
}
}
[轉]Kubernetes 调整 nodePort 端口范围
https://qhh.me/2019/08/pod 文件定义在 /etc/kubernetes/manifests/kube-apiserver.yaml15/Kubernetes-%E8%B0%83%E6%95%B4-nodePort-%E7%AB%AF%E5%8F%A3%E8%8C%83%E5%9B%B4/
在 command 下添加 --service-node-port-range=1-65535 参数,修改后会自动生效,无需其他操作:
在 command 下添加 --service-node-port-range=1-65535 参数,修改后会自动生效,无需其他操作:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
component: kube-apiserver
tier: control-plane
name: kube-apiserver
namespace: kube-system
spec:
containers:
- command:
- kube-apiserver
- --service-node-port-range=1-65535
- --advertise-address=192.168.26.10
- --allow-privileged=true
- --authorization-mode=Node,RBAC
- --client-ca-file=/etc/kubernetes/pki/ca.crt
- --enable-admission-plugins=NodeRestriction
- --enable-bootstrap-token-auth=true
- --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt
- --etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt
- --etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key
- --etcd-servers=https://127.0.0.1:2379
- --insecure-port=0
- --kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt
- --kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt
- --proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key
- --requestheader-allowed-names=front-proxy-client
- --requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt
- --requestheader-extra-headers-prefix=X-Remote-Extra-
- --requestheader-group-headers=X-Remote-Group
- --requestheader-username-headers=X-Remote-User
- --secure-port=6443
- --service-account-key-file=/etc/kubernetes/pki/sa.pub
- --service-cluster-ip-range=10.96.0.0/12
- --tls-cert-file=/etc/kubernetes/pki/apiserver.crt
- --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
image: registry.aliyuncs.com/google_containers/kube-apiserver:v1.15.2
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 8
httpGet:
host: 192.168.26.10
path: /healthz
port: 6443
scheme: HTTPS
initialDelaySeconds: 15
timeoutSeconds: 15
name: kube-apiserver
resources:
requests:
cpu: 250m
volumeMounts:
- mountPath: /etc/ssl/certs
name: ca-certs
readOnly: true
- mountPath: /etc/pki
name: etc-pki
readOnly: true
- mountPath: /etc/kubernetes/pki
name: k8s-certs
readOnly: true
hostNetwork: true
priorityClassName: system-cluster-critical
volumes:
- hostPath:
path: /etc/ssl/certs
type: DirectoryOrCreate
name: ca-certs
- hostPath:
path: /etc/pki
type: DirectoryOrCreate
name: etc-pki
- hostPath:
path: /etc/kubernetes/pki
type: DirectoryOrCreate
name: k8s-certs
status: {}
k8s kubernetes Lesson 8 Error
Error: User "system:serviceaccount:kube-system:default" cannot get resource "namespaces"
https://github.com/fnproject/fn-helm/issues/21#issuecomment-545317241
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
helm init --upgrade --service-account tiller
docker registry Other Way
On root home
openssl req -nodes -newkey rsa:4096 -keyout certs/docker-registry.key -out certs/docker-registry.csr -subj "/C=/ST=/L=/O=/OU=/CN=docker-registry"
openssl x509 -req -sha256 -days 365 -in certs/docker-registry.csr -signkey certs/docker-registry.key -out certs/docker-registry.crt
docker run -dp 5000:5000 --name registry -v "$(pwd)"/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/docker-registry.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/docker-registry.key \
registry
nano /etc/hosts
> 192.168.99.118 docker-registry
cd /etc/docker
mkdir certs.d
cd certs.d
mkdir docker-registry:5000
cd docker-registry:5000
cp ~/certs/docker-registry.crt ca.crt
===== check registry is working
docker image pull busybox
docker image tag busybox docker-registry:5000/mybusybox
docker image push docker-registry:5000/mybusybox
docker run --rm docker-registry:5000/mybusybox echo "Hello from busybox"
//
docker rmi busybox docker-registry:5000/mybusybox
docker run --rm docker-registry:5000/mybusybox echo "Hello from busybox"
===== remove registry
docker container stop registry && docker container rm -v registry
https://jkzhao.github.io/2017/09/01/Registry%E7%A7%81%E6%9C%89%E4%BB%93%E5%BA%93%E6%90%AD%E5%BB%BA%E5%8F%8A%E8%AE%A4%E8%AF%81/
列出私有仓库中的所有镜像
curl -k -X GET https://docker-registry:5000/v2/_catalog >> {"repositories":["mybusybox"]}
curl --cacert certs/docker-registry.crt https://docker-registry:5000/v2/_catalog
curl -k https://docker-registry:5000/v2/_catalog
Hyperledger Hurley is the development environment toolset
https://github.com/worldsibu/hurley#readme
[轉]Hyperledger Composer is deprecated
https://hackernoon.com/hyperledger-composer-is-deprecated-kuzqu31cb
Hyperledger KC Tam
https://medium.com/@kctheservant
http://www.ledgertech.biz/kcarticles.html
===========
https://hyperledger-fabric.readthedocs.io/en/release-1.4/tutorials.html
http://www.ledgertech.biz/kcarticles.html
===========
https://hyperledger-fabric.readthedocs.io/en/release-1.4/tutorials.html
[轉]Hyperledger Fabric BYFN之配置進階篇
https://www.itread01.com/content/1550412200.html
byfn.sh down會呼叫networkdDown去銷燬整個網路和已生成的配置。byfn.sh restart則不會清理。
...........
注意
docker-compose down會停止和刪除容器,網路,映象和對映的卷。
只是停止服務的話的會最好使用docker-compose stop。
docker-compose up則是建立和啟動容器服務, 這裡用於啟動。
我們也可以參考例子fabric-samples/fabcar, 它會重用fabric-samples/basic-network中的start.sh, stop.sh允許停止和重啟。
這自然是有的,但是必須開啟orderer, peer等的持久化配置。
...........
7051是Peer啟動的gRPC, 一般是客戶端應用接入。
7053是事件埠(Peer Event)
..........
Fabric 1.1之後peer event做了完全不同的設計,訊息的監聽不在peer節點了,而是基於channel,這樣設計提供了對Peer資料更細粒度的採訪控制和提供了接收訊息的可靠性。(官方文件是這麼扯,我也有點疑惑) 主要提供兩種服務,Deliver(通知提交到記賬本的整個區塊內容) 和DeliverFiltered(過濾一些區塊減少訊息通知返回的區塊大小)
1. byfn.sh up down會清理所有容器映象,生成的配置檔案和證書,現實場景應該可以停止或恢復區塊鏈網路,該如何處理?
byfn.sh down會呼叫networkdDown去銷燬整個網路和已生成的配置。byfn.sh restart則不會清理。
...........
注意
docker-compose down會停止和刪除容器,網路,映象和對映的卷。
只是停止服務的話的會最好使用docker-compose stop。
docker-compose up則是建立和啟動容器服務, 這裡用於啟動。
我們也可以參考例子fabric-samples/fabcar, 它會重用fabric-samples/basic-network中的start.sh, stop.sh允許停止和重啟。
2. byfn.sh還是fabcar兩個例子即使重啟區塊鏈網路,通道需要創新建立,節點需要重新加入通道,鏈碼也要全要重新安裝,如果節點多維護起來就麻煩且費時,重啟的時候能讓通道,節點,鏈碼,State DB自動恢復?
這自然是有的,但是必須開啟orderer, peer等的持久化配置。
...........
orderer.example.com:
...
- /mnt/hyperledger/orderer:/var/hyperledger/production/orderer
peer0.org1.example.com:
...
- /mnt/hyperledger/org1/peer0:/var/hyperledger/production
couchdb:
...
- /mnt/hyperledger/couchdb:/opt/couchdb/data
4. Peer節點我們配置了兩個埠,配置用來做什麼?
ports:
- 7051:7051
- 7053:7053
7051是Peer啟動的gRPC, 一般是客戶端應用接入。
7053是事件埠(Peer Event)
..........
Fabric 1.1之後peer event做了完全不同的設計,訊息的監聽不在peer節點了,而是基於channel,這樣設計提供了對Peer資料更細粒度的採訪控制和提供了接收訊息的可靠性。(官方文件是這麼扯,我也有點疑惑) 主要提供兩種服務,Deliver(通知提交到記賬本的整個區塊內容) 和DeliverFiltered(過濾一些區塊減少訊息通知返回的區塊大小)
Docker 本身DNS是不穩定的
再分享早上碰到docker穩定度問題,docker內到外網是靠本機的iptables做Nat出去,早上就發現運行很久的docker container,突然不送資料到ELK,一查發現DNS掛了,這之前也碰到幾次了,基本上不是中心DNS掛了,而且Docker本身架構的DNS掛了,基本上只要重啟docker service後就正常,無需對主機重啟,而重啟docker service是一件很嚴重的事情,因為上面所有的服務都會一併被下線,之後還要在把運行的服務全部重新上線…
也許我的理解是錯誤,但只能以目前的情況來判斷,也許是iptables nat轉換的問題,但本機沒有重開機,理論上就沒有這個問題才是。
也許我的理解是錯誤,但只能以目前的情況來判斷,也許是iptables nat轉換的問題,但本機沒有重開機,理論上就沒有這個問題才是。
[轉]What's New in Ethereum Serenity (2.0)
http://kimiwublog.blogspot.com/2018/12/whats-new-in-ethereum-serenity-20.html
需注意,時間是2018/12/06 內容肯不會是最正確的
需注意,時間是2018/12/06 內容肯不會是最正確的
[DIY] HyperLedger
1. Use docker-machine crate docker vm.
And install docker-compose.2. https://github.com/hyperledger/fabric-samples
# Fetch bootstrap.sh from fabric repository using
curl -sS https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh -o ./scripts/bootstrap.sh
# Change file mode to executable
chmod +x ./scripts/bootstrap.sh
# Download binaries and docker images
#./scripts/bootstrap.sh [version] [ca version] [thirdparty_version]
./scripts/bootstrap.sh
Here use all default value.
3. https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html
# Start Run
cd fabric-samples/first-network
./byfn.sh generate
./byfn.sh up
4. Hope you see
===================== Query successful on peer1.org2 on channel 'mychannel' ============================== All GOOD, BYFN execution completed ===========
5. check docker ps Need like this
PS:
1. See Error
2019-11-06 02:22:34.819 UTC [main] InitCmd -> ERRO 001 Cannot run peer because cannot init crypto, folder "/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" does not exist
!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========
How to Fix
cd fabric-samples/first-network
./byfn.sh down
./byfn.sh generate #This maybe don't need
./byfn.sh up
6. How to querying chaincode again
https://learnblockchain.cn/2019/07/03/chaincode-run/
docker exec -it cli bash
root@73e65944cade:/opt/gopath/src/github.com/hyperledger/fabric/peer>
root@73e65944cade:/opt/gopath/src/github.com/hyperledger/fabric/peer> peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
# peer chaincode query This command come from e2etest that you first time See This message:
========= All GOOD, BYFN execution completed ===========
Then just find screen up, can see "peer chaincode query ooxxooxxooxx". Please copy it then use in here.
[轉]SSLH 是一款采用 C 语言编写的开源端口复用软件,目前支持 HTTP、SSL、SSH、OpenVPN、Tinc、XMPP 等多种协议识别
https://mp.weixin.qq.com/s/sHitMzs8KXXO6joX8QqO_A?fbclid=IwAR1UGD7gemvKRY-IkOCEHGDru6YLDkI2vXojKpLTc-AZ4gN2Zz849YwJKZ8
SSLH 是一款采用 C 语言编写的开源端口复用软件,目前支持 HTTP、SSL、SSH、OpenVPN、Tinc、XMPP 等多种协议识别。它主要运行于 *nix 环境,源代码托管在 GitHub 上。
项目地址:https://github.com/yrutschle/sslh
更简单地说,SSLH 允许我们在 Linux 系统上的同一端口上运行多个程序/服务。因此,您可以用同一端口来同时使用两种服务。如果你遇到大多数端口被防火墙阻止的情况,SSLH 就可以帮你派上大用场。下面我们就来看一个 SSL 和 SSH 同时复用同一端口的实例。
SSLH 是一款采用 C 语言编写的开源端口复用软件,目前支持 HTTP、SSL、SSH、OpenVPN、Tinc、XMPP 等多种协议识别。它主要运行于 *nix 环境,源代码托管在 GitHub 上。
项目地址:https://github.com/yrutschle/sslh
更简单地说,SSLH 允许我们在 Linux 系统上的同一端口上运行多个程序/服务。因此,您可以用同一端口来同时使用两种服务。如果你遇到大多数端口被防火墙阻止的情况,SSLH 就可以帮你派上大用场。下面我们就来看一个 SSL 和 SSH 同时复用同一端口的实例。
[轉][Flutter]还在大量使用TextEditingController?试试这种解决方案
当用户输入大量信息时,通常会采用TextField列表来解决,这时如果需要对每个TextField进行控制或监听就需要大量的TextEditingController。
这里提供另一种思路,解决大量使用TextEditingController和信息整理困难的问题。
定义一个Map:
Map _userInfo;
这个Map作用于所有需要收集用户信息的地方。
使用TextField时这样操作:
这里全程未单独定义TextEditingController,只使用TextField默认的方法进行控制,且可以获得以下好处:
1.节省大量代码,简化业务逻辑。
2.用户输入完成时即得到一个包含所有信息的Map。
3.输入的内容不会丢失,只要这个Map不被销毁,下次进入(或返回)这个页面时所有内容都在,不用要求用户再次输入,提升用户体验。
第一次发文章,如有问题,欢迎指正。
作者:xSILENCEx
链接:https://juejin.im/post/5d649bfce51d453b1d648314
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
这里提供另一种思路,解决大量使用TextEditingController和信息整理困难的问题。
定义一个Map:
Map
这个Map作用于所有需要收集用户信息的地方。
使用TextField时这样操作:
////邮箱
TextField(
controller: TextEditingController(text: _userInfo['account']),
onChanged: (value) {
_userInfo['account'] = value;
},
),
////昵称
TextField(
controller: TextEditingController(text: _userInfo['nickname']),
onChanged: (value) {
_userInfo['nickname'] = value;
},
),
////密码
TextField(
controller: TextEditingController(text: _userInfo['password']),
onChanged: (value) {
_userInfo['password'] = value;
},
),
这里全程未单独定义TextEditingController,只使用TextField默认的方法进行控制,且可以获得以下好处:
1.节省大量代码,简化业务逻辑。
2.用户输入完成时即得到一个包含所有信息的Map。
3.输入的内容不会丢失,只要这个Map不被销毁,下次进入(或返回)这个页面时所有内容都在,不用要求用户再次输入,提升用户体验。
第一次发文章,如有问题,欢迎指正。
作者:xSILENCEx
链接:https://juejin.im/post/5d649bfce51d453b1d648314
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
dart null list
減少null判斷情況
https://stackoverflow.com/questions/51036758/flutter-the-method-map-was-called-on-null
https://juejin.im/post/5c6d38b1f265da2dcc7feb69
https://cloud.tencent.com/developer/article/1370380
?? => if null
https://blog.csdn.net/ffa_ijj/article/details/85051156
這個判斷方式有個問題,當查詢回來為[],不是null情況下,在.first會出錯,因為 "No element"會出錯,但.toList()會正確,故改回
https://stackoverflow.com/questions/51036758/flutter-the-method-map-was-called-on-null
https://juejin.im/post/5c6d38b1f265da2dcc7feb69
https://cloud.tencent.com/developer/article/1370380
?? => if null
https://blog.csdn.net/ffa_ijj/article/details/85051156
return qres?.map((value) {
LinkedHashMap result = json.decode(value["jsonitem"]);
return result;
})?.first ?? new LinkedHashMap();
這個判斷方式有個問題,當查詢回來為[],不是null情況下,在.first會出錯,因為 "No element"會出錯,但.toList()會正確,故改回
if (qres == null || qres.isEmpty) return new Member(); // 待確定是否出錯
var resmap = qres.first;
return new Member.fromJson(json.decode(resmap["jsonitem"]));
訂閱:
文章 (Atom)
