blockchain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendTransaction

func SendTransaction(tx Transaction) error

Types

type Block

type Block struct {
	PrevBlockHash string        `json:"prevBlockHash"`
	Transactions  []Transaction `json:"transactions"`
	BlockNumber   int           `json:"blockNumber"`
	Nonce         string        `json:"nonce"`
	BlockHash     string        `json:"blockHash"`
}

Block represents a block in the blockchain.

type BlockchainResponse

type BlockchainResponse struct {
	BlockchainHeader struct {
		BlockchainLength int `json:"blockchainLength"`
	} `json:"blockchainHeader"`
	Blocks []Block `json:"blocks"`
}

BlockchainResponse represents the JSON structure of blockchain data.

type Transaction

type Transaction struct {
	Sender    string `json:"sender"`
	Recipient string `json:"recipient"`
	Amount    int    `json:"amt"`
	Nonce     string `json:"nonce"`
	Data      TxData `json:"data"`
	Timestamp string `json:"timestamp"`
	Sign      string `json:"sign"`
}

Transaction represents a transaction in a block.

func FetchBlockchain

func FetchBlockchain(timestamp string) ([]Transaction, error)

FetchDatabaseNode fetches blockchain transactions at a given timestamp.

type TxData

type TxData struct {
	Type     string            `json:"type"`
	Metadata map[string]string `json:"metadata"`
	Leaver   string            `json:"leaver,omitempty"`
}

TxData represents the transaction's data field.

Jump to

Keyboard shortcuts

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