accumulator

package
v0.0.0-...-d221e65 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Router keeps track of all the chains in flight. It routes transactions to the right chain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain struct {
	MR    [][]byte   // Array of hashes that represent the right edge of the Merkle tree
	Txs   HashStream // stream of hashes going into the Merkle tree
	Mux   sync.Mutex // Allow the chain to be locked when closing
	Count int64      // How many hashes we have processed.
}

Structure for accepting hashes to go into a chain.

func (*Chain) AddToMR

func (c *Chain) AddToMR(hash []byte)

Add a Hash to a building Merkle Tree

func (*Chain) CloseMR

func (c *Chain) CloseMR() []byte

CloseMR Pad the rest of the inputs into the Merkle tree until we match a power of two.

func (*Chain) Run

func (c *Chain) Run(txs HashStream)

go routine that pulls transactions out of the hashstream and pushes them into adding to the Merkle tree

type ChainAcc

type ChainAcc struct {
	// contains filtered or unexported fields
}

type HashStream

type HashStream chan []byte

type Router

type Router struct {
	Mux sync.Mutex
	// contains filtered or unexported fields
}

func (*Router) AddTx

func (r *Router) AddTx(chainId [32]byte, hash []byte)

AddTx Add a TX to its chain. Allocates a chain if one does not exist.

func (*Router) CloseAll

func (r *Router) CloseAll() (chains int64, count int64, pending int64)

CloseAll Close all the accumulators and sum up the results, and pass results back to caller.

func (*Router) Init

func (r *Router) Init()

We create an initial Map to track the chains we are writing to.

Jump to

Keyboard shortcuts

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