Documentation ¶
Index ¶
- Constants
- func CreateValidationBlock(timestamp uint64, channel, alias string, head []byte, block *bcgo.Block, ...) *bcgo.Block
- func CreateValidationEntries(timestamp uint64, node bcgo.Node, channels map[string]bool) ([]*bcgo.BlockEntry, error)
- func CreateValidationEntry(timestamp uint64, node bcgo.Node, channel string, updated uint64, head []byte) (*bcgo.BlockEntry, error)
- type ErrDifferentLiveFlag
- type ErrDuplicateBlock
- type ErrDuplicateEntry
- type ErrHashTooWeak
- type ErrMissingValidatedBlock
- type Live
- type Periodic
- func NewCentennially(node bcgo.Node, channel bcgo.Channel, listener bcgo.MiningListener) Periodic
- func NewDaily(node bcgo.Node, channel bcgo.Channel, listener bcgo.MiningListener) Periodic
- func NewDecennially(node bcgo.Node, channel bcgo.Channel, listener bcgo.MiningListener) Periodic
- func NewHourly(node bcgo.Node, channel bcgo.Channel, listener bcgo.MiningListener) Periodic
- func NewPeriodic(node bcgo.Node, channel bcgo.Channel, threshold uint64, ...) Periodic
- func NewWeekly(node bcgo.Node, channel bcgo.Channel, listener bcgo.MiningListener) Periodic
- func NewYearly(node bcgo.Node, channel bcgo.Channel, listener bcgo.MiningListener) Periodic
- type PoW
- type Unique
Examples ¶
Constants ¶
View Source
const ( PERIOD_HOURLY = time.Hour PERIOD_DAILY = PERIOD_HOURLY * 24 PERIOD_WEEKLY = PERIOD_HOURLY * 168 // (24 * 7) PERIOD_YEARLY = PERIOD_HOURLY * 8766 // (24 * 365.25) PERIOD_DECENNIALLY = PERIOD_HOURLY * 87660 // (24 * 365.25 * 10) PERIOD_CENTENNIALLY = PERIOD_HOURLY * 876600 // (24 * 365.25 * 100) THRESHOLD_PERIOD_HOUR = bcgo.THRESHOLD_F THRESHOLD_PERIOD_DAY = bcgo.THRESHOLD_E THRESHOLD_PERIOD_WEEK = bcgo.THRESHOLD_D THRESHOLD_PERIOD_YEAR = bcgo.THRESHOLD_C THRESHOLD_PERIOD_DECADE = bcgo.THRESHOLD_B THRESHOLD_PERIOD_CENTURY = bcgo.THRESHOLD_A )
Variables ¶
This section is empty.
Functions ¶
func CreateValidationBlock ¶
func CreateValidationEntries ¶
Types ¶
type ErrDifferentLiveFlag ¶ added in v1.2.1
type ErrDifferentLiveFlag struct {
Expected, Actual string
}
ErrDifferentLiveFlag is returned when a block's live flag doesn't match the current setting.
func (ErrDifferentLiveFlag) Error ¶ added in v1.2.1
func (e ErrDifferentLiveFlag) Error() string
type ErrDuplicateBlock ¶ added in v1.2.1
type ErrDuplicateBlock struct {
Hash string
}
ErrDuplicateBlock is returned when a block appears multiple times in a chain.
func (ErrDuplicateBlock) Error ¶ added in v1.2.1
func (e ErrDuplicateBlock) Error() string
type ErrDuplicateEntry ¶ added in v1.2.1
type ErrDuplicateEntry struct {
Hash string
}
ErrDuplicateEntry is returned when an entry appears multiple times in a chain.
func (ErrDuplicateEntry) Error ¶ added in v1.2.1
func (e ErrDuplicateEntry) Error() string
type ErrHashTooWeak ¶ added in v1.2.1
type ErrHashTooWeak struct {
Expected, Actual uint64
}
ErrHashTooWeak is returned when a block's hash doesn't meet the threshold.
func (ErrHashTooWeak) Error ¶ added in v1.2.1
func (e ErrHashTooWeak) Error() string
type ErrMissingValidatedBlock ¶ added in v1.2.1
ErrMissingValidatedBlock is returned when a chain doesn't contain a block recorded in periodic validation chain.
func (ErrMissingValidatedBlock) Error ¶ added in v1.2.1
func (e ErrMissingValidatedBlock) Error() string
type Live ¶
type Live struct { }
Live is a validator which ensures the Live flag in each Records' Metadata matches the Live environment variable.
type Periodic ¶
type Periodic interface { bcgo.Validator AddChannel(string) FillChannelSet(map[string]bool, bcgo.Cache, bcgo.Network) error Update(bcgo.Cache, bcgo.Network, uint64) error Start() Stop() }
func NewCentennially ¶
func NewDecennially ¶
func NewPeriodic ¶
type PoW ¶
Example ¶
package main import ( "aletheiaware.com/bcgo" "aletheiaware.com/bcgo/cache" "aletheiaware.com/bcgo/channel" "aletheiaware.com/bcgo/validation" "aletheiaware.com/cryptogo" "fmt" "log" ) func main() { validator := validation.NewPoW(bcgo.THRESHOLD_G) channel := channel.New("FooBar") channel.AddValidator(validator) cache := cache.NewMemory(10) block := &bcgo.Block{ ChannelName: "TEST", Length: 1, } hash, err := cryptogo.HashProtobuf(block) if err != nil { log.Fatal("Could not hash block:", err) } fmt.Println(validator.Validate(channel, cache, nil, hash, block)) }
Output: Hash doesn't meet Proof-of-Work threshold: 288 vs 262
Click to show internal directories.
Click to hide internal directories.