common

package
v0.0.0-...-b8150c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PrivateKey []byte
	PublicKey  []byte
)
View Source
var Blockchains = make(chan Block, 100000)
View Source
var Tx100 []Transaction

Functions

func GetKeyPair

func GetKeyPair() (prvkey, pubkey []byte)

生成本节点的公私钥

func Init

func Init()

func TransToByte

func TransToByte(trans []Transaction) [][]byte

Types

type Block

type Block struct {
	Index     int    `db:bIndex`
	Timestamp string `db:Timestamp`
	PrevHash  string `db:Prevhash`
	Merkle    string `db:Merkle`
	Signature string `db:Signature`
	Hash      string `db:Hash`
	TX        []Transaction
}
var B Block

func GenerateBlock

func GenerateBlock(oldBlock Block, newBlock Block) Block

create a new block using previous block's hash

func (*Block) GenerateMerkelRoot

func (b *Block) GenerateMerkelRoot() string

type BlockHeader

type BlockHeader struct {
	Index     int    `db:bIndex`
	Timestamp string `db:Timestamp`
	BPM       int    `db:BPM`
	Hash      string `db:Hash`
	PrevHash  string `db:Prevhash`
	Merkle    string
}

type BlockMsg

type BlockMsg struct {
	Bc   Block
	Sign []byte
	Pk   []byte
}

type MerkleNode

type MerkleNode struct {
	Left  *MerkleNode
	Right *MerkleNode
	Data  []byte
}

MerkleNode represent a Merkle tree node

func NewMerkleNode

func NewMerkleNode(left, right *MerkleNode, data []byte) *MerkleNode

NewMerkleNode creates a new Merkle tree node

type MerkleTree

type MerkleTree struct {
	RootNode *MerkleNode
}

MerkleTree represent a Merkle tree

func NewMerkleTree

func NewMerkleTree(data [][]byte) *MerkleTree

NewMerkleTree creates a new Merkle tree from a sequence of data

type Transaction

type Transaction struct {
	From      string
	To        string
	Timestamp string
	Signature string
	Message   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL