Documentation
¶
Overview ¶
utxo数据库创建的意义在于,不会每次进行转帐时遍历整个区块链, 而是去utxo数据库查找未消费的交易输出,这样会大大降低性能问题
Index ¶
- Constants
- Variables
- func CreateBitcoinKeysByMnemonicWord(mnemonicWord []string) *bitcoinKeys
- func GetAddressFromPublicKey(publickey []byte) string
- func GetAddressFromPublicKeyHash(publickeyHash []byte) string
- func GetAllAddress(bd *database.BlockchainDB) *addressList
- func IsVaildBitcoinAddress(address string) bool
- func NewBitcoinKeys(nothing []string) *bitcoinKeys
- func NewBlockchain() *blockchain
- func NewBlockchainIterator(bc *blockchain) *blockchainIterator
- func NewProofOfKill(block *Block) *proofOfKill
- func NewProofOfWork(block *Block) *proofOfWork
- func NewWallets(bd *database.BlockchainDB) *wallets
- type Block
- type Sender
- type TXInput
- type TXOutput
- type Transaction
- type UTXO
- type UTXOHandle
Constants ¶
View Source
const ADDR_LIST_KEY = "addressList"
钱包地址在数据库中的键
View Source
const CHECKSUM = 4
两次sha256(公钥hash)后截取的字节数量
View Source
const DEATH_PUNISHMENT = 200
death in a duel delays agent movement for this value in millisecond. 1 second = 1000 millisecond
View Source
const GENESIS_SEED int64 = 8601066706715
random seed used in genesis block
View Source
const LATEST_BLOCK_HASH_KEY = "lastHash"
最新区块Hash在数据库中的键
View Source
const MAXINT = math.MaxInt64
随机数不能超过的最大值
View Source
const REWARD_ADDR_KEY = "rewardAddress"
奖励地址在数据库中的键
View Source
const VERSION = byte(0x00)
公链版本信息默认为0
Variables ¶
View Source
var LISTEN_PORT string
当前本地监听端口
View Source
var MNWORD_PATH string
中文助记词地址
View Source
var NEWEST_BLOCK_HEIGHT int
当前节点发现的网络中最新区块高度
View Source
var NEWEST_BLOCK_KILL uint64
当前节点发现的网络中最新区块高度
View Source
var REWARD_AMOUNT int
挖矿奖励代币数量
View Source
var ROUND_BIT uint64
determine how many rounds of duel must be faught
View Source
var VERIFY_BIT uint64
Functions ¶
func CreateBitcoinKeysByMnemonicWord ¶
func CreateBitcoinKeysByMnemonicWord(mnemonicWord []string) *bitcoinKeys
根据助记词创建公私钥
func GetAddressFromPublicKeyHash ¶
通过公钥信息获得地址
func NewBlockchainIterator ¶
func NewBlockchainIterator(bc *blockchain) *blockchainIterator
获取区块迭代器实例
Types ¶
type Block ¶
type Block struct { //hash of the provious block PreHash []byte Transactions []Transaction TimeStamp int64 Height int //hash of this block Hash []byte //for verification Agent agent.Agent //recording wins or loses for mining fights Proof []bool //how many kills this block includes Kill uint64 }
func (*Block) Deserialize ¶
type Sender ¶
type Sender interface { SendVersionToPeers(height int, kill uint64) SendTransToPeers(tss []Transaction) }
用于network包向对等节点发送信息
type Transaction ¶
交易列表信息
type UTXOHandle ¶
type UTXOHandle struct {
BC *blockchain
}
func (*UTXOHandle) Synchrodata ¶
func (u *UTXOHandle) Synchrodata(tss []Transaction)
传入交易信息,将交易里的输出添加进utxo数据库,并剔除输入信息
Click to show internal directories.
Click to hide internal directories.