本文整理匯總了Golang中github.com/eris-ltd/eris-pm/util.PreProcess函數的典型用法代碼示例。如果您正苦於以下問題:Golang PreProcess函數的具體用法?Golang PreProcess怎麽用?Golang PreProcess使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了PreProcess函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SendJob
func SendJob(send *definitions.Send, do *definitions.Do) (string, error) {
// Process Variables
send.Source, _ = util.PreProcess(send.Source, do)
send.Destination, _ = util.PreProcess(send.Destination, do)
send.Amount, _ = util.PreProcess(send.Amount, do)
// Use Default
send.Source = useDefault(send.Source, do.Package.Account)
// Don't use pubKey if account override
var oldKey string
if send.Source != do.Package.Account {
oldKey = do.PublicKey
do.PublicKey = ""
}
// Formulate tx
logger.Infof("Sending Transaction =>\t\t%s:%s:%s\n", send.Source, send.Destination, send.Amount)
tx, err := core.Send(do.Chain, do.Signer, do.PublicKey, send.Source, send.Destination, send.Amount, send.Nonce)
if err != nil {
logger.Errorf("ERROR =>\n")
return "", err
}
// Don't use pubKey if account override
if send.Source != do.Package.Account {
do.PublicKey = oldKey
}
// Sign, broadcast, display
return txFinalize(do, tx, send.Wait)
}
示例2: RebondJob
func RebondJob(rebond *definitions.Rebond, do *definitions.Do) (string, error) {
// Process Variables
rebond.Account, _ = util.PreProcess(rebond.Account, do)
rebond.Height, _ = util.PreProcess(rebond.Height, do)
// Use defaults
rebond.Account = useDefault(rebond.Account, do.Package.Account)
// Don't use pubKey if account override
var oldKey string
if rebond.Account != do.Package.Account {
oldKey = do.PublicKey
do.PublicKey = ""
}
// Formulate tx
logger.Infof("Rebond Transaction =>\t\t%s:%s\n", rebond.Account, rebond.Height)
tx, err := core.Rebond(rebond.Account, rebond.Height)
if err != nil {
logger.Errorf("ERROR =>\n")
return "", err
}
// Don't use pubKey if account override
if rebond.Account != do.Package.Account {
do.PublicKey = oldKey
}
// Sign, broadcast, display
return txFinalize(do, tx, rebond.Wait)
}
示例3: BondJob
func BondJob(bond *definitions.Bond, do *definitions.Do) (string, error) {
// Process Variables
bond.Account, _ = util.PreProcess(bond.Account, do)
bond.Amount, _ = util.PreProcess(bond.Amount, do)
bond.PublicKey, _ = util.PreProcess(bond.PublicKey, do)
// Use Defaults
bond.Account = useDefault(bond.Account, do.Package.Account)
do.PublicKey = useDefault(do.PublicKey, bond.PublicKey)
// Formulate tx
log.WithFields(log.Fields{
"public key": do.PublicKey,
"amount": bond.Amount,
}).Infof("Bond Transaction")
erisNodeClient := client.NewErisNodeClient(do.Chain)
erisKeyClient := keys.NewErisKeyClient(do.Signer)
tx, err := core.Bond(erisNodeClient, erisKeyClient, do.PublicKey, bond.Account, bond.Amount, bond.Nonce)
if err != nil {
return util.MintChainErrorHandler(do, err)
}
// Sign, broadcast, display
return txFinalize(do, tx, bond.Wait)
}
示例4: QueryContractJob
func QueryContractJob(query *definitions.QueryContract, do *definitions.Do) (string, error) {
// Preprocess variables. We don't preprocess data as it is processed by ReadAbiFormulateCall
query.Source, _ = util.PreProcess(query.Source, do)
query.Destination, _ = util.PreProcess(query.Destination, do)
// Set the from and the to
fromAddrBytes, err := hex.DecodeString(query.Source)
if err != nil {
return "", err
}
toAddrBytes, err := hex.DecodeString(query.Destination)
if err != nil {
return "", err
}
// Get the packed data from the ABI functions
data, err := util.ReadAbiFormulateCall(query.Destination, query.Data, do)
if err != nil {
return "", err
}
dataBytes, err := hex.DecodeString(data)
if err != nil {
return "", err
}
// Call the client
client := cclient.NewClient(do.Chain, "HTTP")
retrn, err := client.Call(fromAddrBytes, toAddrBytes, dataBytes)
if err != nil {
return "", err
}
// Preprocess return
result, err := util.FormatOutput([]string{"return"}, 0, retrn)
if err != nil {
return "", err
}
result, err = strconv.Unquote(result)
if err != nil {
return "", err
}
// Formally process the return
logger.Debugf("Decoding Raw Result =>\t\t%s\n", result)
result, err = util.ReadAndDecodeContractReturn(query.Destination, query.Data, result, do)
if err != nil {
return "", err
}
// Finalize
logger.Printf("Return Value =>\t\t\t%s\n", result)
return result, nil
}
示例5: QueryNameJob
func QueryNameJob(query *definitions.QueryName, do *definitions.Do) (string, error) {
// Preprocess variables
query.Name, _ = util.PreProcess(query.Name, do)
query.Field, _ = util.PreProcess(query.Field, do)
// Peform query
logger.Infof("Querying Name =>\t\t%s:%s\n", query.Name, query.Field)
result, err := util.NamesInfo(query.Name, query.Field, do)
if err != nil {
return "", err
}
logger.Printf("Return Value =>\t\t\t%s\n", result)
return result, nil
}
示例6: SetAccountJob
func SetAccountJob(account *definitions.Account, do *definitions.Do) (string, error) {
var result string
var err error
// Preprocess
account.Address, _ = util.PreProcess(account.Address, do)
// Set the Account in the Package & Announce
do.Package.Account = account.Address
log.WithField("=>", do.Package.Account).Info("Setting Account")
// Set the public key from eris-keys
keys.DaemonAddr = do.Signer
log.WithField("from", keys.DaemonAddr).Info("Getting Public Key")
do.PublicKey, err = keys.Call("pub", map[string]string{"addr": do.Package.Account, "name": ""})
if _, ok := err.(keys.ErrConnectionRefused); ok {
keys.ExitConnectErr(err)
}
if err != nil {
return util.KeysErrorHandler(do, err)
}
// Set result and return
result = account.Address
return result, nil
}
示例7: SetValJob
func SetValJob(set *definitions.Set, do *definitions.Do) (string, error) {
var result string
set.Value, _ = util.PreProcess(set.Value, do)
logger.Infof("Setting Variable =>\t\t%s\n", set.Value)
result = set.Value
return result, nil
}
示例8: QueryAccountJob
func QueryAccountJob(query *definitions.QueryAccount, do *definitions.Do) (string, error) {
// Preprocess variables
query.Account, _ = util.PreProcess(query.Account, do)
query.Field, _ = util.PreProcess(query.Field, do)
// Perform Query
logger.Infof("Querying Account =>\t\t%s:%s\n", query.Account, query.Field)
result, err := util.AccountsInfo(query.Account, query.Field, do)
if err != nil {
return "", err
}
// Result
logger.Printf("Return Value =>\t\t\t%s\n", result)
return result, nil
}
示例9: SetValJob
func SetValJob(set *definitions.Set, do *definitions.Do) (string, error) {
var result string
set.Value, _ = util.PreProcess(set.Value, do)
log.WithField("=>", set.Value).Info("Setting Variable")
result = set.Value
return result, nil
}
示例10: registerNameTx
// Runs an individual nametx.
func registerNameTx(name *definitions.RegisterName, do *definitions.Do) (string, error) {
// Process Variables
name.Source, _ = util.PreProcess(name.Source, do)
name.Name, _ = util.PreProcess(name.Name, do)
name.Data, _ = util.PreProcess(name.Data, do)
name.Amount, _ = util.PreProcess(name.Amount, do)
name.Fee, _ = util.PreProcess(name.Fee, do)
// Set Defaults
name.Source = useDefault(name.Source, do.Package.Account)
name.Fee = useDefault(name.Fee, do.DefaultFee)
name.Amount = useDefault(name.Amount, do.DefaultAmount)
// Don't use pubKey if account override
var oldKey string
if name.Source != do.Package.Account {
oldKey = do.PublicKey
do.PublicKey = ""
}
// Formulate tx
log.WithFields(log.Fields{
"name": name.Name,
"data": name.Data,
"amount": name.Amount,
}).Info("NameReg Transaction")
erisNodeClient := client.NewErisNodeClient(do.Chain)
erisKeyClient := keys.NewErisKeyClient(do.Signer)
tx, err := core.Name(erisNodeClient, erisKeyClient, do.PublicKey, name.Source, name.Amount, name.Nonce, name.Fee, name.Name, name.Data)
if err != nil {
return util.MintChainErrorHandler(do, err)
}
// Don't use pubKey if account override
if name.Source != do.Package.Account {
do.PublicKey = oldKey
}
// Sign, broadcast, display
return txFinalize(do, tx, name.Wait)
}
示例11: BondJob
func BondJob(bond *definitions.Bond, do *definitions.Do) (string, error) {
// Process Variables
bond.Account, _ = util.PreProcess(bond.Account, do)
bond.Amount, _ = util.PreProcess(bond.Amount, do)
bond.PublicKey, _ = util.PreProcess(bond.PublicKey, do)
// Use Defaults
bond.Account = useDefault(bond.Account, do.Package.Account)
do.PublicKey = useDefault(do.PublicKey, bond.PublicKey)
// Formulate tx
logger.Infof("Bond Transaction =>\t\t%s:%s\n", do.PublicKey, bond.Amount)
tx, err := core.Bond(do.Chain, do.Signer, do.PublicKey, bond.Account, bond.Amount, bond.Nonce)
if err != nil {
logger.Errorf("ERROR =>\n")
return "", err
}
// Sign, broadcast, display
return txFinalize(do, tx, bond.Wait)
}
示例12: QueryAccountJob
func QueryAccountJob(query *definitions.QueryAccount, do *definitions.Do) (string, error) {
// Preprocess variables
query.Account, _ = util.PreProcess(query.Account, do)
query.Field, _ = util.PreProcess(query.Field, do)
// Perform Query
arg := fmt.Sprintf("%s:%s", query.Account, query.Field)
log.WithField("=>", arg).Info("Querying Account")
result, err := util.AccountsInfo(query.Account, query.Field, do)
if err != nil {
return "", err
}
// Result
if result != "" {
log.WithField("=>", result).Warn("Return Value")
} else {
log.Debug("No return.")
}
return result, nil
}
示例13: QueryNameJob
func QueryNameJob(query *definitions.QueryName, do *definitions.Do) (string, error) {
// Preprocess variables
query.Name, _ = util.PreProcess(query.Name, do)
query.Field, _ = util.PreProcess(query.Field, do)
// Peform query
log.WithFields(log.Fields{
"name": query.Name,
"field": query.Field,
}).Info("Querying")
result, err := util.NamesInfo(query.Name, query.Field, do)
if err != nil {
return "", err
}
if result != "" {
log.WithField("=>", result).Warn("Return Value")
} else {
log.Debug("No return.")
}
return result, nil
}
示例14: SendJob
func SendJob(send *definitions.Send, do *definitions.Do) (string, error) {
// Process Variables
send.Source, _ = util.PreProcess(send.Source, do)
send.Destination, _ = util.PreProcess(send.Destination, do)
send.Amount, _ = util.PreProcess(send.Amount, do)
// Use Default
send.Source = useDefault(send.Source, do.Package.Account)
// Don't use pubKey if account override
var oldKey string
if send.Source != do.Package.Account {
oldKey = do.PublicKey
do.PublicKey = ""
}
// Formulate tx
log.WithFields(log.Fields{
"source": send.Source,
"destination": send.Destination,
"amount": send.Amount,
}).Info("Sending Transaction")
erisNodeClient := client.NewErisNodeClient(do.Chain)
erisKeyClient := keys.NewErisKeyClient(do.Signer)
tx, err := core.Send(erisNodeClient, erisKeyClient, do.PublicKey, send.Source, send.Destination, send.Amount, send.Nonce)
if err != nil {
return util.MintChainErrorHandler(do, err)
}
// Don't use pubKey if account override
if send.Source != do.Package.Account {
do.PublicKey = oldKey
}
// Sign, broadcast, display
return txFinalize(do, tx, send.Wait)
}
示例15: RebondJob
func RebondJob(rebond *definitions.Rebond, do *definitions.Do) (string, error) {
// Process Variables
var err error
rebond.Account, err = util.PreProcess(rebond.Account, do)
rebond.Height, err = util.PreProcess(rebond.Height, do)
if err != nil {
return "", err
}
// Use defaults
rebond.Account = useDefault(rebond.Account, do.Package.Account)
// Don't use pubKey if account override
var oldKey string
if rebond.Account != do.Package.Account {
oldKey = do.PublicKey
do.PublicKey = ""
}
// Formulate tx
log.WithFields(log.Fields{
"account": rebond.Account,
"height": rebond.Height,
}).Info("Rebond Transaction")
tx, err := core.Rebond(rebond.Account, rebond.Height)
if err != nil {
return util.MintChainErrorHandler(do, err)
}
// Don't use pubKey if account override
if rebond.Account != do.Package.Account {
do.PublicKey = oldKey
}
// Sign, broadcast, display
return txFinalize(do, tx, rebond.Wait)
}