Documentation ¶
Overview ¶
Package containing utilities for BC in Go
Index ¶
- Constants
- func AddPeer(directory, peer string) error
- func BinarySizeToString(size uint64) string
- func CreateRecords(creatorAlias string, creatorKey *rsa.PrivateKey, ...) (int, error)
- func DecimalSizeToString(size uint64) string
- func DecryptRecord(entry *BlockEntry, access *Record_Access, key *rsa.PrivateKey, ...) error
- func GetAlias() (string, error)
- func GetBCHost() string
- func GetBCWebsite() string
- func GetBooleanFlag(name string) bool
- func GetCacheDirectory(directory string) (string, error)
- func GetCertificateDirectory(directory string) (string, error)
- func GetKeyDirectory(directory string) (string, error)
- func GetPeers(directory string) ([]string, error)
- func GetRootDirectory() (string, error)
- func IsBeta() bool
- func IsLive() bool
- func Iterate(channel string, hash []byte, block *Block, cache Cache, network Network, ...) error
- func IterateChronologically(channel string, hash []byte, block *Block, cache Cache, network Network, ...) error
- func LoadConfig() error
- func MoneyToString(currency string, amount int64) string
- func Ones(data []byte) uint64
- func PrintBlock(output io.Writer, prefix string, hash []byte, block *Block)
- func PrintBlockEntry(output io.Writer, prefix string, entry *BlockEntry)
- func PrintRecord(output io.Writer, prefix string, hash []byte, record *Record)
- func PrintReference(output io.Writer, prefix string, reference *Reference)
- func Read(channel string, hash []byte, block *Block, cache Cache, network Network, ...) error
- func ReadConfig(directory string) error
- func ReadDelimitedProtobuf(reader *bufio.Reader, destination proto.Message) error
- func ReadKey(channel string, hash []byte, block *Block, cache Cache, network Network, ...) error
- func SetupLogging(directory string) (*os.File, error)
- func SplitRemoveEmpty(s, sep string) []string
- func Timestamp() uint64
- func TimestampToString(timestamp uint64) string
- func WriteDelimitedProtobuf(writer *bufio.Writer, source proto.Message) error
- type Block
- func CreateValidationBlock(timestamp uint64, channel, alias string, head []byte, block *Block, ...) *Block
- func GetBlock(channel string, cache Cache, network Network, hash []byte) (*Block, error)
- func GetBlockContainingRecord(channel string, cache Cache, network Network, hash []byte) (*Block, error)
- func (*Block) Descriptor() ([]byte, []int)
- func (m *Block) GetChannelName() string
- func (m *Block) GetEntry() []*BlockEntry
- func (m *Block) GetLength() uint64
- func (m *Block) GetMiner() string
- func (m *Block) GetNonce() uint64
- func (m *Block) GetPrevious() []byte
- func (m *Block) GetTimestamp() uint64
- func (*Block) ProtoMessage()
- func (m *Block) Reset()
- func (m *Block) String() string
- func (m *Block) XXX_DiscardUnknown()
- func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Block) XXX_Merge(src proto.Message)
- func (m *Block) XXX_Size() int
- func (m *Block) XXX_Unmarshal(b []byte) error
- type BlockEntry
- func (*BlockEntry) Descriptor() ([]byte, []int)
- func (m *BlockEntry) GetRecord() *Record
- func (m *BlockEntry) GetRecordHash() []byte
- func (*BlockEntry) ProtoMessage()
- func (m *BlockEntry) Reset()
- func (m *BlockEntry) String() string
- func (m *BlockEntry) XXX_DiscardUnknown()
- func (m *BlockEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *BlockEntry) XXX_Merge(src proto.Message)
- func (m *BlockEntry) XXX_Size() int
- func (m *BlockEntry) XXX_Unmarshal(b []byte) error
- type Cache
- type Channel
- func (c *Channel) AddTrigger(trigger func())
- func (c *Channel) AddValidator(validator Validator)
- func (c *Channel) LoadCachedHead(cache Cache) error
- func (c *Channel) LoadHead(cache Cache, network Network) error
- func (c *Channel) Pull(cache Cache, network Network) error
- func (c *Channel) Push(cache Cache, network Network) error
- func (c *Channel) Refresh(cache Cache, network Network) error
- func (c *Channel) String() string
- func (c *Channel) Update(cache Cache, network Network, head []byte, block *Block) error
- func (c *Channel) ValidateName(name string) error
- type FileCache
- func (f *FileCache) GetBlock(hash []byte) (*Block, error)
- func (f *FileCache) GetBlockContainingRecord(channel string, hash []byte) (*Block, error)
- func (f *FileCache) GetBlockEntries(channel string, timestamp uint64) ([]*BlockEntry, error)
- func (f *FileCache) GetHead(channel string) (*Reference, error)
- func (f *FileCache) MeasureStorageUsage(prefix string) (map[string]uint64, error)
- func (f *FileCache) PutBlock(hash []byte, block *Block) error
- func (f *FileCache) PutBlockEntry(channel string, entry *BlockEntry) error
- func (f *FileCache) PutHead(channel string, reference *Reference) error
- type LiveValidator
- type MemoryCache
- func (m *MemoryCache) GetBlock(hash []byte) (*Block, error)
- func (m *MemoryCache) GetBlockContainingRecord(channel string, hash []byte) (*Block, error)
- func (m *MemoryCache) GetBlockEntries(channel string, timestamp uint64) ([]*BlockEntry, error)
- func (m *MemoryCache) GetHead(channel string) (*Reference, error)
- func (m *MemoryCache) PutBlock(hash []byte, block *Block) error
- func (m *MemoryCache) PutBlockEntry(channel string, entry *BlockEntry) error
- func (m *MemoryCache) PutHead(channel string, reference *Reference) error
- type MiningListener
- type Network
- type Node
- func (n *Node) AddChannel(channel *Channel)
- func (n *Node) GetChannel(name string) (*Channel, error)
- func (n *Node) GetChannels() []*Channel
- func (n *Node) GetLastMinedTimestamp(channel *Channel) (uint64, error)
- func (n *Node) GetOrOpenChannel(name string, opener func() *Channel) *Channel
- func (n *Node) Mine(channel *Channel, threshold uint64, listener MiningListener) ([]byte, *Block, error)
- func (n *Node) MineBlock(channel *Channel, threshold uint64, listener MiningListener, block *Block) ([]byte, *Block, error)
- func (n *Node) MineEntries(channel *Channel, threshold uint64, listener MiningListener, ...) ([]byte, *Block, error)
- func (n *Node) MineProto(channel *Channel, threshold uint64, listener MiningListener, ...) error
- func (n *Node) Write(timestamp uint64, channel *Channel, acl map[string]*rsa.PublicKey, ...) (*Reference, error)
- type PeriodicValidator
- func GetCentenniallyValidator(channel *Channel) *PeriodicValidator
- func GetDailyValidator(channel *Channel) *PeriodicValidator
- func GetDecenniallyValidator(channel *Channel) *PeriodicValidator
- func GetHourlyValidator(channel *Channel) *PeriodicValidator
- func GetWeeklyValidator(channel *Channel) *PeriodicValidator
- func GetYearlyValidator(channel *Channel) *PeriodicValidator
- func NewPeriodicValidator(channel *Channel, period time.Duration) *PeriodicValidator
- func (p *PeriodicValidator) FillChannelSet(set map[string]bool, cache Cache, network Network) error
- func (p *PeriodicValidator) Start(node *Node, threshold uint64, listener MiningListener)
- func (p *PeriodicValidator) Stop()
- func (p *PeriodicValidator) Update(node *Node, threshold uint64, listener MiningListener, timestamp uint64) error
- func (p *PeriodicValidator) Validate(channel *Channel, cache Cache, network Network, hash []byte, block *Block) error
- type PoWValidator
- type PrintingMiningListener
- type Record
- func (*Record) Descriptor() ([]byte, []int)
- func (m *Record) GetAccess() []*Record_Access
- func (m *Record) GetCompressionAlgorithm() cryptogo.CompressionAlgorithm
- func (m *Record) GetCreator() string
- func (m *Record) GetEncryptionAlgorithm() cryptogo.EncryptionAlgorithm
- func (m *Record) GetMeta() map[string]string
- func (m *Record) GetPayload() []byte
- func (m *Record) GetReference() []*Reference
- func (m *Record) GetSignature() []byte
- func (m *Record) GetSignatureAlgorithm() cryptogo.SignatureAlgorithm
- func (m *Record) GetTimestamp() uint64
- func (*Record) ProtoMessage()
- func (m *Record) Reset()
- func (m *Record) String() string
- func (m *Record) XXX_DiscardUnknown()
- func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Record) XXX_Merge(src proto.Message)
- func (m *Record) XXX_Size() int
- func (m *Record) XXX_Unmarshal(b []byte) error
- type Record_Access
- func (*Record_Access) Descriptor() ([]byte, []int)
- func (m *Record_Access) GetAlias() string
- func (m *Record_Access) GetEncryptionAlgorithm() cryptogo.EncryptionAlgorithm
- func (m *Record_Access) GetSecretKey() []byte
- func (*Record_Access) ProtoMessage()
- func (m *Record_Access) Reset()
- func (m *Record_Access) String() string
- func (m *Record_Access) XXX_DiscardUnknown()
- func (m *Record_Access) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Record_Access) XXX_Merge(src proto.Message)
- func (m *Record_Access) XXX_Size() int
- func (m *Record_Access) XXX_Unmarshal(b []byte) error
- type Reference
- func (*Reference) Descriptor() ([]byte, []int)
- func (m *Reference) GetBlockHash() []byte
- func (m *Reference) GetChannelName() string
- func (m *Reference) GetIndex() uint64
- func (m *Reference) GetRecordHash() []byte
- func (m *Reference) GetTimestamp() uint64
- func (*Reference) ProtoMessage()
- func (m *Reference) Reset()
- func (m *Reference) String() string
- func (m *Reference) XXX_DiscardUnknown()
- func (m *Reference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Reference) XXX_Merge(src proto.Message)
- func (m *Reference) XXX_Size() int
- func (m *Reference) XXX_Unmarshal(b []byte) error
- type StopIterationError
- type TCPNetwork
- func (t *TCPNetwork) AddPeer(peer string)
- func (t *TCPNetwork) Broadcast(channel *Channel, cache Cache, hash []byte, block *Block) error
- func (t *TCPNetwork) Connect(peer string, data []byte) error
- func (t *TCPNetwork) GetBlock(reference *Reference) (*Block, error)
- func (t *TCPNetwork) GetHead(channel string) (*Reference, error)
- func (t *TCPNetwork) SetPeers(peers ...string)
- type UniqueValidator
- type Validator
Examples ¶
Constants ¶
View Source
const ( THRESHOLD_Z = 0 THRESHOLD_I = 256 // (32 / 64) * 512 // Hash Space: 2 ^ 256 // Usage: General Purpose THRESHOLD_H = 272 // (34 / 64) * 512 // Hash Space: 2 ^ 240 // Usage: General Purpose THRESHOLD_G = 288 // (36 / 64) * 512 // Hash Space: 2 ^ 224 // Usage: General Purpose, Alias THRESHOLD_F = 304 // (38 / 64) * 512 // Hash Space: 2 ^ 208 // Usage: Hour Validation THRESHOLD_E = 320 // (40 / 64) * 512 // Hash Space: 2 ^ 192 // Usage: Day Validation THRESHOLD_D = 336 // (42 / 64) * 512 // Hash Space: 2 ^ 176 // Usage: Week Validation THRESHOLD_C = 352 // (44 / 64) * 512 // Hash Space: 2 ^ 160 // Usage: Year Validation THRESHOLD_B = 368 // (46 / 64) * 512 // Hash Space: 2 ^ 144 // Usage: Decade Validation THRESHOLD_A = 384 // (48 / 64) * 512 // Hash Space: 2 ^ 128 // Usage: Century Validation MAX_BLOCK_SIZE_BYTES = uint64(2 * 1024 * 1024 * 1024) // 2Gb MAX_PAYLOAD_SIZE_BYTES = uint64(10 * 1024 * 1024) // 10Mb )
View Source
const ( BC_HOST = "bc.aletheiaware.com" BC_HOST_TEST = "test-bc.aletheiaware.com" BETA_FLAG = "BETA" LIVE_FLAG = "LIVE" )
View Source
const ( ERROR_CHAIN_INVALID = "Chain invalid: %s" ERROR_CHAIN_TOO_SHORT = "Chain too short to replace current head: %d vs %d" ERROR_HASH_INCORRECT = "Hash doesn't match block hash" ERROR_NAME_INCORRECT = "Name doesn't match channel name: %s vs %s" ERROR_NAME_INVALID = "Name invalid: %s" )
View Source
const ( ERROR_BLOCK_NOT_FOUND = "Block not found %s" ERROR_HEAD_NOT_FOUND = "Head not found %s" ERROR_RECORD_TO_BLOCK_MAPPING_NOT_FOUND = "Record to Block Mapping not found %s" )
View Source
const ( ERROR_NO_ENTRIES_TO_MINE = "No entries to mine for channel: %s" ERROR_NO_SUCH_CHANNEL = "No such channel: %s" ERROR_PAYLOAD_TOO_LARGE = "Payload too large: %s max: %s" ERROR_BLOCK_TOO_LARGE = "Block too large: %s max: %s" ERROR_NONCE_WRAP_AROUND = "Nonce wrapped around before reaching threshold" )
View Source
const ( ERROR_MISSING_VALIDATED_BLOCK = "Missing Validated Block %s" 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 = THRESHOLD_F THRESHOLD_PERIOD_DAY = THRESHOLD_E THRESHOLD_PERIOD_WEEK = THRESHOLD_D THRESHOLD_PERIOD_YEAR = THRESHOLD_C THRESHOLD_PERIOD_DECADE = THRESHOLD_B THRESHOLD_PERIOD_CENTURY = THRESHOLD_A )
View Source
const ( MAX_TCP_ERRORS = 10 TIMEOUT = 3 * time.Minute PORT_CONNECT = 22022 PORT_GET_BLOCK = 22222 PORT_GET_HEAD = 22322 PORT_BROADCAST = 23232 )
View Source
const ( ERROR_DUPLICATE_BLOCK = "Duplicate Block: %s" ERROR_DUPLICATE_ENTRY = "Duplicate Entry: %s" )
View Source
const (
ERROR_CHANNEL_OUT_OF_DATE = "Channel out of date"
)
View Source
const (
ERROR_DIFFERENT_LIVE_FLAG = "Different Live Flag; Expected '%s', got '%s'"
)
View Source
const (
ERROR_HASH_TOO_WEAK = "Hash doesn't meet Proof-of-Work threshold: %d vs %d"
)
Variables ¶
This section is empty.
Functions ¶
func BinarySizeToString ¶
func CreateRecords ¶
func CreateRecords(creatorAlias string, creatorKey *rsa.PrivateKey, access map[string]*rsa.PublicKey, references []*Reference, reader io.Reader, callback func([]byte, *Record) error) (int, error)
Chunk the data from reader into individual records with their own secret key and access list
func DecimalSizeToString ¶
func DecryptRecord ¶
func DecryptRecord(entry *BlockEntry, access *Record_Access, key *rsa.PrivateKey, callback func(*BlockEntry, []byte, []byte) error) error
func GetBCWebsite ¶
func GetBCWebsite() string
func GetBooleanFlag ¶
func GetCacheDirectory ¶
func GetCertificateDirectory ¶
func GetKeyDirectory ¶
func GetRootDirectory ¶
func IterateChronologically ¶
func LoadConfig ¶
func LoadConfig() error
func MoneyToString ¶
func PrintBlockEntry ¶
func PrintBlockEntry(output io.Writer, prefix string, entry *BlockEntry)
func ReadConfig ¶
func ReadDelimitedProtobuf ¶
func SplitRemoveEmpty ¶
func TimestampToString ¶
Types ¶
type Block ¶
type Block struct { // Timestamp (nanoseconds) when the block was created. Timestamp uint64 `protobuf:"fixed64,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Name of the channel. ChannelName string `protobuf:"bytes,2,opt,name=channel_name,json=channelName,proto3" json:"channel_name,omitempty"` // Length of chain in blocks (inclusive). Length uint64 `protobuf:"fixed64,3,opt,name=length,proto3" json:"length,omitempty"` // Hash of the previous block in the chain. Previous []byte `protobuf:"bytes,4,opt,name=previous,proto3" json:"previous,omitempty"` // Alias of the block miner's public key. Miner string `protobuf:"bytes,5,opt,name=miner,proto3" json:"miner,omitempty"` // The nonce mined to reach threshold. Nonce uint64 `protobuf:"fixed64,6,opt,name=nonce,proto3" json:"nonce,omitempty"` // The block's entries (list of hash/record pairs). Entry []*BlockEntry `protobuf:"bytes,7,rep,name=entry,proto3" json:"entry,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func CreateValidationBlock ¶
func (*Block) Descriptor ¶
func (*Block) GetChannelName ¶
func (*Block) GetEntry ¶
func (m *Block) GetEntry() []*BlockEntry
func (*Block) GetPrevious ¶
func (*Block) GetTimestamp ¶
func (*Block) ProtoMessage ¶
func (*Block) ProtoMessage()
func (*Block) XXX_DiscardUnknown ¶
func (m *Block) XXX_DiscardUnknown()
func (*Block) XXX_Marshal ¶
func (*Block) XXX_Unmarshal ¶
type BlockEntry ¶
type BlockEntry struct { // Hash of the record. RecordHash []byte `protobuf:"bytes,1,opt,name=record_hash,json=recordHash,proto3" json:"record_hash,omitempty"` Record *Record `protobuf:"bytes,2,opt,name=record,proto3" json:"record,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func CreateValidationEntries ¶
func CreateValidationEntries(timestamp uint64, node *Node) ([]*BlockEntry, error)
func CreateValidationEntry ¶
func (*BlockEntry) Descriptor ¶
func (*BlockEntry) Descriptor() ([]byte, []int)
func (*BlockEntry) GetRecord ¶
func (m *BlockEntry) GetRecord() *Record
func (*BlockEntry) GetRecordHash ¶
func (m *BlockEntry) GetRecordHash() []byte
func (*BlockEntry) ProtoMessage ¶
func (*BlockEntry) ProtoMessage()
func (*BlockEntry) Reset ¶
func (m *BlockEntry) Reset()
func (*BlockEntry) String ¶
func (m *BlockEntry) String() string
func (*BlockEntry) XXX_DiscardUnknown ¶
func (m *BlockEntry) XXX_DiscardUnknown()
func (*BlockEntry) XXX_Marshal ¶
func (m *BlockEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*BlockEntry) XXX_Merge ¶
func (m *BlockEntry) XXX_Merge(src proto.Message)
func (*BlockEntry) XXX_Size ¶
func (m *BlockEntry) XXX_Size() int
func (*BlockEntry) XXX_Unmarshal ¶
func (m *BlockEntry) XXX_Unmarshal(b []byte) error
type Cache ¶
type Cache interface { GetHead(channel string) (*Reference, error) GetBlock(hash []byte) (*Block, error) GetBlockEntries(channel string, timestamp uint64) ([]*BlockEntry, error) GetBlockContainingRecord(channel string, hash []byte) (*Block, error) PutHead(channel string, reference *Reference) error PutBlock(hash []byte, block *Block) error PutBlockEntry(channel string, entry *BlockEntry) error }
type Channel ¶
type Channel struct { Name string Head []byte Timestamp uint64 Triggers []func() Validators []Validator }
func NewChannel ¶
func OpenPoWChannel ¶
func (*Channel) AddTrigger ¶
func (c *Channel) AddTrigger(trigger func())
func (*Channel) AddValidator ¶
func (*Channel) LoadCachedHead ¶
func (*Channel) ValidateName ¶
Validates name matches channel name and all characters are in the set [a-zA-Z0-9.-_]
type FileCache ¶
type FileCache struct {
Directory string
}
func NewFileCache ¶
func (*FileCache) GetBlockContainingRecord ¶
func (*FileCache) GetBlockEntries ¶
func (f *FileCache) GetBlockEntries(channel string, timestamp uint64) ([]*BlockEntry, error)
func (*FileCache) MeasureStorageUsage ¶
func (*FileCache) PutBlockEntry ¶
func (f *FileCache) PutBlockEntry(channel string, entry *BlockEntry) error
type LiveValidator ¶
type LiveValidator struct { }
type MemoryCache ¶
type MemoryCache struct { Blocks map[string]*Block Heads map[string]*Reference Entries map[string][]*BlockEntry Mapping map[string]*Block }
func NewMemoryCache ¶
func NewMemoryCache(size int) *MemoryCache
func (*MemoryCache) GetBlockContainingRecord ¶
func (m *MemoryCache) GetBlockContainingRecord(channel string, hash []byte) (*Block, error)
func (*MemoryCache) GetBlockEntries ¶
func (m *MemoryCache) GetBlockEntries(channel string, timestamp uint64) ([]*BlockEntry, error)
func (*MemoryCache) PutBlockEntry ¶
func (m *MemoryCache) PutBlockEntry(channel string, entry *BlockEntry) error
type MiningListener ¶
type Network ¶
type Network interface { // Requests the head hash of the given channel GetHead(channel string) (*Reference, error) // Requests the block from the given reference GetBlock(reference *Reference) (*Block, error) // Broadcasts the channel update to the network Broadcast(channel *Channel, cache Cache, hash []byte, block *Block) error }
type Node ¶
type Node struct { Alias string Key *rsa.PrivateKey Cache Cache Network Network Channels map[string]*Channel }
Example ¶
package main import ( "aletheiaware.com/bcgo" "crypto/rand" "crypto/rsa" "encoding/base64" "fmt" "io/ioutil" "log" ) func main() { // Create temp directory dir, err := ioutil.TempDir("", "test") if err != nil { log.Fatal("Could not create temp cache dir:", err) } // Create file cache cache, err := bcgo.NewFileCache(dir) if err != nil { log.Fatal("Could not create file cache:", err) } channel := &bcgo.Channel{ Name: "Example", } // Write record to cache _, err = bcgo.WriteRecord(channel.Name, cache, &bcgo.Record{ Payload: []byte("Example!"), }) if err != nil { log.Fatal("Could not write record:", err) } // Generate private key privateKey, err := rsa.GenerateKey(rand.Reader, 4096) if err != nil { log.Fatal("Could not generate private key:", err) } // Create node node := &bcgo.Node{ Alias: "ExampleNode", Key: privateKey, Cache: cache, } // Mine all records in cache hash, block, err := node.Mine(channel, bcgo.THRESHOLD_G, nil) if err != nil { log.Fatal("Could not mine:", err) } fmt.Println(base64.RawURLEncoding.EncodeToString(hash)) fmt.Println(block) }
Output:
func (*Node) AddChannel ¶
func (*Node) GetChannels ¶
func (*Node) GetLastMinedTimestamp ¶
func (*Node) GetOrOpenChannel ¶
func (*Node) MineEntries ¶
func (n *Node) MineEntries(channel *Channel, threshold uint64, listener MiningListener, entries []*BlockEntry) ([]byte, *Block, error)
type PeriodicValidator ¶
type PeriodicValidator struct { // TODO add validator that each block holds the full channel set of the previous // TODO add validator that the duration between block timestamps equals or exceeds the period // TODO add validator that each head reference in block is the longest chain before timestamp Channel *Channel Period time.Duration Ticker *time.Ticker }
func GetCentenniallyValidator ¶
func GetCentenniallyValidator(channel *Channel) *PeriodicValidator
func GetDailyValidator ¶
func GetDailyValidator(channel *Channel) *PeriodicValidator
func GetDecenniallyValidator ¶
func GetDecenniallyValidator(channel *Channel) *PeriodicValidator
func GetHourlyValidator ¶
func GetHourlyValidator(channel *Channel) *PeriodicValidator
func GetWeeklyValidator ¶
func GetWeeklyValidator(channel *Channel) *PeriodicValidator
func GetYearlyValidator ¶
func GetYearlyValidator(channel *Channel) *PeriodicValidator
func NewPeriodicValidator ¶
func NewPeriodicValidator(channel *Channel, period time.Duration) *PeriodicValidator
func (*PeriodicValidator) FillChannelSet ¶
Fills the given set with the names of all channels validated in this chain
func (*PeriodicValidator) Start ¶
func (p *PeriodicValidator) Start(node *Node, threshold uint64, listener MiningListener)
Periodically mines a new block into the chain containing the head hashes of all open channels
func (*PeriodicValidator) Stop ¶
func (p *PeriodicValidator) Stop()
func (*PeriodicValidator) Update ¶
func (p *PeriodicValidator) Update(node *Node, threshold uint64, listener MiningListener, timestamp uint64) error
type PoWValidator ¶
type PoWValidator struct {
Threshold uint64
}
type PrintingMiningListener ¶
func (*PrintingMiningListener) OnMiningStarted ¶
func (p *PrintingMiningListener) OnMiningStarted(channel *Channel, size uint64)
func (*PrintingMiningListener) OnMiningThresholdReached ¶
func (p *PrintingMiningListener) OnMiningThresholdReached(channel *Channel, hash []byte, block *Block)
func (*PrintingMiningListener) OnNewMaxOnes ¶
func (p *PrintingMiningListener) OnNewMaxOnes(channel *Channel, nonce, ones uint64)
type Record ¶
type Record struct { // Timestamp (nanoseconds) when the record was created. Timestamp uint64 `protobuf:"fixed64,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Alias of the record creator's public key. Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"` // The list of accesses granted. Access []*Record_Access `protobuf:"bytes,3,rep,name=access,proto3" json:"access,omitempty"` // Holds record content, optionally encrypted with a secret key. Payload []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"` // The algorithm used to compress the payload. CompressionAlgorithm cryptogo.CompressionAlgorithm `` /* 155-byte string literal not displayed */ // The algorithm used to encrypt the payload. EncryptionAlgorithm cryptogo.EncryptionAlgorithm `` /* 151-byte string literal not displayed */ // Signature of payload (signed by the record creator's private key). Signature []byte `protobuf:"bytes,7,opt,name=signature,proto3" json:"signature,omitempty"` // The algorithm used to sign the payload. SignatureAlgorithm cryptogo.SignatureAlgorithm `` /* 147-byte string literal not displayed */ // References to previous records. Reference []*Reference `protobuf:"bytes,9,rep,name=reference,proto3" json:"reference,omitempty"` // Holds payload meta data. Meta map[string]string `` /* 150-byte string literal not displayed */ XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func CreateRecord ¶
func (*Record) Descriptor ¶
func (*Record) GetAccess ¶
func (m *Record) GetAccess() []*Record_Access
func (*Record) GetCompressionAlgorithm ¶
func (m *Record) GetCompressionAlgorithm() cryptogo.CompressionAlgorithm
func (*Record) GetCreator ¶
func (*Record) GetEncryptionAlgorithm ¶
func (m *Record) GetEncryptionAlgorithm() cryptogo.EncryptionAlgorithm
func (*Record) GetPayload ¶
func (*Record) GetReference ¶
func (*Record) GetSignature ¶
func (*Record) GetSignatureAlgorithm ¶
func (m *Record) GetSignatureAlgorithm() cryptogo.SignatureAlgorithm
func (*Record) GetTimestamp ¶
func (*Record) ProtoMessage ¶
func (*Record) ProtoMessage()
func (*Record) XXX_DiscardUnknown ¶
func (m *Record) XXX_DiscardUnknown()
func (*Record) XXX_Marshal ¶
func (*Record) XXX_Unmarshal ¶
type Record_Access ¶
type Record_Access struct { // Alias of the public key granted access, empty if public. Alias string `protobuf:"bytes,1,opt,name=alias,proto3" json:"alias,omitempty"` // The secret access key used to encrypt the payload. SecretKey []byte `protobuf:"bytes,2,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"` // If the alias is set, the secret key will be encrypted by the alias' public key. // The algorithm used to encrypt the secret key. EncryptionAlgorithm cryptogo.EncryptionAlgorithm `` /* 151-byte string literal not displayed */ XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Record_Access) Descriptor ¶
func (*Record_Access) Descriptor() ([]byte, []int)
func (*Record_Access) GetAlias ¶
func (m *Record_Access) GetAlias() string
func (*Record_Access) GetEncryptionAlgorithm ¶
func (m *Record_Access) GetEncryptionAlgorithm() cryptogo.EncryptionAlgorithm
func (*Record_Access) GetSecretKey ¶
func (m *Record_Access) GetSecretKey() []byte
func (*Record_Access) ProtoMessage ¶
func (*Record_Access) ProtoMessage()
func (*Record_Access) Reset ¶
func (m *Record_Access) Reset()
func (*Record_Access) String ¶
func (m *Record_Access) String() string
func (*Record_Access) XXX_DiscardUnknown ¶
func (m *Record_Access) XXX_DiscardUnknown()
func (*Record_Access) XXX_Marshal ¶
func (m *Record_Access) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*Record_Access) XXX_Merge ¶
func (m *Record_Access) XXX_Merge(src proto.Message)
func (*Record_Access) XXX_Size ¶
func (m *Record_Access) XXX_Size() int
func (*Record_Access) XXX_Unmarshal ¶
func (m *Record_Access) XXX_Unmarshal(b []byte) error
type Reference ¶
type Reference struct { // Timestamp (nanoseconds) when the referenced item was created. Timestamp uint64 `protobuf:"fixed64,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Name of the channel holding the referenced item. ChannelName string `protobuf:"bytes,2,opt,name=channel_name,json=channelName,proto3" json:"channel_name,omitempty"` // Hash of the block holding the referenced item. BlockHash []byte `protobuf:"bytes,3,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` // Hash of the record holding the referenced item. RecordHash []byte `protobuf:"bytes,4,opt,name=record_hash,json=recordHash,proto3" json:"record_hash,omitempty"` // Index of block in chain holding the referenced item. Index uint64 `protobuf:"fixed64,5,opt,name=index,proto3" json:"index,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func GetHeadReference ¶
func WriteRecord ¶
func (*Reference) Descriptor ¶
func (*Reference) GetBlockHash ¶
func (*Reference) GetChannelName ¶
func (*Reference) GetRecordHash ¶
func (*Reference) GetTimestamp ¶
func (*Reference) ProtoMessage ¶
func (*Reference) ProtoMessage()
func (*Reference) XXX_DiscardUnknown ¶
func (m *Reference) XXX_DiscardUnknown()
func (*Reference) XXX_Marshal ¶
func (*Reference) XXX_Unmarshal ¶
type StopIterationError ¶
type StopIterationError struct { }
func (StopIterationError) Error ¶
func (e StopIterationError) Error() string
type TCPNetwork ¶
func NewTCPNetwork ¶
func NewTCPNetwork(peers ...string) *TCPNetwork
func (*TCPNetwork) AddPeer ¶
func (t *TCPNetwork) AddPeer(peer string)
func (*TCPNetwork) SetPeers ¶
func (t *TCPNetwork) SetPeers(peers ...string)
type UniqueValidator ¶
type UniqueValidator struct { }
Click to show internal directories.
Click to hide internal directories.