Skip to content

Commit

Permalink
change theme papermod
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-Kai committed Jan 12, 2023
1 parent 65883cb commit 5b7f4ba
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 63 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: blog deploy pipline
on:
push:
tags:
- '*'
branches: [ main ]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{github.repository}}

jobs:
build:
runs-on: ubuntu-latest
concurrency:
group: ${{github.workflow}} - ${{github.ref}}
steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0
- name: setup hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.92.0'
extended: true
- name: build
run: hugo --minify

- name: deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{github.ref == 'refs/heads/main'}}
with:
github_token: ${{secrets.GITHUB_TOKEN}}
publish_dir: ./public
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ baseURL = "https://chi-kai.github.io"
disqusShortname = "ck"
hasCJKLanguage = true
languageCode = "zh-cn"
theme = "tokiwa"
theme = "PaperMod"
title = "悉达多"
googleAnalytics = "G-CWBXLVG90W"

Expand Down
5 changes: 2 additions & 3 deletions content/post/Raft论文阅读.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ toc: true
```

3. 当收到一个更高term的回复RPC,Candidate转变为Follower,term变为更高的term,投票变为null。
4. 当收到一个更高的term的心跳时,状态转变为Follower,
term变为更高的term,投票变为null。
4. 当收到一个更高的term的心跳时,状态转变为Follower,term变为更高的term,投票变为null。
5. 节点在两种情况拒绝投票,一是Candidate的term小于自己,二是自己在本term中已经投过票。
```golang
if rf.currentTerm > args.Term ||
Expand Down Expand Up @@ -101,7 +100,7 @@ leader 只能发送日志给follower,而不能从follower接收日志,所以

![幽灵复现](http://tva1.sinaimg.cn/large/008upJWily1h7oklyiaigj30ue0vaww7.jpg)

在上图中,raft 为了避免出现一致性问题,要求 leader 绝不会提交过去的 term 的 entry (即使该 entry 已经被复制到了多数节点上)。leader 永远只提交当前 term 的 entry, 过去的 entry 只会随着当前的 entry 被一并提交。(上图中的 c,term2 只会跟随 term4 被提交。)
在上图中,raft 为了避免出现一致性问题,要求 leader 绝不会提交过去的 term 的 entry (即使该 entry 已经被复制到了多数节点上)。leader 永远只提交当前 term 的 entry,过去的 entry 只会随着当前的 entry 被一并提交。(上图中的 c,term2 只会跟随 term4 被提交。)

如果一个 candidate 能取得多数同意,说明它的日志已经是多数节点中最完备的, 那么也就可以认为该 candidate 已经包含了整个集群的所有 committed entries。

Expand Down
4 changes: 3 additions & 1 deletion content/post/Redis源码剖析-一.md
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ unsigned char *ziplistNew(void) {
```
#### 插入元素


1. 编码。计算previous_entry_length字段、encoding字段和content字段的内容。

## 字典

Expand Down Expand Up @@ -1087,3 +1087,5 @@ unsigned long long dictFingerprint(dict *d) {
3.

#### 安全迭代器

##
23 changes: 23 additions & 0 deletions content/post/区块链学习-eth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: "区块链学习--Eth"
date: 2022-12-11T10:45:48+08:00
draft: true
---

## 账户模型

BTC系统是***基于交易**的账本,系统中并未显示记录账户有多少钱,只能通过UTXO进行推算。

以太坊系统则采用了**基于账户的模型**,与现实中银行账户相似。系统中显示记录每个账户以太币的数量,转账是否合法只需要查看转账者账户中以太币是否足够即可,同时也不需要每次全部转账。同时,这也也天然地防范了双花攻击。当然,以太坊发这种模式也存在缺点,这种模式存在重放攻击的缺陷。A向B转账,过一段时间,B将A的交易重新发布,从而导致A账户被扣钱两次。

为了防范重放攻击,给账户交易添加计数器记录该账户交易过多少次,转账时候将转账次数计入交易的内容中。 系统中全节点维护账户余额和该计数器的交易数,从而防止本地篡改余额或进行重放攻击。

以太坊系统中存在两类账户:外部账户和合约账户。

1. 外部账户:类似于BTC系统中公私钥对。存在账户余额balance和计数器nonce
2. 合约账户:并非通过公私钥对控制。(不能主动发起交易,只能接收到外部账户调用后才能发起交易或调用其他合约账户)其除了balance和nonce之外还有code(代码)、storage(相关状态-存储)创建合约时候会返回一个地址,就可以对其调用。调用过程中,代码不变但状态会发生改变。

为什么要做以太坊,更换为基于账户的模型而不是沿袭BTC系统? 比特币中支持每次更换账户,但以太坊是为了支持
智能合约,而合约签订双方是需要明确且较少变化的。尤其是对于合约账户来说,需要保持稳定状态。

## 数据结构
Loading

0 comments on commit 5b7f4ba

Please sign in to comment.