bcgo

package module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 21 Imported by: 27

README

bcgo

This is a Go implementation of a blockchain using the BC data structures defined in Protobufs.

Build

go build

Documentation

Overview

Package containing utilities for BC in Go

Index

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"
)

Variables

This section is empty.

Functions

func AddPeer

func AddPeer(directory, peer string) error

func Alias added in v1.2.0

func Alias() (string, error)

func BCHost added in v1.2.0

func BCHost() string

func BCWebsite added in v1.2.0

func BCWebsite() string

func BinarySizeToString

func BinarySizeToString(size uint64) string

func BooleanFlag added in v1.2.0

func BooleanFlag(name string) bool

func CacheDirectory added in v1.2.0

func CacheDirectory(directory string) (string, error)

func CertificateDirectory added in v1.2.0

func CertificateDirectory(directory string) (string, error)

func CreateRecords

func CreateRecords(creator Account, access []Identity, 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 DecimalSizeToString(size uint64) string

func IsBeta

func IsBeta() bool

func IsLive

func IsLive() bool

func Iterate

func Iterate(channel string, hash []byte, block *Block, cache Cache, network Network, callback func([]byte, *Block) error) error

func IterateChronologically

func IterateChronologically(channel string, hash []byte, block *Block, cache Cache, network Network, callback func([]byte, *Block) error) error

func KeyDirectory added in v1.2.0

func KeyDirectory(directory string) (string, error)

func LastMinedTimestamp added in v1.2.0

func LastMinedTimestamp(node Node, channel Channel) (uint64, error)

func LoadConfig

func LoadConfig() error

func MineProto added in v1.2.0

func MineProto(node Node, channel Channel, threshold uint64, listener MiningListener, access []Identity, references []*Reference, message proto.Message) error

func MoneyToString

func MoneyToString(currency string, amount int64) string

func Ones

func Ones(data []byte) uint64

func Peers added in v1.2.0

func Peers(directory string) ([]string, error)

func PrintBlock

func PrintBlock(output io.Writer, prefix string, hash []byte, block *Block)

func PrintBlockEntry

func PrintBlockEntry(output io.Writer, prefix string, entry *BlockEntry)

func PrintRecord

func PrintRecord(output io.Writer, prefix string, hash []byte, record *Record)

func PrintReference

func PrintReference(output io.Writer, prefix string, reference *Reference)

func Read

func Read(channel string, hash []byte, block *Block, cache Cache, network Network, account Account, recordHash []byte, callback func(*BlockEntry, []byte, []byte) error) error

func ReadConfig

func ReadConfig(directory string) error

func ReadDelimitedProtobuf

func ReadDelimitedProtobuf(reader *bufio.Reader, destination proto.Message) error

func ReadKey

func ReadKey(channel string, hash []byte, block *Block, cache Cache, network Network, account Account, recordHash []byte, callback func([]byte) error) error

func RootDirectory added in v1.2.0

func RootDirectory() (string, error)

func RootDirectoryForUser added in v1.2.0

func RootDirectoryForUser(u *user.User) string

func SetupLogging

func SetupLogging(directory string) (*os.File, error)

func SplitRemoveEmpty

func SplitRemoveEmpty(s, sep string) []string

func Timestamp

func Timestamp() uint64

func TimestampToString

func TimestampToString(timestamp uint64) string

func ValidateName added in v1.2.0

func ValidateName(name string) error

ValidateName ensures all characters are in the set [a-zA-Z0-9.-_]

func WriteDelimitedProtobuf

func WriteDelimitedProtobuf(writer *bufio.Writer, source proto.Message) error

Types

type Account added in v1.2.0

type Account interface {
	Identity
	// Decrypt takes an Encryption Algorithm, Encrypted Payload, and Symmetric Key.
	// The Key is used to decrypt the Payload.
	// Decrypt returns the Decrypted Payload, or an error.
	Decrypt(cryptogo.EncryptionAlgorithm, []byte, []byte) ([]byte, error)
	// DecryptKey takes an Encrytion Algorithm and Encrypted Key.
	// The Key is decrypted with this Account's Private Key.
	// DecryptKey returns the Decrypted Key, or an error
	DecryptKey(cryptogo.EncryptionAlgorithm, []byte) ([]byte, error)
	// Sign takes a Payload.
	// Sign returns the Signature, Algorithm, or an error.
	Sign([]byte) (cryptogo.SignatureAlgorithm, []byte, error)
}

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 LoadBlock added in v1.2.0

func LoadBlock(channel string, cache Cache, network Network, hash []byte) (*Block, error)

func LoadBlockContainingRecord added in v1.2.0

func LoadBlockContainingRecord(channel string, cache Cache, network Network, hash []byte) (*Block, error)

func Mine added in v1.2.0

func Mine(node Node, channel Channel, threshold uint64, listener MiningListener) ([]byte, *Block, error)

func MineBlock added in v1.2.0

func MineBlock(node Node, channel Channel, threshold uint64, listener MiningListener, block *Block) ([]byte, *Block, error)

func MineEntries added in v1.2.0

func MineEntries(node Node, channel Channel, threshold uint64, listener MiningListener, entries []*BlockEntry) ([]byte, *Block, error)

func (*Block) Descriptor

func (*Block) Descriptor() ([]byte, []int)

func (*Block) GetChannelName

func (m *Block) GetChannelName() string

func (*Block) GetEntry

func (m *Block) GetEntry() []*BlockEntry

func (*Block) GetLength

func (m *Block) GetLength() uint64

func (*Block) GetMiner

func (m *Block) GetMiner() string

func (*Block) GetNonce

func (m *Block) GetNonce() uint64

func (*Block) GetPrevious

func (m *Block) GetPrevious() []byte

func (*Block) GetTimestamp

func (m *Block) GetTimestamp() uint64

func (*Block) ProtoMessage

func (*Block) ProtoMessage()

func (*Block) Reset

func (m *Block) Reset()

func (*Block) String

func (m *Block) String() string

func (*Block) XXX_DiscardUnknown

func (m *Block) XXX_DiscardUnknown()

func (*Block) XXX_Marshal

func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Block) XXX_Merge

func (m *Block) XXX_Merge(src proto.Message)

func (*Block) XXX_Size

func (m *Block) XXX_Size() int

func (*Block) XXX_Unmarshal

func (m *Block) XXX_Unmarshal(b []byte) error

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 (*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 {
	Head(channel string) (*Reference, error)
	Block(hash []byte) (*Block, error)
	BlockEntries(channel string, timestamp uint64) ([]*BlockEntry, error)
	BlockContainingRecord(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 interface {
	fmt.Stringer
	Name() string
	Head() []byte
	Timestamp() uint64
	AddTrigger(func())
	AddValidator(Validator)
	Update(Cache, Network, []byte, *Block) error
	Set(uint64, []byte)
	Load(Cache, Network) error
	Refresh(Cache, Network) error
	Pull(Cache, Network) error
	Push(Cache, Network) error
}

type ErrBlockHashIncorrect added in v1.2.1

type ErrBlockHashIncorrect struct {
}

ErrBlockHashIncorrect is returned when the given hash does not match the hash of the given block.

func (ErrBlockHashIncorrect) Error added in v1.2.1

func (e ErrBlockHashIncorrect) Error() string

type ErrBlockTooLarge added in v1.2.1

type ErrBlockTooLarge struct {
	Size, Max uint64
}

ErrBlockTooLarge is returned when the Block exceeds the size limit.

func (ErrBlockTooLarge) Error added in v1.2.1

func (e ErrBlockTooLarge) Error() string

type ErrChainInvalid added in v1.2.1

type ErrChainInvalid struct {
	Reason string
}

ErrChainInvalid is returned when a block fails validation for some reason.

func (ErrChainInvalid) Error added in v1.2.1

func (e ErrChainInvalid) Error() string

type ErrChainTooShort added in v1.2.1

type ErrChainTooShort struct {
	LengthA, LengthB uint64
}

ErrChainTooShort is returned when a new chain is shorter the channel's current head.

func (ErrChainTooShort) Error added in v1.2.1

func (e ErrChainTooShort) Error() string

type ErrChannelNameIncorrect added in v1.2.1

type ErrChannelNameIncorrect struct {
	Expected, Actual string
}

ErrChannelNameIncorrect is returned when a block channel name doesn't match the channel.

func (ErrChannelNameIncorrect) Error added in v1.2.1

func (e ErrChannelNameIncorrect) Error() string

type ErrChannelNameInvalid added in v1.2.1

type ErrChannelNameInvalid struct {
	Reason string
}

ErrChannelNameInvalid is returned when a channel name is too long or includes unsupported characters.

func (ErrChannelNameInvalid) Error added in v1.2.1

func (e ErrChannelNameInvalid) Error() string

type ErrChannelOutOfDate added in v1.2.1

type ErrChannelOutOfDate struct {
	Channel string
}

ErrChannelOutOfDate is returned when a broadcast fails due to the network having a more up-to-date version of the channel.

func (ErrChannelOutOfDate) Error added in v1.2.1

func (e ErrChannelOutOfDate) Error() string

type ErrNoEntriesToMine added in v1.2.1

type ErrNoEntriesToMine struct {
	Channel string
}

ErrNoEntriesToMine is returned when a mining operation fails due to a lack of entries.

func (ErrNoEntriesToMine) Error added in v1.2.1

func (e ErrNoEntriesToMine) Error() string

type ErrNoSuchBlock added in v1.2.1

type ErrNoSuchBlock struct {
	Hash string
}

ErrNoSuchBlock is returned when a block with the given hash cannot be found.

func (ErrNoSuchBlock) Error added in v1.2.1

func (e ErrNoSuchBlock) Error() string

type ErrNoSuchChannel added in v1.2.1

type ErrNoSuchChannel struct {
	Channel string
}

ErrNoSuchChannel is returned when a channel with the given name cannot be found.

func (ErrNoSuchChannel) Error added in v1.2.1

func (e ErrNoSuchChannel) Error() string

type ErrNoSuchHead added in v1.2.1

type ErrNoSuchHead struct {
	Channel string
}

ErrNoSuchHead is returned when a head with the given name cannot be found.

func (ErrNoSuchHead) Error added in v1.2.1

func (e ErrNoSuchHead) Error() string

type ErrNoSuchMapping added in v1.2.1

type ErrNoSuchMapping struct {
	Hash string
}

ErrNoSuchMapping is returned when a mapping with the given hash cannot be found.

func (ErrNoSuchMapping) Error added in v1.2.1

func (e ErrNoSuchMapping) Error() string

type ErrNonceWrapAround added in v1.2.1

type ErrNonceWrapAround struct {
}

ErrNonceWrapAround is returned when a mining operation fails after attempting every possible nonce.

func (ErrNonceWrapAround) Error added in v1.2.1

func (e ErrNonceWrapAround) Error() string

type ErrPayloadTooLarge added in v1.2.1

type ErrPayloadTooLarge struct {
	Size, Max uint64
}

ErrPayloadTooLarge is returned when the Payload exceeds the size limit.

func (ErrPayloadTooLarge) Error added in v1.2.1

func (e ErrPayloadTooLarge) Error() string

type ErrStopIteration added in v1.2.1

type ErrStopIteration struct {
}

ErrStopIteration is used by callbacks to indicate that their iteration through a channel should stop, typically because the result has been found.

func (ErrStopIteration) Error added in v1.2.1

func (e ErrStopIteration) Error() string

type Identity added in v1.2.0

type Identity interface {
	Alias() string
	PublicKey() (cryptogo.PublicKeyFormat, []byte, error)
	// Encrypt takes a Plaintext Payload
	// A new AES 256bit Symmetric Key is generated, used to encrypt the Payload.
	// Encrypt returns the Encryption Algorithm, Encrypted Payload, Key used, or an error.
	Encrypt([]byte) (cryptogo.EncryptionAlgorithm, []byte, []byte, error)
	// Encrypt takes a Plaintext key
	// The given key is encrypted with this Identity's Public Key
	// EncryptKey returns the Encryption Algorithm and Encrypted Key, or an error.
	EncryptKey([]byte) (cryptogo.EncryptionAlgorithm, []byte, error)
	// Verify takes a Signature Algorithm, Payload, and Signature.
	// Verify returns an error if the signature cannot be verified.
	Verify(cryptogo.SignatureAlgorithm, []byte, []byte) error
}

type LoggingMiningListener added in v1.1.5

type LoggingMiningListener struct {
}

func (*LoggingMiningListener) OnMiningStarted added in v1.1.5

func (l *LoggingMiningListener) OnMiningStarted(channel Channel, size uint64)

func (*LoggingMiningListener) OnMiningThresholdReached added in v1.1.5

func (l *LoggingMiningListener) OnMiningThresholdReached(channel Channel, hash []byte, block *Block)

func (*LoggingMiningListener) OnNewMaxOnes added in v1.1.5

func (l *LoggingMiningListener) OnNewMaxOnes(channel Channel, nonce, ones uint64)

type MiningListener

type MiningListener interface {
	OnMiningStarted(channel Channel, size uint64)
	OnNewMaxOnes(channel Channel, nonce, ones uint64)
	OnMiningThresholdReached(channel Channel, hash []byte, block *Block)
}

type Network

type Network interface {
	// Requests the head hash of the given channel
	Head(channel string) (*Reference, error)
	// Requests the block from the given reference
	Block(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 interface {
	Account() Account
	Cache() Cache
	Network() Network
	AddChannel(Channel)
	Channel(string) (Channel, error)
	OpenChannel(string, func() Channel) Channel
	Channels() []Channel
	Write(uint64, Channel, []Identity, []*Reference, []byte) (*Reference, error)
}

type PrintingMiningListener

type PrintingMiningListener struct {
	Output io.Writer
}

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 CreateRecord(timestamp uint64, creator Account, access []Identity, references []*Reference, payload []byte) ([]byte, *Record, error)

func (*Record) Descriptor

func (*Record) Descriptor() ([]byte, []int)

func (*Record) GetAccess

func (m *Record) GetAccess() []*Record_Access

func (*Record) GetCompressionAlgorithm

func (m *Record) GetCompressionAlgorithm() cryptogo.CompressionAlgorithm

func (*Record) GetCreator

func (m *Record) GetCreator() string

func (*Record) GetEncryptionAlgorithm

func (m *Record) GetEncryptionAlgorithm() cryptogo.EncryptionAlgorithm

func (*Record) GetMeta

func (m *Record) GetMeta() map[string]string

func (*Record) GetPayload

func (m *Record) GetPayload() []byte

func (*Record) GetReference

func (m *Record) GetReference() []*Reference

func (*Record) GetSignature

func (m *Record) GetSignature() []byte

func (*Record) GetSignatureAlgorithm

func (m *Record) GetSignatureAlgorithm() cryptogo.SignatureAlgorithm

func (*Record) GetTimestamp

func (m *Record) GetTimestamp() uint64

func (*Record) ProtoMessage

func (*Record) ProtoMessage()

func (*Record) Reset

func (m *Record) Reset()

func (*Record) String

func (m *Record) String() string

func (*Record) XXX_DiscardUnknown

func (m *Record) XXX_DiscardUnknown()

func (*Record) XXX_Marshal

func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Record) XXX_Merge

func (m *Record) XXX_Merge(src proto.Message)

func (*Record) XXX_Size

func (m *Record) XXX_Size() int

func (*Record) XXX_Unmarshal

func (m *Record) XXX_Unmarshal(b []byte) error

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 LoadHead added in v1.2.0

func LoadHead(channel string, cache Cache, network Network) (*Reference, error)

func WriteRecord

func WriteRecord(channel string, cache Cache, record *Record) (*Reference, error)

func (*Reference) Descriptor

func (*Reference) Descriptor() ([]byte, []int)

func (*Reference) GetBlockHash

func (m *Reference) GetBlockHash() []byte

func (*Reference) GetChannelName

func (m *Reference) GetChannelName() string

func (*Reference) GetIndex

func (m *Reference) GetIndex() uint64

func (*Reference) GetRecordHash

func (m *Reference) GetRecordHash() []byte

func (*Reference) GetTimestamp

func (m *Reference) GetTimestamp() uint64

func (*Reference) ProtoMessage

func (*Reference) ProtoMessage()

func (*Reference) Reset

func (m *Reference) Reset()

func (*Reference) String

func (m *Reference) String() string

func (*Reference) XXX_DiscardUnknown

func (m *Reference) XXX_DiscardUnknown()

func (*Reference) XXX_Marshal

func (m *Reference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Reference) XXX_Merge

func (m *Reference) XXX_Merge(src proto.Message)

func (*Reference) XXX_Size

func (m *Reference) XXX_Size() int

func (*Reference) XXX_Unmarshal

func (m *Reference) XXX_Unmarshal(b []byte) error

type Validator

type Validator interface {
	Validate(channel Channel, cache Cache, network Network, hash []byte, block *Block) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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