区块链接触总结[未完成]

要了解一样事物就必须接近它,之前只是浅显的知道它程序的实现方式,但对于运行机制了解不太够

运行原理

实验过程

本人使用k8s环境进行实验

#####环境构建#####
#下载bitcore
wget https://bitcoin.org/bin/bitcoin-core-0.20.1/bitcoin-0.20.1-x86_64-linux-gnu.tar.gz
#使用dockerhub镜像运行一个centos pod,并先退出
kubectl run centos --image=jieshao/centos:fast  -it --command -- bash|exit
#将bitcoin导入centos pod 的 /opt目录
kubectl cp bitcoin-0.20.1-x86_64-linux-gnu.tar.gz centos:/opt
#进入centos pod 进行实验
kubectl attach centos -c centos -it
#####配置bitcore#####
cd /opt #进入目录
tar xf bitcoin-0.20.1-x86_64-linux-gnu.tar.gz #解压bitcoin
cd bitcoin-0.20.1/bin/ #进入bitcoin bin目录
###写入节点master配置,虽然去中心化但是还是需要有一个标准
mkdir master
cat << EOF > master/bitcoin.conf
regtest=1
dnsseed=0
upnp=0

server=1

[regtest]
port=18000
rpcport=19000

rpcuser=master
rpcpassword=123
EOF
#启动master节点
./bitcoind -datadir=master -daemon
#定义master管理命令
alias master='./bitcoin-cli -datadir=master '
#获取连接节点
master getpeerinfo
###写入节点node1配置
mkdir node1
cat << EOF > node1/bitcoin.conf
regtest=1
dnsseed=0
upnp=0

server=1

[regtest]
listen=0
connect=127.0.0.1:18000
port=18001
rpcport=19001

rpcuser=node1
rpcpassword=123
EOF
#启动node1节点
./bitcoind -datadir=node1 -daemon
#定义node1管理命令
alias node1='./bitcoin-cli -datadir=node1'
#获取连接节点
node1 getpeerinfo
#####实际操作#####
获取节点采矿信息
[root@centos bin]# master getmininginfo
{
  "blocks": 0,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 0,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}
#获取区块总数
[root@centos bin]# master getblockcount 
0
#查看钱包金额数
[root@centos bin]# master getbalance
0.00000000
[root@centos bin]# node1 getbalance
0.00000000
#生成地址
[root@centos bin]# master getnewaddress "jieshao"
bcrt1qm439mzdh3yz6agsx9f2fn80lzgjsxts55rfjgn
[root@centos bin]# node1 getnewaddress "jie"
bcrt1qqprth6kz7qhc58fuky6memtj6s7nerg2pgq0hs
#挖矿(生成区块)
#给jieshao的地址生成200个区块(前100个区块没有奖励)
[root@centos bin]# node1 generatetoaddress 1 bcrt1qm439mzdh3yz6agsx9f2fn80lzgjsxts55rfjgn
#查看区块信息
[root@centos bin]# master getblockchaininfo
{
  "chain": "regtest",
  "blocks": 200,#区块总数
  "headers": 200,
  "bestblockhash": "77589c9b931f4255ccc839bde37610ac372c5e92be11a87dd2fcba9ffb835a82",
  "difficulty": 4.656542373906925e-10,
  "mediantime": 1610172272,
  "verificationprogress": 1,
  "initialblockdownload": false,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000000192",
  "size_on_disk": 60150,
  "pruned": false,
  "softforks": {
    "bip34": {
      "type": "buried",
      "active": false,
      "height": 500
    },
    "bip66": {
      "type": "buried",
      "active": false,
      "height": 1251
    },
    "bip65": {
      "type": "buried",
      "active": false,
      "height": 1351
    },
    "csv": {
      "type": "buried",
      "active": false,
      "height": 432
    },
    "segwit": {
      "type": "buried",
      "active": true,
      "height": 0
    },
    "testdummy": {
      "type": "bip9",
      "bip9": {
        "status": "started",
        "bit": 28,
        "start_time": 0,
        "timeout": 9223372036854775807,
        "since": 144,
        "statistics": {
          "period": 144,
          "threshold": 108,
          "elapsed": 57,
          "count": 57,
          "possible": true
        }
      },
      "active": false
    }
  },
  "warnings": ""
}
#我手滑又生成了100个区块
[root@centos bin]# master getmininginfo
{
  "blocks": 300,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 0.1043932144410613,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}
#查看比特币总数
[root@centos bin]# node1 getbalances
{
  "mine": {
    "trusted": 8725.00000000,#已信赖比特币,属于不同的人
    "untrusted_pending": 0.00000000,
    "immature": 2487.50000000 #不成熟的比特币,暂时不属于任何人
  }
}
[root@centos bin]# master getbalance
8725.00000000
[root@centos bin]# node1 getbalance
0.00000000
#发送bitcoin
[root@centos bin]# master sendtoaddress bcrt1qqprth6kz7qhc58fuky6memtj6s7nerg2pgq0hs 8725
error code: -4
error message:
Fee estimation failed. Fallbackfee is disabled. Wait a few blocks or enable -fallbackfee.
#查看
[root@centos bin]# master getbalance
8725.00000000
[root@centos bin]# master getbalances
{
  "mine": {
    "trusted": 8725.00000000,
    "untrusted_pending": 0.00000000,
    "immature": 2487.50000000
  }
}
#交易未完成

存在的问题(个人不太看好)

  1. 新加入的节点都需要从头同步区块,耗时耗能量,并且随着时间推移区块越来越大2009区块创世以来到2020年已经多达100多G,是一大阻碍,入门困难,大多数炒币的都是通过交易所降低门槛(但这带来了风险),交易慢需要等待区块确认,始终需要算力支持,如果没有人挖矿,那么交易就无法进行。
  2. 基于数学信任的货币,一旦数学信任崩塌,或者大势(人的群体信任)崩塌将不值一文
  3. 本质上是一次去中心化的货币实验,既然是实验,风险就很高。

参考资料

描述来源
加密相关非对称加密 中的 椭圆曲线数字签名算法(ECDSA)
对称加密 中的 AES算法
base58
背景诱因2008年金融危机(金融可以说是一种信用体系,当信任崩塌人们寻求另一种信任模式),去中心(在金融危机中指漂亮国的银行,记账的中心)化的基于密码学信任的数字货币
源头p2pfoundation博客,所谓的论文没发在各大数据库里,而是在他开发的网站【www.bitcoin.org】里
2008年10月31日论文撰写的时候是发在metzdowd中
概念百度百科-区块链(区块链是比特币的区块存储模式,特殊的数据库) 百度百科-比特币
比特币论文原版 谷歌学术白皮书 中文版 其他翻译版
bitcore操作link
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值