ontchain

package module
v0.0.0-...-9c98f16 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: BSD-2-Clause Imports: 15 Imported by: 1

README

ontchain

Customize the ontology blockchain SDK for easier managed. Some feature can't supply in default sdk because of security. Simplize using managed wallet and functions.

Documentation

Index

Constants

View Source
const (
	NotStored = iota
	PartStored
	AllStored
)

wallet storage status

Variables

View Source
var (

	// Endpoint - ont block chain restful api endpoint
	Endpoint = "http://localhost:20334"
)
View Source
var (
	// FirstRevision - first or default revision
	FirstRevision = "0.1.0"
)

Functions

func Attributes2StringMaps

func Attributes2StringMaps(attributes []*sdk.DDOAttribute) map[string]string

Attributes2StringMaps - attributes to map

func ClaimCommit

func ClaimCommit(claim *Claim, acct *sdk.Account) (common.Uint256, error)

ClaimCommit - Commit claim

func ClaimGetStatus

func ClaimGetStatus(claim string) *sdkcom.PreExecResult

ClaimGetStatus - get claim status

func ClaimRevoke

func ClaimRevoke(claim, commiter string, acct *sdk.Account) (common.Uint256, error)

ClaimRevoke - revoke a claim

func DeployContract

func DeployContract(acct *sdk.Account, sc *sdkcom.SmartContract) (common.Uint256, error)

DeployContract - deploy contract

func DeployContractCode

func DeployContractCode(acct *sdk.Account, name, code string) (common.Uint256, error)

DeployContractCode - deploy contract code

func GenerateClaim

func GenerateClaim(d []byte) []byte

GenerateClaim - generate method

func GetDDO

func GetDDO(id string) *sdk.DDO

GetDDO - get ddo by id

func GetID

func GetID() string

GetID - just generate ID

func GetSdk

func GetSdk(url string) *sdk.OntologySdk

GetSdk - get default sdk url - restful interface. If pass "" we using the default URL configurated.

func GetSimpleStorage

func GetSimpleStorage(key []byte) *sdkcom.PreExecResult

GetSimpleStorage - get simple storage

func GetSmartContractEvent

func GetSmartContractEvent(txHash string) (*sdkcom.SmartContactEvent, error)

GetSmartContractEvent - get smart contract event

func GetStorage

func GetStorage(addr string, key []byte) ([]byte, error)

GetStorage - get smartcontract storage

func GetTxInfo

func GetTxInfo(hash string) (*types.Transaction, error)

GetTxInfo - get transaction infomation

func IdentityFormat

func IdentityFormat(fl validator.FieldLevel) bool

IdentityFormat - validate for indentity

func PostSimpleStorage

func PostSimpleStorage(acct *sdk.Account, key, value []byte) (common.Uint256, error)

PostSimpleStorage - post simple storage

func PutSimpleStorage

func PutSimpleStorage(acct *sdk.Account, key, value []byte) (common.Uint256, error)

PutSimpleStorage - create simple storage

func RemoveSimpleStorage

func RemoveSimpleStorage(acct *sdk.Account, key []byte) (common.Uint256, error)

RemoveSimpleStorage - remove simple storage

func StringMap2Attributes

func StringMap2Attributes(attr map[string]string) []*sdk.DDOAttribute

StringMap2Attributes - stringmap to attributes

func VerifyClaim

func VerifyClaim(claim, data []byte) bool

VerifyClaim - verify claim content

Types

type Claim

type Claim struct {
	Claim    []byte
	Commiter []byte
	Owner    []byte
}

Claim - Claim is a contract that save the document hash to record content impartially commiter is the claim issuer. Who wants to claim this issue should be first creator of claim and had the operation power. owner is the administrator of this claim. owner is who had authority to manage this claim.

func MakeClaim

func MakeClaim(commiter, owner []byte, data interface{}) *Claim

MakeClaim - convert data to claim

type ManagedIdentity

type ManagedIdentity struct {
	sdk.IdentityData
	Password []byte
}

ManagedIdentity - Get Password in storage

func GetIdentityFromID

func GetIdentityFromID(id string, passwd []byte) (*ManagedIdentity, error)

GetIdentityFromID - get identity struct from id include control data

func (*ManagedIdentity) Identity

func (id *ManagedIdentity) Identity() (*sdk.Identity, error)

Identity - get identity from managedidentity

func (*ManagedIdentity) RegIDWithAttributes

func (id *ManagedIdentity) RegIDWithAttributes(attr map[string]string, signer *sdk.Account)

RegIDWithAttributes -register id with attributes

func (*ManagedIdentity) RegisterID

func (id *ManagedIdentity) RegisterID(signer *sdk.Account)

RegisterID - register id to blockchain

type ManagedWallet

type ManagedWallet struct {
	Name     string // ID/Key of wallet
	Revision string // revision of wallet format or something information
	Info     string // extended information
	WalletStorage
	Password    []byte
	Data        sdk.WalletData
	Wallet      *sdk.Wallet   `json:"-"`
	DefAccout   *sdk.Account  `json:"-"`
	DefIdentity *sdk.Identity `json:"-"`
}

ManagedWallet - managed wallet Save password and walletdata in struct. Easier saving and loading data to database or storage 1, Load the data, then using "Update" function to refresh the wallet 2, get "walletData" from wallet information. After setting password and path then "Update" also can get managedwallet 3, "NewUpdatedManagedWallet" to get a full new managedwallet. 4, "GetWallet" to get wallet from managedwallet.

func GetManagedWalletFromDB

func GetManagedWalletFromDB(db kvdb.KVMethods, key string) *ManagedWallet

GetManagedWalletFromDB - load managedwallet from database

func GetManagedWalletFromFile

func GetManagedWalletFromFile(path string) *ManagedWallet

GetManagedWalletFromFile - load managedwallet from wallet file

func NewDefaultWallet

func NewDefaultWallet(name string, password []byte) *ManagedWallet

NewDefaultWallet - Creart new default revision and path "" Wallet

func NewManagedWallet

func NewManagedWallet(name string, rev string, password []byte) *ManagedWallet

NewManagedWallet - Create a new managedwallet

func NewUpdatedManagedWallet

func NewUpdatedManagedWallet(name string, password []byte) *ManagedWallet

NewUpdatedManagedWallet - Create a new managedwallet

func (*ManagedWallet) GetWallet

func (mw *ManagedWallet) GetWallet() *sdk.Wallet

GetWallet - get managedwallet's wallet

func (*ManagedWallet) SetDB

func (mw *ManagedWallet) SetDB(db kvdb.KVMethods) *sdk.Wallet

SetDB - store managewallet into the db

func (*ManagedWallet) SetFilePath

func (mw *ManagedWallet) SetFilePath(path string, force bool) error

SetFilePath - Save wallet to wallet file(path)

func (*ManagedWallet) Update

func (mw *ManagedWallet) Update() error

Update - after get walletdata from json update to *wallet and * account

func (*ManagedWallet) UpdateWalletData

func (mw *ManagedWallet) UpdateWalletData()

UpdateWalletData - update walletdata from ManagedWallet.Wallet to ManagedWallet.Data

type SmartContract

type SmartContract sdkcom.SmartContract

SmartContract - smart contract

type WalletStorage

type WalletStorage struct {
	FilePath string
	KVDB     kvdb.KVMethods `json:"-"`
}

WalletStorage - wallet storage information

func (*WalletStorage) Status

func (ws *WalletStorage) Status() int

Status - wallet storage status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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