# 廣播

### 廣播（Broadcasting）是將交易或新區塊傳遞到區塊鏈網路中所有節點的過程。這就像在一群人之間傳話——你告訴旁邊的人，他們再告訴更多人，直到所有人都知道為止。

***

## 廣播的運作方式

區塊鏈是一個 P2P（點對點）網路，沒有中央伺服器：

```
       [你的節點]
          ↓ 發送
    [鄰居節點 A] [鄰居節點 B]
      ↓     ↓       ↓      ↓
   [節點] [節點]  [節點] [節點]
      ↓     ↓       ↓      ↓
         ... 繼續傳播 ...
```

{% hint style="info" %}
**八卦協議（Gossip Protocol）**

區塊鏈使用「八卦協議」來傳播資訊。就像八卦傳播一樣，每個節點把消息告訴它認識的節點，很快全網都知道了。
{% endhint %}

***

## 什麼需要廣播？

### 1. 交易廣播

當你發送一筆交易：

1. 錢包簽署交易
2. 發送到連接的節點
3. 節點驗證後轉發給其他節點
4. 交易進入各節點的交易池
5. 等待礦工打包

### 2. 區塊廣播

當礦工挖到新區塊：

1. 礦工驗證自己的區塊
2. 廣播給所有連接的節點
3. 其他節點驗證區塊
4. 驗證通過後加入本地鏈
5. 繼續轉發給更多節點

***

## 廣播的速度

| 區塊鏈 | 平均傳播時間       |
| --- | ------------ |
| 比特幣 | 數秒內達到 90% 節點 |
| 以太坊 | 約 1-2 秒全網    |

{% hint style="success" %}
**為什麼這麼快？**

雖然是「傳話」模式，但因為網路是高度連結的，而且每個節點同時向多個節點傳播，所以指數級增長的速度非常快。
{% endhint %}

***

## 廣播的挑戰

### 1. 網路延遲

不同地區的節點收到消息的時間不同，可能導致短暫的分叉。

### 2. 頻寬限制

區塊太大會：

* 傳播更慢
* 對節點頻寬要求更高
* 可能造成網路擁塞

### 3. 節點連接數

節點連接的對等節點越多：

* 收到消息越快
* 消耗資源越多

***

## 交易卡住了？

如果你的交易廣播後一直沒被打包，可能是：

| 原因       | 解決方法          |
| -------- | ------------- |
| 手續費太低    | 使用「加速」功能提高手續費 |
| 網路擁塞     | 等待，或提高手續費     |
| 節點問題     | 換一個節點重新廣播     |
| Nonce 問題 | 檢查是否有卡住的前序交易  |

{% hint style="warning" %}
**重複廣播**

同一筆交易可以重複廣播，但這不會讓它更快被打包。區塊鏈會自動忽略重複的交易。不過，你可以廣播一筆相同 nonce 但更高手續費的交易來「取代」原本的交易。
{% endhint %}

***

## 私密交易通道

有些服務提供「私密廣播」：

* **Flashbots**：交易直接送到礦工，不進公開交易池
* **私有 mempool**：避免被搶跑（front-running）

這些服務主要用於 DeFi 交易，防止 MEV 機器人看到你的交易意圖。

***

## 延伸閱讀

* [打包](/qu-kuai-lian-ru-he-da-cheng-gong-shi/wa/da-bao.md) — 廣播後的下一步
* [驗證](/qu-kuai-lian-ru-he-da-cheng-gong-shi/wa/undefined.md) — 廣播前的必要步驟
* [交易池](https://github.com/dAAAb/Blockpedia/blob/master/blockchain-intro/mempool.md) — 交易等待的地方
* [全節點](/gei-kai-fa-zhe-de-zhi-nan/node/quan.md) — 參與廣播的節點

***

#### 參考資料

* [Bitcoin P2P Network](https://developer.bitcoin.org/devguide/p2p_network.html)
* [Ethereum Networking](https://ethereum.org/en/developers/docs/networking-layer/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.0x1.academy/qu-kuai-lian-ru-he-da-cheng-gong-shi/wa/bo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
