ppcutil

package module
v0.0.0-...-64ffd16 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2015 License: ISC Imports: 17 Imported by: 0

README

ppcutil

Provides peercoin-specific convenience functions and types - a package from ppcd

Documentation

Overview

Package ppcutil provides a simple LRU cache. It is based on the LRU implementation in groupcache: https://github.com/golang/groupcache/tree/master/lru

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockUnixTime

func BlockUnixTime(block *btcutil.Block) int64

BlockUnixTime gets block timestamp in unix time

func DifficultyToTarget

func DifficultyToTarget(diff float64) (target *big.Int)

func GetNextTargetRequired

func GetNextTargetRequired(params btcnet.Params, db database.Db, last *btcutil.Block, proofOfStake bool) (compact uint32)

GetNextTargetRequired TODO(kac-) golint https://github.com/ppcoin/ppcoin/blob/v0.4.0ppc/src/main.cpp#L902

func IsBlockProofOfStake

func IsBlockProofOfStake(block *btcutil.Block) bool

IsBlockProofOfStake indicates if block is of proof of stake type

func IsMsgBlockProofOfStake

func IsMsgBlockProofOfStake(msg *btcwire.MsgBlock) bool

IsMsgBlockProofOfStake checks if MsgBlock is of proof of stake type https://github.com/ppcoin/ppcoin/blob/v0.4.0ppc/src/main.h#L962 ppc: two types of block: proof-of-work or proof-of-stake

func TargetToDifficulty

func TargetToDifficulty(bits uint32) (diff float64)

Types

type CBlkIdx

type CBlkIdx struct {
	Prev                  *CBlkIdx
	Next                  *CBlkIdx
	Height                uint32
	Mint                  uint64
	Supply                uint64
	GeneratedModifier     bool
	EntropyBit            bool
	ProofOfStake          bool
	StakeModifier         []byte
	StakeModifierChecksum []byte
	HashProofOfStake      []byte
	PrevOutHash           []byte
	PrevOutN              uint32
	StakeTime             uint32
	HashMerkleRoot        []byte
	BlockHash             []byte
	BlockTrust            []byte
	ChainTrust            []byte
}

CBlkIdx TODO(kac-) golint

func ReadCBlockIndex

func ReadCBlockIndex(blockIndexFile string) (rootIndex *CBlkIdx)

ReadCBlockIndex TODO(kac-) golint

type Cache

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

Cache is a thread-safe fixed size LRU cache.

func NewCache

func NewCache(size int) (*Cache, error)

NewCache creates an LRU cache of the given size

func (*Cache) Add

func (c *Cache) Add(key, value interface{})

Add adds a value to the cache.

func (*Cache) Get

func (c *Cache) Get(key interface{}) (value interface{}, ok bool)

Get looks up a key's value from the cache.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Purge

func (c *Cache) Purge()

Purge is used to completely clear the cache

func (*Cache) Remove

func (c *Cache) Remove(key interface{})

Remove removes the provided key from the cache.

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

RemoveOldest removes the oldest item from the cache.

Jump to

Keyboard shortcuts

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