Documentation
¶
Index ¶
- func BuyEntryCredit(version uint16, ecPubKey *notaryapi.Hash, from *notaryapi.Hash, value uint64, ...) error
- func CommitChain(c *notaryapi.EChain) error
- func CommitEntry(e *notaryapi.Entry) error
- func CommitEntry2(e *Entry) error
- func EXPLODE(obj interface{}) error
- func GetDirectoryBlokByHashStr(addr string) (*notaryapi.DBlock, error)
- func GetDirectoryBloks(fromBlockHeight uint64, toBlockHeight uint64) (dBlocks []notaryapi.DBlock, err error)
- func GetEntryBlokByHashStr(addr string) (*notaryapi.EBlock, error)
- func GetEntryBlokByMRStr(addr string) (*notaryapi.EBlock, error)
- func GetEntryByHashStr(addr string) (*notaryapi.Entry, error)
- func GetEntryCreditBalance(ecPubKey *notaryapi.Hash) (credits int32, err error)
- func PrintEntry(e *Entry)
- func RevealChain(c *notaryapi.EChain) error
- func RevealEntry(e *notaryapi.Entry) error
- func RevealEntry2(e *Entry) error
- func SafeMarshal(writer io.Writer, obj interface{}) error
- func SafeMarshalHTML(writer io.Writer, obj interface{}) error
- func SafeUnmarshal(reader gocoding.SliceableRuneReader, obj interface{}) error
- func SetDB(database database.Db) error
- func SetOutMsgQueue(outMsgQ chan<- factomwire.Message) error
- func SetServerAddr(addr string) error
- func Submit(f FactomWriter) (err error)
- func SubmitFactoidTx(m factomwire.Message) error
- type Chain
- type Entry
- type FactomChainer
- type FactomWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuyEntryCredit ¶
func BuyEntryCredit(version uint16, ecPubKey *notaryapi.Hash, from *notaryapi.Hash, value uint64, fee uint64, sig *notaryapi.Signature) error
This method will be replaced with a Factoid transaction once we have the factoid implementation in place
func CommitChain ¶
-------------------------------------
// PrintEntry is a helper function for debugging entry transport and encoding
func PrintEntry(e *Entry) { fmt.Println("ChainID:", hex.EncodeToString(e.ChainID)) fmt.Println("ExtIDs:") for i := range e.ExtIDs { fmt.Println(" ", string(e.ExtIDs[i])) } fmt.Println("Data:", string(e.Data)) }
// NewEntry creates a factom entry. It is supplied a string chain id, a []byte // of data, and a series of string external ids for entry lookup
func NewEntry(cid string, eids []string, data []byte) (e *Entry, err error) { e = new(Entry) e.ChainID, err = hex.DecodeString(cid) if err != nil { return nil, err } e.Data = data for _, v := range eids { e.ExtIDs = append(e.ExtIDs, []byte(v)) } return }
// NewChain creates a factom chain from a []string chain name and a new entry // to be the first entry of the new chain from []byte data, and a series of // string external ids
func NewChain(name []string, eids []string, data []byte) (c *Chain, err error) { c = new(Chain) for _, v := range name { c.Name = append(c.Name, []byte(v)) } c.GenerateID() e := new(Entry) e.ChainID = c.ChainID e.Data = data for _, v := range eids { e.ExtIDs = append(e.ExtIDs, []byte(v)) } c.FirstEntry = e return }
// CommitEntry sends a message to the factom network containing a hash of the // entry to be used to verify the later RevealEntry.
func CommitEntry(e *Entry) error { data := url.Values{ "datatype": {"entryhash"}, "format": {"binary"}, "data": {e.Hash()}, } server := fmt.Sprintf(`http://%s/v1`, serverAddr) _, err := http.PostForm(server, data) if err != nil { return err } return nil }
// RevealEntry sends a message to the factom network containing the binary // encoded entry for the server to add it to the factom blockchain. The entry // will be rejected if a CommitEntry was not done.
func RevealEntry(e *Entry) error { data := url.Values{ "datatype": {"entry"}, "format": {"binary"}, "entry": {e.Hex()}, } server := fmt.Sprintf(`http://%s/v1`, serverAddr) _, err := http.PostForm(server, data) if err != nil { return err } return nil }
CommitChain sends a message to the factom network containing a series of hashes to be used to verify the later RevealChain.
func CommitEntry ¶
CommitEntry sends a message to the factom network containing a hash of the entry to be used to verify the later RevealEntry.
func CommitEntry2 ¶
CommitEntry sends a message to the factom network containing a hash of the entry to be used to verify the later RevealEntry.
func GetDirectoryBloks ¶
func GetEntryCreditBalance ¶
func PrintEntry ¶
func PrintEntry(e *Entry)
PrintEntry is a helper function for debugging entry transport and encoding
func RevealChain ¶
RevealChain sends a message to the factom network containing the binary encoded first entry for a chain to be used by the server to add a new factom chain. It will be rejected if a CommitChain was not done.
func RevealEntry ¶
RevealEntry sends a message to the factom network containing the binary encoded entry for the server to add it to the factom blockchain. The entry will be rejected if a CommitEntry was not done.
func RevealEntry2 ¶
RevealEntry sends a message to the factom network containing the binary encoded entry for the server to add it to the factom blockchain. The entry will be rejected if a CommitEntry was not done.
func SafeMarshal ¶
func SafeMarshalHTML ¶
func SafeUnmarshal ¶
func SafeUnmarshal(reader gocoding.SliceableRuneReader, obj interface{}) error
func SetOutMsgQueue ¶
func SetOutMsgQueue(outMsgQ chan<- factomwire.Message) error
func SetServerAddr ¶
to be removed------------------------------
func Submit ¶
func Submit(f FactomWriter) (err error)
CommitChain sends a message to the factom network containing a series of hashes to be used to verify the later RevealChain.
func CommitChain(c *Chain) error { var msg bytes.Buffer binary.Write(&msg, binary.BigEndian, uint64(time.Now().Unix())) msg.Write(c.MarshalBinary()) chainhash, chainentryhash, entryhash := c.Hash() msg.Write([]byte(chainhash)) msg.Write([]byte(chainentryhash)) msg.Write([]byte(entryhash)) sig := wallet.SignData(msg.Bytes()) data := url.Values{ "datatype": {"commitchain"}, "format": {"binary"}, "signature": {hex.EncodeToString((*sig.Sig)[:])}, "pubkey": {hex.EncodeToString((*sig.Pub.Key)[:])}, "data": {hex.EncodeToString(msg.Bytes())}, } _, err := http.PostForm(server, data) if err != nil { return err } return nil }
// RevealChain sends a message to the factom network containing the binary // encoded first entry for a chain to be used by the server to add a new factom // chain. It will be rejected if a CommitChain was not done.
func RevealChain(c *Chain) error { data := url.Values{ "datatype": {"entry"}, "format": {"binary"}, "data": {hex.EncodeToString(c.MarshalBinary())}, } _, err := http.PostForm(server, data) if err != nil { return err } return nil }
Submit wraps CommitEntry and RevealEntry. Submit takes a FactomWriter (an entry is a FactomWriter) and does a commit and reveal for the entry adding it to the factom blockchain.
func SubmitFactoidTx ¶
func SubmitFactoidTx(m factomwire.Message) error
Types ¶
type Chain ¶
A Chain that can be submitted to the factom network.
func NewChain ¶
NewChain creates a factom chain from a []string chain name and a new entry to be the first entry of the new chain from []byte data, and a series of string external ids
func (*Chain) CreateFactomChain ¶
CreateFactomChain satisfies the FactomChainer interface.
func (*Chain) GenerateID ¶
GenerateID will create the chainid from the chain name. It sets the chainid for the object and returns the chainid as a hex encoded string.
func (*Chain) Hash ¶
Hash will return a hex encoded hash of the chainid, a hash of the entry, and a hash of the chainid + entry to be used by CommitChain.
func (*Chain) MarshalBinary ¶
MarshalBinary creates a single []byte from a chain for transport.
func (*Chain) UnmarshalJSON ¶
UnmarshalJSON makes satisfies the json.Unmarshaler interfact and populates an entry with the data from a json entry.
type Entry ¶
A factom entry that can be submitted to the factom network.
func NewEntry ¶
NewEntry creates a factom entry. It is supplied a string chain id, a []byte of data, and a series of string external ids for entry lookup
func (*Entry) CreateFactomEntry ¶
CreateFactomEntry allows an Entry to satisfy the FactomWriter interface.
func (*Entry) FromJsonEntry ¶
func (*Entry) MarshalBinary ¶
MarshalBinary creates a single []byte from an entry for transport.
func (*Entry) UnmarshalJSON ¶
UnmarshalJSON makes satisfies the json.Unmarshaler interfact and populates an entry with the data from a json entry.
type FactomChainer ¶
type FactomChainer interface {
CreateFactomChain() *Chain
}
Objects implimenting the FactomChainer interface may be used in the CreateChain call to create a chain and first entry on the factom network.
type FactomWriter ¶
type FactomWriter interface {
CreateFactomEntry() *Entry
}
Objects implimenting the FactomWriter interface may be used in the Submit call to create and add an entry to the factom network.