Documentation ¶
Index ¶
- Variables
- func RegisterStorage(s Storage)
- func ResetChainCache()
- type Block
- type BlockValidationError
- type Chain
- func (c *Chain) CacheBlock(block *Block) BlockValidationError
- func (c *Chain) CommitCache()
- func (c Chain) CreateBlock(payload []byte) *Block
- func (c Chain) GetBlock(height uint64) *Block
- func (c Chain) GetBlocks(from uint64, to uint64) []*Block
- func (c Chain) IsOwner() bool
- func (c *Chain) SaveBlock(block *Block) bool
- func (c *Chain) Sync()
- func (c Chain) ValidateBlock(block *Block) BlockValidationError
- func (c Chain) WIF() string
- type DangledBlockError
- type ExistBlockError
- type ForkError
- type InvalidBlockError
- type MismatchedIDError
- type Storage
Constants ¶
This section is empty.
Variables ¶
View Source
var BlockSavedHook func(block *Block) = nil
Functions ¶
func RegisterStorage ¶
func RegisterStorage(s Storage)
func ResetChainCache ¶
func ResetChainCache()
Types ¶
type Block ¶
type Block struct { Height uint64 `json:"height"` Time uint64 `json:"time"` PrevHash string `json:"prev_hash"` Hash string `json:"hash"` Signature string `json:"signature"` Payload []byte `json:"payload"` // contains filtered or unexported fields }
func DeserializeBlock ¶
func DeserializeBlock(message json.RawMessage) (*Block, error)
func (Block) DataForHashing ¶
Create a byte array for hashing height + time + prev_hash + payload int value should be converted to string literally hash string should be converted to string with base58 decoding TODO: store result to reduce calculations
func (*Block) Validate ¶
func (b *Block) Validate() BlockValidationError
TODO: store result to reduce calculations
type BlockValidationError ¶
type Chain ¶
func CreateChain ¶
Create a chain object with genesis block payload
func LoadAllChains ¶
func LoadAllChains() []*Chain
func NewOwnedChain ¶
func NewReadonlyChain ¶
func (*Chain) CacheBlock ¶
func (c *Chain) CacheBlock(block *Block) BlockValidationError
func (*Chain) CommitCache ¶
func (c *Chain) CommitCache()
func (Chain) CreateBlock ¶
func (Chain) ValidateBlock ¶
func (c Chain) ValidateBlock(block *Block) BlockValidationError
TODO: may need to cache database query result
type DangledBlockError ¶
type DangledBlockError struct {
// contains filtered or unexported fields
}
func (DangledBlockError) Code ¶
func (e DangledBlockError) Code() string
func (DangledBlockError) Error ¶
func (e DangledBlockError) Error() string
type ExistBlockError ¶
type ExistBlockError struct {
// contains filtered or unexported fields
}
func (ExistBlockError) Code ¶
func (e ExistBlockError) Code() string
func (ExistBlockError) Error ¶
func (e ExistBlockError) Error() string
type InvalidBlockError ¶
type InvalidBlockError struct {
// contains filtered or unexported fields
}
func (InvalidBlockError) Code ¶
func (e InvalidBlockError) Code() string
func (InvalidBlockError) Error ¶
func (e InvalidBlockError) Error() string
type MismatchedIDError ¶
type MismatchedIDError struct {
// contains filtered or unexported fields
}
func (MismatchedIDError) Code ¶
func (e MismatchedIDError) Code() string
func (MismatchedIDError) Error ¶
func (e MismatchedIDError) Error() string
type Storage ¶
type Storage interface { GetChain(chainID string, ref *int64, wif *string, count *uint64) bool GetAllChains(func(ref int64, id string, wif string, count uint64)) GetBlock(id int64, height uint64) *Block GetBlockByHash(id int64, hash string) *Block GetBlocks(id int64, from uint64, to uint64) []*Block SaveChain(chain *Chain) error IncreaseCount(chain *Chain) SaveBlock(id int64, block *Block) CleanChain(chain *Chain) }
func SharedStorage ¶
func SharedStorage() Storage
Click to show internal directories.
Click to hide internal directories.