Documentation
¶
Index ¶
- Constants
- Variables
- func AltBlockEncoder(scratch [64]byte, r gocoding.Renderer, v reflect.Value)
- func DecodeBinary(bytes *string) ([]byte, error)
- func DecodeStringToChainName(pathstr string) (name [][]byte)
- func EncodeBinary(bytes *[]byte) string
- func EncodeChainNameToString(name [][]byte) (pathstr string)
- func NewDecoding(decoding gocoding.Decoding) gocoding.Decoding
- func NewJSONUnmarshaller() gocoding.Unmarshaller
- func NewUnmarshaller(decoding gocoding.Decoding) gocoding.Unmarshaller
- func StartDynamic(path string, readEH func(err error)) error
- func StartStatic(path string) (err error)
- func UnmarshalJSON(reader gocoding.SliceableRuneReader, obj interface{}) error
- func Verify(publicKey *[ed25519.PublicKeySize]byte, message []byte, ...) bool
- func VerifySlice(p []byte, message []byte, s []byte) bool
- type BinaryMarshallable
- type BuyCBEntry
- type ByteArray
- type CBEntry
- type CBInfo
- type CBlock
- type CBlockHeader
- type CChain
- type DBEntry
- func (e *DBEntry) EncodableFields() map[string]reflect.Value
- func (e *DBEntry) GetBinaryTimeStamp() []byte
- func (e *DBEntry) Hash() *Hash
- func (e *DBEntry) MarshalBinary() (data []byte, err error)
- func (e *DBEntry) MarshalledSize() (size uint64)
- func (e *DBEntry) RealTime() time.Time
- func (e *DBEntry) SetHash(binaryHash []byte)
- func (e *DBEntry) SetTimeStamp(binaryTime []byte)
- func (e *DBEntry) ShaHash() *Hash
- func (e *DBEntry) StampTime()
- func (e *DBEntry) TimeStamp() int64
- func (e *DBEntry) UnmarshalBinary(data []byte) (err error)
- type DBInfo
- type DBlock
- type DBlockHeader
- type DChain
- type DetachedPublicKey
- type DetachedSignature
- type EBEntry
- func (e *EBEntry) EncodableFields() map[string]reflect.Value
- func (e *EBEntry) GetBinaryTimeStamp() []byte
- func (e *EBEntry) Hash() *Hash
- func (e *EBEntry) MarshalBinary() ([]byte, error)
- func (e *EBEntry) MarshalledSize() uint64
- func (e *EBEntry) RealTime() time.Time
- func (e *EBEntry) SetHash(binaryHash []byte)
- func (e *EBEntry) SetIntTimeStamp(ts int64)
- func (e *EBEntry) SetTimeStamp(binaryTime []byte)
- func (e *EBEntry) ShaHash() *Hash
- func (e *EBEntry) StampTime()
- func (e *EBEntry) TimeStamp() int64
- func (e *EBEntry) UnmarshalBinary(data []byte) (err error)
- type EBInfo
- type EBlock
- type EBlockHeader
- type ECBalance
- type EChain
- type Entry
- type EntryInfo
- type EntryInfoBranch
- type Error
- type Hash
- func (h *Hash) BTCString() string
- func (h *Hash) ByteString() string
- func (h *Hash) Decoding(m gocoding.Unmarshaller, t reflect.Type) gocoding.Decoder
- func (h *Hash) Encoding(m gocoding.Marshaller, t reflect.Type) gocoding.Encoder
- func (h *Hash) GetBytes() []byte
- func (a *Hash) IsSameAs(b *Hash) bool
- func (h *Hash) MarshalBinary() ([]byte, error)
- func (h *Hash) MarshalledSize() uint64
- func (hash *Hash) SetBytes(newHash []byte) error
- func (h *Hash) String() string
- func (h *Hash) UnmarshalBinary(p []byte) error
- type HashF
- type PayChainCBEntry
- func (e *PayChainCBEntry) Credits() int32
- func (e *PayChainCBEntry) MarshalBinary() (data []byte, err error)
- func (e *PayChainCBEntry) MarshalledSize() uint64
- func (e *PayChainCBEntry) PublicKey() *Hash
- func (e *PayChainCBEntry) Type() byte
- func (e *PayChainCBEntry) UnmarshalBinary(data []byte) (err error)
- type PayEntryCBEntry
- func (e *PayEntryCBEntry) Credits() int32
- func (e *PayEntryCBEntry) MarshalBinary() (data []byte, err error)
- func (e *PayEntryCBEntry) MarshalledSize() uint64
- func (e *PayEntryCBEntry) PublicKey() *Hash
- func (e *PayEntryCBEntry) Type() byte
- func (e *PayEntryCBEntry) UnmarshalBinary(data []byte) (err error)
- type PrivateKey
- type PublicKey
- type Signature
- type Signer
- type SimpleData
- type Verifyer
Constants ¶
const ( TYPE_BUY uint8 = iota TYPE_PAY_ENTRY TYPE_PAY_CHAIN )
--------------------------------------------------------------- Three types of entries (transactions) for Entry Credit Block ---------------------------------------------------------------
const ( ErrorBadMethod = 0 ErrorNotAcceptable = 1 ErrorMissingVersionSpec = 2 ErrorMalformedVersionSpec = 3 ErrorBadVersionSpec = 4 ErrorEmptyRequest = 5 ErrorBadElementSpec = 6 ErrorBadIdentifier = 7 ErrorBlockNotFound = 8 ErrorEntryNotFound = 9 ErrorInternal = 10 ErrorJSONMarshal = 11 ErrorXMLMarshal = 12 ErrorUnsupportedMarshal = 13 ErrorJSONUnmarshal = 14 ErrorXMLUnmarshal = 15 ErrorUnsupportedUnmarshal = 16 ErrorBadPOSTData = 17 ErrorTemplateError = 18 ErrorHTTPNewRequestFailure = 19 ErrorHTTPDoRequestFailure = 20 ErrorHTMLMarshal = 21 ErrorVerifySignature = 22 )
const DBlockVersion = 1
const HashSize = 32
Size of array used to store sha hashes. See ShaHash.
const (
Separator = "/"
)
Variables ¶
var M = struct{ Main, Alt gocoding.Marshaller }{ json.NewMarshaller(), json.NewMarshaller(), }
Functions ¶
func DecodeBinary ¶
func DecodeStringToChainName ¶
To decode the binary name to a string to enable internal path search in db The algorithm is PathString = Hex(Name[0]) + ":" + Hex(Name[0]) + ":" + ... + Hex(Name[n])
func EncodeBinary ¶
func EncodeChainNameToString ¶
To encode the binary name to a string to enable internal path search in db The algorithm is PathString = Hex(Name[0]) + ":" + Hex(Name[0]) + ":" + ... + Hex(Name[n])
func NewJSONUnmarshaller ¶
func NewJSONUnmarshaller() gocoding.Unmarshaller
func NewUnmarshaller ¶
func NewUnmarshaller(decoding gocoding.Decoding) gocoding.Unmarshaller
func StartDynamic ¶
func StartStatic ¶
func UnmarshalJSON ¶
func UnmarshalJSON(reader gocoding.SliceableRuneReader, obj interface{}) error
func Verify ¶
func Verify(publicKey *[ed25519.PublicKeySize]byte, message []byte, sig *[ed25519.SignatureSize]byte) bool
Verify returns true iff sig is a valid signature of message by publicKey.
Types ¶
type BinaryMarshallable ¶
type BinaryMarshallable interface {
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
MarshalledSize() uint64
}
type BuyCBEntry ¶
type BuyCBEntry struct {
CBEntry //interface
FactomTxHash *Hash
// contains filtered or unexported fields
}
func NewBuyCBEntry ¶
func NewBuyCBEntry(pubKey *Hash, factoidTxHash *Hash, credits int32) *BuyCBEntry
func (*BuyCBEntry) Credits ¶
func (e *BuyCBEntry) Credits() int32
func (*BuyCBEntry) MarshalBinary ¶
func (e *BuyCBEntry) MarshalBinary() (data []byte, err error)
func (*BuyCBEntry) MarshalledSize ¶
func (e *BuyCBEntry) MarshalledSize() uint64
func (*BuyCBEntry) PublicKey ¶
func (e *BuyCBEntry) PublicKey() *Hash
func (*BuyCBEntry) Type ¶
func (e *BuyCBEntry) Type() byte
func (*BuyCBEntry) UnmarshalBinary ¶
func (e *BuyCBEntry) UnmarshalBinary(data []byte) (err error)
type ByteArray ¶
type ByteArray []byte
func NewByteArray ¶
func (ByteArray) MarshalBinary ¶
func (ByteArray) MarshalledSize ¶
type CBInfo ¶
func (*CBInfo) MarshalBinary ¶
func (*CBInfo) MarshalledSize ¶
func (*CBInfo) UnmarshalBinary ¶
type CBlock ¶
type CBlock struct {
//Marshalized
Header *CBlockHeader
CBEntries []CBEntry //Interface
//Not Marshalized
CBHash *Hash
Salt *Hash
Chain *CChain
IsSealed bool
}
func (*CBlock) AddCBEntry ¶
func (*CBlock) MarshalBinary ¶
func (*CBlock) MarshalledSize ¶
func (*CBlock) UnmarshalBinary ¶
type CBlockHeader ¶
-----------------------
func NewCBlockHeader ¶
func NewCBlockHeader(blockId uint64, prevHash *Hash, merkle *Hash) *CBlockHeader
func (*CBlockHeader) MarshalBinary ¶
func (b *CBlockHeader) MarshalBinary() (data []byte, err error)
func (*CBlockHeader) MarshalledSize ¶
func (b *CBlockHeader) MarshalledSize() uint64
func (*CBlockHeader) UnmarshalBinary ¶
func (b *CBlockHeader) UnmarshalBinary(data []byte) (err error)
type CChain ¶
type CChain struct {
ChainID *Hash
Name [][]byte
Blocks []*CBlock
CurrentBlock *CBlock
BlockMutex sync.Mutex
NextBlockID uint64
}
func (*CChain) MarshalBinary ¶
func (*CChain) MarshalledSize ¶
func (*CChain) UnmarshalBinary ¶
type DBEntry ¶
type DBEntry struct {
MerkleRoot *Hash // Different MR in EBlockHeader
ChainID *Hash
// contains filtered or unexported fields
}
func NewDBEntry ¶
func NewDBEntryFromCBlock ¶
func (*DBEntry) GetBinaryTimeStamp ¶
func (*DBEntry) MarshalBinary ¶
func (*DBEntry) MarshalledSize ¶
func (*DBEntry) SetTimeStamp ¶
func (*DBEntry) UnmarshalBinary ¶
type DBInfo ¶
type DBInfo struct {
// Serial hash for the directory block
DBHash *Hash
// BTCTxHash is the Tx hash returned from rpcclient.SendRawTransaction
BTCTxHash *Hash // use string or *btcwire.ShaHash ???
// BTCTxOffset is the index of the TX in this BTC block
BTCTxOffset int
// BTCBlockHeight is the height of the block where this TX is stored in BTC
BTCBlockHeight int32
//BTCBlockHash is the hash of the block where this TX is stored in BTC
BTCBlockHash *Hash // use string or *btcwire.ShaHash ???
// DBMerkleRoot is the merkle root of the Directory Block
// and is written into BTC as OP_RETURN data
DBMerkleRoot *Hash
}
func NewDBInfoFromDBlock ¶
func (*DBInfo) MarshalBinary ¶
func (*DBInfo) MarshalledSize ¶
func (*DBInfo) UnmarshalBinary ¶
type DBlock ¶
type DBlock struct {
//Marshalized
Header *DBlockHeader
DBEntries []*DBEntry
Salt *Hash
//Not Marshalized
Chain *DChain
IsSealed bool
DBHash *Hash
}
func (*DBlock) CalculateMerkleRoot ¶
func (*DBlock) MarshalBinary ¶
func (*DBlock) MarshalledSize ¶
func (*DBlock) UnmarshalBinary ¶
type DBlockHeader ¶
type DBlockHeader struct {
BlockID uint64
PrevBlockHash *Hash
MerkleRoot *Hash
Version int32
TimeStamp int64
BatchFlag byte // 1: start of the batch
EntryCount uint32
}
func NewDBlockHeader ¶
func NewDBlockHeader(blockId uint64, prevHash *Hash, version int32, count uint32) *DBlockHeader
func (*DBlockHeader) MarshalBinary ¶
func (b *DBlockHeader) MarshalBinary() (data []byte, err error)
func (*DBlockHeader) MarshalledSize ¶
func (b *DBlockHeader) MarshalledSize() uint64
func (*DBlockHeader) RealTime ¶
func (b *DBlockHeader) RealTime() time.Time
func (*DBlockHeader) UnmarshalBinary ¶
func (b *DBlockHeader) UnmarshalBinary(data []byte) (err error)
type DChain ¶
type DChain struct {
ChainID *Hash
Blocks []*DBlock
CurrentBlock *DBlock
BlockMutex sync.Mutex
NextBlockID uint64
}
func (*DChain) AddCBlockToDBEntry ¶
Add DBEntry from an Entry Credit Block
func (*DChain) AddDBEntry ¶
Add DBEntry from an Entry Block
func (*DChain) AddFBlockToDBEntry ¶
Add DBEntry from a Factoid Block
type DetachedPublicKey ¶
type DetachedPublicKey [ed25519.PublicKeySize]byte
type DetachedSignature ¶
type DetachedSignature [ed25519.SignatureSize]byte
func (*DetachedSignature) String ¶
func (ds *DetachedSignature) String() string
type EBEntry ¶
type EBEntry struct {
ChainID *[]byte // not marshalllized
// contains filtered or unexported fields
}
func NewEBEntry ¶
func (*EBEntry) GetBinaryTimeStamp ¶
func (*EBEntry) MarshalBinary ¶
func (*EBEntry) MarshalledSize ¶
func (*EBEntry) SetIntTimeStamp ¶
func (*EBEntry) SetTimeStamp ¶
func (*EBEntry) UnmarshalBinary ¶
type EBInfo ¶
func (*EBInfo) MarshalBinary ¶
func (*EBInfo) MarshalledSize ¶
func (*EBInfo) UnmarshalBinary ¶
type EBlock ¶
type EBlock struct {
//Marshalized
Header *EBlockHeader
EBEntries []*EBEntry
//Not Marshalized
EBHash *Hash
MerkleRoot *Hash
Salt *Hash
Chain *EChain
IsSealed bool
}
func CreateBlock ¶
func (*EBlock) AddEBEntry ¶
func (*EBlock) MarshalBinary ¶
func (*EBlock) MarshalledSize ¶
func (*EBlock) UnmarshalBinary ¶
type EBlockHeader ¶
func NewEBlockHeader ¶
func NewEBlockHeader(blockId uint64, prevHash *Hash, merkle *Hash) *EBlockHeader
func (*EBlockHeader) MarshalBinary ¶
func (b *EBlockHeader) MarshalBinary() (data []byte, err error)
func (*EBlockHeader) MarshalledSize ¶
func (b *EBlockHeader) MarshalledSize() uint64
func (*EBlockHeader) RealTime ¶
func (e *EBlockHeader) RealTime() time.Time
func (*EBlockHeader) UnmarshalBinary ¶
func (b *EBlockHeader) UnmarshalBinary(data []byte) (err error)
type EChain ¶
type EChain struct {
//Marshalized
ChainID *Hash
Name [][]byte
FirstEntry *Entry
//Not Marshalized
Blocks []*EBlock
CurrentBlock *EBlock
BlockMutex sync.Mutex
NextBlockID uint64
}
func (*EChain) EncodableFields ¶
For Json marshaling
func (*EChain) GenerateIDFromName ¶
To generate a chain id (hash) from a binary array name The algorithm is chainID = Sha(Sha(Name[0]) + Sha(Name[1] + ... + Sha(Name[n])
func (*EChain) MarshalBinary ¶
func (*EChain) MarshalledSize ¶
func (*EChain) UnmarshalBinary ¶
type Entry ¶
func (*Entry) MarshalBinary ¶
func (*Entry) MarshalledSize ¶
func (*Entry) UnmarshalBinary ¶
type EntryInfo ¶
func (*EntryInfo) MarshalBinary ¶
func (*EntryInfo) MarshalledSize ¶
func (*EntryInfo) UnmarshalBinary ¶
type EntryInfoBranch ¶
type Error ¶
type Error struct {
APICode uint
HTTPCode int
Name string
Description string
SupportURL string
Message string
}
func CreateError ¶
type Hash ¶
type Hash struct {
Bytes []byte `json:"bytes"`
}
func BuildMerkleTreeStore ¶
func CreateHash ¶
func CreateHash(entities ...BinaryMarshallable) (h *Hash, err error)
func NewShaHash ¶
NewShaHash returns a new ShaHash from a byte slice. An error is returned if the number of bytes passed in is not HashSize.
func (*Hash) ByteString ¶
func (*Hash) MarshalBinary ¶
func (*Hash) MarshalledSize ¶
func (*Hash) SetBytes ¶
SetBytes sets the bytes which represent the hash. An error is returned if the number of bytes passed in is not HashSize.
func (*Hash) UnmarshalBinary ¶
type PayChainCBEntry ¶
type PayChainCBEntry struct {
CBEntry //interface
EntryHash *Hash
ChainIDHash *Hash
EntryChainIDHash *Hash //Hash(EntryHash+ChainIDHash)
// contains filtered or unexported fields
}
func NewPayChainCBEntry ¶
func (*PayChainCBEntry) Credits ¶
func (e *PayChainCBEntry) Credits() int32
func (*PayChainCBEntry) MarshalBinary ¶
func (e *PayChainCBEntry) MarshalBinary() (data []byte, err error)
func (*PayChainCBEntry) MarshalledSize ¶
func (e *PayChainCBEntry) MarshalledSize() uint64
func (*PayChainCBEntry) PublicKey ¶
func (e *PayChainCBEntry) PublicKey() *Hash
func (*PayChainCBEntry) Type ¶
func (e *PayChainCBEntry) Type() byte
func (*PayChainCBEntry) UnmarshalBinary ¶
func (e *PayChainCBEntry) UnmarshalBinary(data []byte) (err error)
type PayEntryCBEntry ¶
type PayEntryCBEntry struct {
CBEntry //interface
EntryHash *Hash
TimeStamp int64
// contains filtered or unexported fields
}
func NewPayEntryCBEntry ¶
func NewPayEntryCBEntry(pubKey *Hash, entryHash *Hash, credits int32, timeStamp int64) *PayEntryCBEntry
func (*PayEntryCBEntry) Credits ¶
func (e *PayEntryCBEntry) Credits() int32
func (*PayEntryCBEntry) MarshalBinary ¶
func (e *PayEntryCBEntry) MarshalBinary() (data []byte, err error)
func (*PayEntryCBEntry) MarshalledSize ¶
func (e *PayEntryCBEntry) MarshalledSize() uint64
func (*PayEntryCBEntry) PublicKey ¶
func (e *PayEntryCBEntry) PublicKey() *Hash
func (*PayEntryCBEntry) Type ¶
func (e *PayEntryCBEntry) Type() byte
func (*PayEntryCBEntry) UnmarshalBinary ¶
func (e *PayEntryCBEntry) UnmarshalBinary(data []byte) (err error)
type PrivateKey ¶
type PrivateKey struct {
Key *[ed25519.PrivateKeySize]byte
Pub PublicKey
}
PrivateKey contains Public/Private key pair
func (*PrivateKey) AllocateNew ¶
func (pk *PrivateKey) AllocateNew()
func (*PrivateKey) GenerateKey ¶
func (pk *PrivateKey) GenerateKey() (err error)
Generate creates new PrivateKey / PublciKey pair or returns error
func (PrivateKey) MarshalSign ¶
func (pk PrivateKey) MarshalSign(msg BinaryMarshallable) (sig Signature)
Sign signs msg with PrivateKey and return Signature
func (PrivateKey) Public ¶
func (pk PrivateKey) Public() []byte
func (PrivateKey) Sign ¶
func (pk PrivateKey) Sign(msg []byte) (sig Signature)
Sign signs msg with PrivateKey and return Signature
type PublicKey ¶
type PublicKey struct {
Key *[ed25519.PublicKeySize]byte
}
PublicKey contains only Public part of Public/Private key pair
func PubKeyFromString ¶
type Signature ¶
type Signature struct {
Pub PublicKey
Sig *[ed25519.SignatureSize]byte
}
Signature has signed data and its corresponsing PublicKey
func (*Signature) DetachSig ¶
func (sig *Signature) DetachSig() *DetachedSignature
type SimpleData ¶
type SimpleData struct {
Data []byte
}
func (*SimpleData) MarshalBinary ¶
func (d *SimpleData) MarshalBinary() ([]byte, error)
func (*SimpleData) MarshalledSize ¶
func (d *SimpleData) MarshalledSize() uint64
func (*SimpleData) UnmarshalBinary ¶
func (d *SimpleData) UnmarshalBinary([]byte) error