carbonchain

package module
v0.0.0-...-c88584e Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2017 License: MIT Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Carbonchain Library

Use bitcoin blockchain as a network layer to propagate "packets".

Authors

  • Faruq Rasid - Initial work - ruqqq

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • TO BE UPDATED

Documentation

Index

Constants

View Source
const (
	LOG_LEVEL_VERBOSE = iota
	LOG_LEVEL_INFO    = iota
	LOG_LEVEL_DEBUG   = iota
	LOG_LEVEL_ERROR   = iota
)
View Source
const BITCOIN_BTC_DUST float32 = 0.00001
View Source
const OP_RETURN_MAX_BLOCKS int = 64
View Source
const OP_RETURN_MAX_BYTES int = 80
View Source
const PACKET_HEADER_SIZE int = 20

Variables

View Source
var MAX_WORKERS = os.Getenv("MAX_WORKERS")

Functions

func Store

func Store(data []byte, packetId byte, btcFee float64, options *rpc.RpcOptions) ([]string, error)

Types

type BlockMeta

type BlockMeta struct {
	FileNum  uint32                   `struc:"little"`
	Pos      uint64                   `struc:"little"`
	HashPrev blockchainparser.Hash256 `struc:"little,[32]byte"`
}

type BlockScanRequest

type BlockScanRequest struct {
	Index         int
	BlockStartPos int64
	FileNum       uint32
}

type BlockScanResult

type BlockScanResult struct {
	Index int
}

type BlockScanWorker

type BlockScanWorker struct {
	JobChannel    chan BlockScanRequest
	ResultChannel chan BlockScanResult
	// contains filtered or unexported fields
}

func NewBlockScanWorker

func NewBlockScanWorker(cc *CarbonChain, jobChannel chan BlockScanRequest, resultChannel chan BlockScanResult) *BlockScanWorker

func (*BlockScanWorker) Start

func (w *BlockScanWorker) Start()

func (*BlockScanWorker) Stop

func (w *BlockScanWorker) Stop()

type CarbonChain

type CarbonChain struct {
	Options  *CarbonChainOptions
	BlockDb  *bolt.DB
	ChainDb  *bolt.DB
	CarbonDb *bolt.DB
	// contains filtered or unexported fields
}

func NewCarbonChain

func NewCarbonChain(blockDb *bolt.DB, chainDb *bolt.DB, carbonDb *bolt.DB, options *CarbonChainOptions) (*CarbonChain, error)

func NewCarbonChainWithDb

func NewCarbonChainWithDb(options *CarbonChainOptions) (*CarbonChain, error)

func (*CarbonChain) Close

func (cc *CarbonChain) Close()

func (*CarbonChain) GetBlock

func (cc *CarbonChain) GetBlock(hash []byte) (*blockchainparser.Block, error)

func (*CarbonChain) GetBlockAtHeight

func (cc *CarbonChain) GetBlockAtHeight(height int) (*blockchainparser.Block, error)

func (*CarbonChain) GetBlockConfirmation

func (cc *CarbonChain) GetBlockConfirmation(hash []byte) (int, error)

func (*CarbonChain) GetBlockHashAtHeight

func (cc *CarbonChain) GetBlockHashAtHeight(height int) ([]byte, error)

func (*CarbonChain) GetBlockchainHeight

func (cc *CarbonChain) GetBlockchainHeight() (int, error)

func (*CarbonChain) GetNextBlockInChain

func (cc *CarbonChain) GetNextBlockInChain(hash []byte) (*blockchainparser.Block, error)

func (*CarbonChain) GetNextHashInChain

func (cc *CarbonChain) GetNextHashInChain(hash []byte) ([]byte, error)

func (*CarbonChain) GetTransaction

func (cc *CarbonChain) GetTransaction(hash []byte) (*blockchainparser.Transaction, error)

func (*CarbonChain) GetTransactionBlockHash

func (cc *CarbonChain) GetTransactionBlockHash(hash []byte) ([]byte, error)

func (*CarbonChain) GetTransactionMeta

func (cc *CarbonChain) GetTransactionMeta(hash []byte) (*TransactionMeta, error)

func (*CarbonChain) Init

func (cc *CarbonChain) Init() error

func (*CarbonChain) Watch

func (cc *CarbonChain) Watch(done chan bool) error

type CarbonChainOptions

type CarbonChainOptions struct {
	Testnet      bool
	BlockMagicId blockchainparser.MagicId
	PacketId     byte
	GenesisBlock blockchainparser.Hash256
	DataDir      string
	ProcessFunc  func(cc *CarbonChain, carbonDb *bolt.DB)
	LogLevel     int
}

type Datapack

type Datapack struct {
	TxIds      []blockchainparser.Hash256
	Version    int8
	OutputAddr OutputAddr
	Data       []byte
	Timestamp  int64
}

func NewDatapackFromBytes

func NewDatapackFromBytes(data []byte) *Datapack

func (*Datapack) Bytes

func (datapack *Datapack) Bytes() []byte

type OutputAddr

type OutputAddr [20]byte

func (OutputAddr) String

func (outputAddr OutputAddr) String() string

type Packet

type Packet struct {
	Id           byte
	Version      int8
	Sequence     int16
	Checksum     PacketChecksum
	NextChecksum PacketChecksum
	Data         []byte

	// fields below only exists in db, not on blockchain
	Txid       blockchainparser.Hash256 // txId this packet was extracted from
	OutputAddr OutputAddr               // outputAddr this packet belongs to
	Timestamp  int64                    // time this packet is inserted into db
}

func NewPacketFromBytes

func NewPacketFromBytes(data []byte) *Packet

func NewPacketFromDbBytes

func NewPacketFromDbBytes(data []byte) *Packet

func (*Packet) Bytes

func (packet *Packet) Bytes() []byte

func (*Packet) CalculateChecksum

func (packet *Packet) CalculateChecksum() []byte

func (*Packet) DbBytes

func (packet *Packet) DbBytes() []byte

type PacketChecksum

type PacketChecksum [8]byte

func (PacketChecksum) String

func (packetChecksum PacketChecksum) String() string

type TransactionMeta

type TransactionMeta struct {
	FileNum   uint32                   `struc:"little"`
	BlockHash blockchainparser.Hash256 `struc:"little,[32]byte"`
	Pos       uint64                   `struc:"little"`
	Index     uint32                   `struc:"little"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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