utils

package
v0.0.0-...-b7062c8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2017 License: LGPL-3.0-or-later Imports: 47 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FirstBlockDir is a folder where 1block file will be stored
	FirstBlockDir = flag.String("firstBlockDir", "", "FirstBlockDir")
	// FirstBlockPublicKey is the private key
	FirstBlockPublicKey = flag.String("firstBlockPublicKey", "", "FirstBlockPublicKey")
	// FirstBlockNodePublicKey is the node private key
	FirstBlockNodePublicKey = flag.String("firstBlockNodePublicKey", "", "FirstBlockNodePublicKey")
	// FirstBlockHost is the host of the first block
	FirstBlockHost = flag.String("firstBlockHost", "", "FirstBlockHost")
	// WalletAddress is a wallet address for forging
	WalletAddress = flag.String("walletAddress", "", "walletAddress for forging ")
	// TCPHost is the tcp host
	TCPHost = flag.String("tcpHost", "", "tcpHost (e.g. 127.0.0.1)")
	// ListenHTTPPort is HTTP port
	ListenHTTPPort = flag.String("listenHttpPort", "7079", "ListenHTTPPort")
	// GenerateFirstBlock show if the first block must be generated
	GenerateFirstBlock = flag.Int64("generateFirstBlock", 0, "generateFirstBlock")
	// OldVersion is the number of the old version
	OldVersion = flag.String("oldVersion", "", "")
	// TestRollBack equals 1 for testing rollback
	TestRollBack = flag.Int64("testRollBack", 0, "testRollBack")
	// Dir is EGAAS folder
	Dir = flag.String("dir", GetCurrentDir(), "DayLight directory")
	// OldFileName is the old file name
	OldFileName = flag.String("oldFileName", "", "")
	// LogLevel is the log level
	LogLevel = flag.String("logLevel", "", "DayLight LogLevel")
	// Console equals 1 for starting in console
	Console = flag.Int64("console", 0, "Start from console")
	// StartBlockID is the start block
	StartBlockID = flag.Int64("startBlockId", 0, "Start block for blockCollection daemon")
	// EndBlockID is the end block
	EndBlockID = flag.Int64("endBlockId", 0, "End block for blockCollection daemon")
	// RollbackToBlockID is the target block for rollback
	RollbackToBlockID = flag.Int64("rollbackToBlockId", 0, "Rollback to block_id")
	// TLS is a directory for .well-known and keys. It is required for https
	TLS = flag.String("tls", "", "Support https. Specify directory for .well-known")
	// DevTools switches on dev tools in thrust shell
	DevTools = flag.Int64("devtools", 0, "Devtools in thrust-shell")
	// BoltDir is the edir for BoltDb folder
	BoltDir = flag.String("boltDir", GetCurrentDir(), "Bolt directory")
	// BoltPsw is the password for BoltDB
	BoltPsw = flag.String("boltPsw", "", "Bolt password")
	// APIToken is an api token for exchange api
	APIToken = flag.String("apiToken", "", "API Token")
	// OneCountry is the country which is supported
	OneCountry int64
	// PrivCountry is protect system from registering
	PrivCountry bool

	// LogoExt is the extension of the logotype
	LogoExt = `png`
	// DltWalletID is the wallet identifier
	DltWalletID = flag.Int64("dltWalletId", 0, "DltWalletID")

	// DaemonsChans is a slice of DaemonsChansType
	DaemonsChans []*DaemonsChansType
	// Thrust is true for thrust shell
	Thrust bool
)
View Source
var (
	// LangList is the list of available languages. It stores two-bytes codes
	LangList []string
)
View Source
var Mutex = &sync.Mutex{}

Mutex for locking DB

Functions

func A

func A(vars *map[string]string, pars ...string) (out string)

A returns href HTML tag

func And

func And(vars *map[string]string, pars ...string) string

And is a logical AND function

func Android

func Android() bool

Android checks if the app runs on Android

func AutoUpdate

func AutoUpdate(vars *map[string]string, pars ...string) string

AutoUpdate reloads inner commands each pars[0] seconds

func AutoUpdateEnd

func AutoUpdateEnd(vars *map[string]string, pars ...string) (out string)

AutoUpdateEnd must be used with AutoUpdate for text processing

func Back

func Back(vars *map[string]string, pars ...string) string

Back returns back button

func Balance

func Balance(walletID int64) (decimal.Decimal, error)

Balance returns the balance of the wallet

func Bin2Hex

func Bin2Hex(vars *map[string]string, pars ...string) string

Bin2Hex converts interface to hex string

func BinToDec

func BinToDec(bin []byte) int64

BinToDec converts input binary []byte to int64

func BinToDecBytesShift

func BinToDecBytesShift(bin *[]byte, num int64) int64

BinToDecBytesShift converts the input binary []byte to int64 and shifts the input bin

func BinToHex

func BinToHex(v interface{}) []byte

BinToHex converts interface to hex []byte

func BlockInfo

func BlockInfo(vars *map[string]string, pars ...string) string

BlockInfo returns returns a link for popup block

func BtnContract

func BtnContract(vars *map[string]string, pars ...string) string

BtnContract returns the button for executing of the contract

func BtnEdit

func BtnEdit(vars *map[string]string, pars ...string) string

BtnEdit returns button HTML tag with an icon

func BtnPage

func BtnPage(vars *map[string]string, pars ...string) string

BtnPage returns the button HTML tag with the link to the template page

func BytesShift

func BytesShift(str *[]byte, index int64) (ret []byte)

BytesShift returns the index bytes of the input []byte and shift str pointer

func BytesShiftReverse

func BytesShiftReverse(str *[]byte, v interface{}) []byte

BytesShiftReverse gets []byte from the end of the input and cut the input pointer to []byte

func BytesToFloat64

func BytesToFloat64(s []byte) float64

BytesToFloat64 converts []byte to float64

func BytesToInt

func BytesToInt(s []byte) int

BytesToInt converts []byte to integer

func BytesToInt64

func BytesToInt64(s []byte) int64

BytesToInt64 converts []bytes to int64

func CallMethod

func CallMethod(i interface{}, methodName string) interface{}

CallMethod calls the function by its name

func Caller

func Caller(steps int) string

Caller returns the name of the latest function

func ChartBar

func ChartBar(vars *map[string]string, pars *map[string]string) string

ChartBar returns bar chart with the information from the database

func ChartPie

func ChartPie(vars *map[string]string, pars *map[string]string) string

ChartPie returns pie chart with the information from the database

func CheckInputData

func CheckInputData(idata interface{}, dataType string) bool

CheckInputData checks the input data

func CheckSign

func CheckSign(publicKeys [][]byte, forSign string, signs []byte, nodeKeyOrLogin bool) (bool, error)

CheckSign checks the signature

func CmpTime

func CmpTime(vars *map[string]string, pars ...string) string

CmpTime compares two time. It returns 0 if they equal, -1 - left < right, 1 - left > right

func CopyFileContents

func CopyFileContents(src, dst string) error

CopyFileContents copy files

func CreateHTMLFromTemplate

func CreateHTMLFromTemplate(page string, citizenID, stateID int64, params *map[string]string) (string, error)

CreateHTMLFromTemplate gets the template of the page from the table and proceeds it

func DSha256

func DSha256(v interface{}) []byte

DSha256 returns the double calculation of SHA256 hash

func Date

func Date(vars *map[string]string, pars ...string) string

Date formats the date value

func DateTime

func DateTime(vars *map[string]string, pars ...string) string

DateTime formats the date/time value

func DecToBin

func DecToBin(v interface{}, sizeBytes int64) []byte

DecToBin converts interface to []byte

func DecodeLength

func DecodeLength(buf *[]byte) (ret int64)

DecodeLength decodes length from []byte

func DecryptCFB

func DecryptCFB(iv, encrypted, key []byte) ([]byte, error)

DecryptCFB decrypts the ciphertext with AES CFB

func DefLang

func DefLang() string

DefLang returns the default language

func Desktop

func Desktop() bool

Desktop checks if the app runs on the desktop with thrust_shell

func Div

func Div(vars *map[string]string, pars ...string) (out string)

Div returns div HTML tag

func Divs

func Divs(vars *map[string]string, pars ...string) (out string)

Divs returns nested div HTML tags

func DivsEnd

func DivsEnd(vars *map[string]string, pars ...string) (out string)

DivsEnd closes divs which has been created with Divs function

func DownloadToFile

func DownloadToFile(url, file string, timeoutSec int64, DaemonCh chan bool, AnswerDaemonCh chan string, GoroutineName string) (int64, error)

DownloadToFile downloads and saves the specified file

func EGSRate

func EGSRate(idstate int64) (float64, error)

EGSRate returns egs_rate of the state

func EgaasUpdate

func EgaasUpdate(url string) error

EgaasUpdate decompresses and updates executable file

func Else

func Else(vars *map[string]string, pars ...string) string

Else function emulates else in conditional operator for text processing

func ElseIf

func ElseIf(vars *map[string]string, pars ...string) string

ElseIf function emulates 'else if' for text processing

func Em

func Em(vars *map[string]string, pars ...string) (out string)

Em returns em HTML tag

func EncodeLengthPlusData

func EncodeLengthPlusData(idata interface{}) []byte

EncodeLengthPlusData encoding interface into []byte

func EncryptCFB

func EncryptCFB(text, key, iv []byte) ([]byte, []byte, error)

EncryptCFB encrypts the text with AES CFB

func ErrInfo

func ErrInfo(verr interface{}, additionally ...string) error

ErrInfo formats the error message

func ErrInfoFmt

func ErrInfoFmt(err string, a ...interface{}) error

ErrInfoFmt fomats the error message

func FirstBlock

func FirstBlock(exit bool)

FirstBlock generates the first block

func Float64ToStr

func Float64ToStr(f float64) string

Float64ToStr converts float64 to string

func ForList

func ForList(vars *map[string]string, pars ...string) string

ForList emulates for operator in text processing

func ForListEnd

func ForListEnd(vars *map[string]string, pars ...string) (out string)

ForListEnd must be used with ForList for text processing

func Form

func Form(vars *map[string]string, pars ...string) string

Form returns the form HTML tag

func FormEnd

func FormEnd(vars *map[string]string, pars ...string) string

FormEnd closes the form HTML tag

func FormatQueryArgs

func FormatQueryArgs(q, dbType string, args ...interface{}) (string, []interface{})

FormatQueryArgs formats the query

func FullScreen

func FullScreen(vars *map[string]string, pars ...string) string

FullScreen inserts java script for switching the workarea to the full browser window

func GetBlockBody

func GetBlockBody(host string, blockID int64, dataTypeBlockBody int64) ([]byte, error)

GetBlockBody gets the block data

func GetColumnType

func GetColumnType(tblname, column string) (itype string)

GetColumnType returns the type of the column

func GetCurrentDir

func GetCurrentDir() string

GetCurrentDir returns the current directory

func GetEndBlockID

func GetEndBlockID() (int64, error)

GetEndBlockID returns the end block id

func GetHTTPTextAnswer

func GetHTTPTextAnswer(url string) (string, error)

GetHTTPTextAnswer returns HTTP answer as a string

func GetList

func GetList(vars *map[string]string, pars ...string) string

GetList assigns the result of sql request to the variables

func GetMap

func GetMap(vars *map[string]string, pars ...string) string

GetMap assigns the result of sql request to the variable and parse it to map

func GetMrklroot

func GetMrklroot(binaryData []byte, first bool) ([]byte, error)

GetMrklroot returns MerkleTreeRoot

func GetNetworkTime

func GetNetworkTime() (*time.Time, error)

GetNetworkTime returns the network time

func GetOne

func GetOne(vars *map[string]string, pars ...string) string

GetOne returns the single value of sql query.

func GetParent

func GetParent() string

GetParent returns the information where the call of function happened

func GetPrefix

func GetPrefix(tableName, stateID string) (string, error)

GetPrefix returns the prefix of the table. In this case it is checked that the prefix was global or matched with the identifier of the state

func GetRowVars

func GetRowVars(vars *map[string]string, pars ...string) string

GetRowVars assignes the value of row result to the variables

func GetTxTypeAndUserID

func GetTxTypeAndUserID(binaryBlock []byte) (txType int64, walletID int64, citizenID int64)

GetTxTypeAndUserID returns tx type, wallet and citizen id from the block data

func GetUpdVerAndURL

func GetUpdVerAndURL(host string) (updinfo *lib.Update, err error)

GetUpdVerAndURL downloads the information about the version

func GetVar

func GetVar(vars *map[string]string, pars ...string) (out string)

GetVar returns the processed value of the variable

func HexToBin

func HexToBin(ihexdata interface{}) []byte

HexToBin converts hex interface to binary []byte

func IDToAddress

func IDToAddress(vars *map[string]string, pars ...string) string

IDToAddress converts the number to the wallet address

func IOS

func IOS() bool

IOS checks if the app runs on iOS

func If

func If(vars *map[string]string, pars ...string) string

If function emulates conditional operator for text processing

func IfEnd

func IfEnd(vars *map[string]string, pars ...string) string

IfEnd must be used at the end of If operator for text processing

func Image

func Image(vars *map[string]string, pars ...string) string

Image returns image HTML tag

func ImageInput

func ImageInput(vars *map[string]string, pars ...string) string

ImageInput returns HTML tags for uploading image

func InSliceString

func InSliceString(search string, slice []string) bool

InSliceString searches the string in the slice of strings

func Include

func Include(vars *map[string]string, pars ...string) string

Include returns the another template page

func Input

func Input(vars *map[string]string, pars ...string) string

Input returns input HTML tag

func InputAddress

func InputAddress(vars *map[string]string, pars ...string) string

InputAddress returns input HTML tag for entering wallet address

func InputCheckbox

func InputCheckbox(vars *map[string]string, pars ...string) string

InputCheckbox returns styled input HTML tag with checkbox type

func InputDate

func InputDate(vars *map[string]string, pars ...string) string

InputDate returns input HTML tag with datepicker

func InputMap

func InputMap(vars *map[string]string, pars ...string) string

InputMap returns HTML tags for map point

func InputMapPoly

func InputMapPoly(vars *map[string]string, pars ...string) string

InputMapPoly returns HTML tags for polygon map

func InputMoney

func InputMoney(vars *map[string]string, pars ...string) string

InputMoney returns input HTML tag with a special money mask

func Int64ToByte

func Int64ToByte(num int64) []byte

Int64ToByte converts int64 to []byte

func Int64ToStr

func Int64ToStr(num int64) string

Int64ToStr converts int64 to string

func IntToStr

func IntToStr(num int) string

IntToStr converts integer to string

func InterfaceSliceToStr

func InterfaceSliceToStr(i []interface{}) []string

InterfaceSliceToStr converts the slice of interfaces to the slice of strings

func InterfaceToFloat64

func InterfaceToFloat64(i interface{}) float64

InterfaceToFloat64 converts the interfaces to the float64

func InterfaceToStr

func InterfaceToStr(v interface{}) string

InterfaceToStr converts the interfaces to the string

func IsLang

func IsLang(code string) bool

IsLang checks if there is a language with code name

func JSONScript

func JSONScript(vars *map[string]string, pars ...string) string

JSONScript returns json object

func Label

func Label(vars *map[string]string, pars ...string) string

Label returns the label HTML tag

func LangJS

func LangJS(vars *map[string]string, pars ...string) string

LangJS returns span tag for the language resource

func LangMacro

func LangMacro(input string, state int, accept string) string

LangMacro replaces all inclusions of $resname$ in the incoming text with the corresponding language resources, if they exist

func LangRes

func LangRes(vars *map[string]string, pars ...string) string

LangRes returns the corresponding language resource of the specified parameter

func LangText

func LangText(in string, state int, accept string) (string, bool)

LangText looks for the specified word through language sources and returns the meaning of the source if it is found. Search goes according to the languages specified in 'accept'

func Legend

func Legend(vars *map[string]string, pars ...string) (out string)

Legend returns the legend HTML tag

func Li

func Li(vars *map[string]string, pars ...string) (out string)

Li returns li HTML tag

func LiBegin

func LiBegin(vars *map[string]string, pars ...string) string

LiBegin opens li HTML tag

func LiEnd

func LiEnd(vars *map[string]string, pars ...string) string

LiEnd closes li HTML tag

func LiTemplate

func LiTemplate(vars *map[string]string, pars ...string) string

LiTemplate returns li HTML tag with a link to the template page

func LinkPage

func LinkPage(vars *map[string]string, pars ...string) string

LinkPage returns the HTML link to the template page

func ListVal

func ListVal(vars *map[string]string, pars ...string) string

ListVal returns the value of the list as the value of the variable

func LoadContract

func LoadContract(prefix string) (err error)

LoadContract reads and compiles contract of new state

func LoadContracts

func LoadContracts() (err error)

LoadContracts reads and compiles contracts from smart_contracts tables

func Map

func Map(vars *map[string]string, pars ...string) string

Map returns a map widget

func MapPoint

func MapPoint(vars *map[string]string, pars ...string) string

MapPoint returns a map widget with a baloon

func MarkDown

func MarkDown(vars *map[string]string, pars ...string) string

MarkDown returns processed markdown text

func Md5

func Md5(v interface{}) []byte

Md5 returns the hex MD5 hash

func MenuBack(vars *map[string]string, pars ...string) string

MenuBack returns a special menu link

func MenuEnd(vars *map[string]string, pars ...string) string

MenuEnd closes menu tags

func MenuGroup(vars *map[string]string, pars ...string) string

MenuGroup returns a group of the menu items

func MenuItem(vars *map[string]string, pars ...string) string

MenuItem returns a menu item

func MenuPage(vars *map[string]string, pars ...string) string

MenuPage returns a special comment for the menu

func MerkleTreeRoot

func MerkleTreeRoot(dataArray [][]byte) []byte

MerkleTreeRoot rertun Merkle value

func MessageBoard

func MessageBoard(vars *map[string]string, pars ...string) string

MessageBoard returns HTML source for displaying messages

func Mobile

func Mobile() bool

Mobile checks if the app runs on Android or iOS

func Money

func Money(vars *map[string]string, pars ...string) string

Money returns the formated value of the specified money amount

func Mult

func Mult(vars *map[string]string, pars ...string) string

Mult multiplies two float64 values

func Navigation(vars *map[string]string, pars ...string) string

Navigation returns bread crumb navigation links

func Now

func Now(vars *map[string]string, pars ...string) string

Now returns the current time of postgresql

func Or

func Or(vars *map[string]string, pars ...string) string

Or is a logical OR function

func PageEnd

func PageEnd(vars *map[string]string, pars ...string) string

PageEnd closes the page panel

func PageTitle

func PageTitle(vars *map[string]string, pars ...string) string

PageTitle returns the header of the page panel

func Par

func Par(vars *map[string]string, pars ...string) (out string)

Par returns paragraph HTML tag

func Param

func Param(vars *map[string]string, pars ...string) string

Param returns the value of the specified varaible

func ProceedTemplate

func ProceedTemplate(html string, data interface{}) (string, error)

ProceedTemplate proceeds html template

func RSortMap

func RSortMap(m map[int64]string) []map[int64]string

RSortMap sorts map to the reversed slice of maps

func RandInt

func RandInt(min int, max int) int

RandInt returns a random integer between min and max

func RandSeq

func RandSeq(n int) string

RandSeq generates a random string

func ReplQ

func ReplQ(q string) string

ReplQ preprocesses a database query

func Ring

func Ring(vars *map[string]string, pars ...string) string

Ring returns a ring HTML control

func Round

func Round(num float64, precision int) float64

Round rounds float64 value

func Select

func Select(vars *map[string]string, pars ...string) string

Select returns select HTML tag

func SetVar

func SetVar(vars *map[string]string, pars ...string) string

SetVar assigns the value to the variable

func Sha256

func Sha256(v interface{}) []byte

Sha256 returns SHA256 hash

func ShellExecute

func ShellExecute(cmdline string)

ShellExecute runs cmdline

func Sleep

func Sleep(sec time.Duration)

Sleep makes a pause during sec seconds

func SliceReverse

func SliceReverse(s []int64) []int64

SliceReverse reverses the slice of int64

func Small

func Small(vars *map[string]string, pars ...string) (out string)

Small returns small HTML tag

func SortMap

func SortMap(m map[int64]string) []map[int64]string

SortMap sorts map to the slice of maps

func Source

func Source(vars *map[string]string, pars ...string) string

Source returns HTML control for source code

func Span

func Span(vars *map[string]string, pars ...string) (out string)

Span returns span HTML tag

func StateLink(vars *map[string]string, pars ...string) string

StateLink returns the value of the variable

func StateParam

func StateParam(idstate int64, name string) (string, error)

StateParam returns the value of state parameters

func StateVal

func StateVal(vars *map[string]string, pars ...string) string

StateVal returns par[1]-th value of pars[0] state param

func StrToFloat64

func StrToFloat64(s string) float64

StrToFloat64 converts string to float64

func StrToInt

func StrToInt(s string) int

StrToInt converts string to integer

func StrToInt64

func StrToInt64(s string) int64

StrToInt64 converts string to int64

func StrToMoney

func StrToMoney(str string) float64

StrToMoney rounds money string to float64

func StrToUint64

func StrToUint64(s string) uint64

StrToUint64 converts string to the unsinged int64

func Strong

func Strong(vars *map[string]string, pars ...string) (out string)

Strong returns strong HTML tag

func TCPConn

func TCPConn(Addr string) (net.Conn, error)

TCPConn connects to the address

func TXButton

func TXButton(vars *map[string]string, pars *map[string]string) string

TXButton returns button which calls the contract

func TXForm

func TXForm(vars *map[string]string, pars *map[string]string) string

TXForm returns HTML form for the contract

func Table

func Table(vars *map[string]string, pars *map[string]string) string

Table returns table HTML tag with the result of sql query

func Tag

func Tag(vars *map[string]string, pars ...string) (out string)

Tag returns the specified HTML tag

func TextHidden

func TextHidden(vars *map[string]string, pars ...string) (out string)

TextHidden returns hidden textarea HTML tag

func Textarea

func Textarea(vars *map[string]string, pars ...string) string

Textarea returns textarea HTML tag

func Time

func Time() int64

Time returns th ecurrent Unix time

func Title

func Title(vars *map[string]string, pars ...string) string

Title returns a div tag with the title class

func Trim

func Trim(vars *map[string]string, pars ...string) string

Trim trims spaces at the beginning and at the end of the text

func TxForm

func TxForm(vars *map[string]string, pars *map[string]string) string

TxForm returns HTML form for the contract

func TxID

func TxID(vars *map[string]string, pars ...string) string

TxID returns the integer value of the transaction

func TypeInt

func TypeInt(txType string) int64

TypeInt returns the identifier of the embedded transaction

func UInt32ToStr

func UInt32ToStr(num uint32) string

UInt32ToStr converts uint32 to string

func UList

func UList(vars *map[string]string, pars ...string) string

UList creates ol or ul HTML tag

func UListEnd

func UListEnd(vars *map[string]string, pars ...string) string

UListEnd closes ol or ul HTMl tag

func UpdateLang

func UpdateLang(state int, name, value string)

UpdateLang updates language sources for the specified state

func Upload

func Upload(vars *map[string]string, pars ...string) string

Upload is a simple input[type='file'] wrapper to do the uploading

func Val

func Val(vars *map[string]string, pars ...string) string

Val returns the value of the html control with id identifier

func ValidateEmail

func ValidateEmail(email string) bool

ValidateEmail validates email

func ValueByID

func ValueByID(vars *map[string]string, pars ...string) string

ValueByID gets a row from table with the specified id and aasigns the values of fields to variables

func WhiteBg

func WhiteBg(vars *map[string]string, pars ...string) string

WhiteBg switches flatPageMobile class

func WhiteMobileBg

func WhiteMobileBg(vars *map[string]string, pars ...string) string

WhiteMobileBg switches flatPageMobile class

func WiAccount

func WiAccount(vars *map[string]string, pars ...string) string

WiAccount returns an account widget

func WiBalance

func WiBalance(vars *map[string]string, pars ...string) string

WiBalance returns a balance widget

func WiCitizen

func WiCitizen(vars *map[string]string, pars ...string) string

WiCitizen returns a widget with the information about the citizen

func WriteSelectiveLog

func WriteSelectiveLog(text interface{})

WriteSelectiveLog writes info into SelectiveLog.txt

func WriteSizeAndData

func WriteSizeAndData(binaryData []byte, conn net.Conn) error

WriteSizeAndData writes []byte to the connection

Types

type BlockData

type BlockData struct {
	BlockId  int64
	Time     int64
	WalletId int64
	StateID  int64
	Sign     []byte
	Hash     []byte
}

BlockData is a structure of the block's header

func ParseBlockHeader

func ParseBlockHeader(binaryBlock *[]byte) *BlockData

ParseBlockHeader parses the header of the block

type CommonPage

type CommonPage struct {
	Address   string
	WalletId  int64
	CitizenId int64
	StateId   int64
	StateName string
}

CommonPage contains the common information for each template page

type DCDB

type DCDB struct {
	*sql.DB
	ConfigIni map[string]string
}

DCDB is a database structure

var DB *DCDB

DB is a database variable

func NewDbConnect

func NewDbConnect(ConfigIni map[string]string) (*DCDB, error)

NewDbConnect creates a new database connection

func (*DCDB) CheckDaemonsRestart

func (db *DCDB) CheckDaemonsRestart() bool

CheckDaemonsRestart is reserved

func (*DCDB) CheckDelegateCB

func (db *DCDB) CheckDelegateCB(myStateID int64) (bool, error)

CheckDelegateCB checks if the state is delegated

func (*DCDB) CheckInstall

func (db *DCDB) CheckInstall(DaemonCh chan bool, AnswerDaemonCh chan string, GoroutineName string) bool

CheckInstall waits for the end of the installation

func (*DCDB) CheckStateName

func (db *DCDB) CheckStateName(stateID int64) (bool, error)

CheckStateName checks if the state id is valid

func (*DCDB) DbLock

func (db *DCDB) DbLock(DaemonCh chan bool, AnswerDaemonCh chan string, goRoutineName string) (bool, error)

DbLock locks deamons

func (*DCDB) DbUnlock

func (db *DCDB) DbUnlock(goRoutineName string) error

DbUnlock unlocks database

func (*DCDB) DecryptData

func (db *DCDB) DecryptData(binaryTx *[]byte) ([]byte, []byte, []byte, error)

DecryptData decrypts tx data

func (*DCDB) DelLogTx

func (db *DCDB) DelLogTx(binaryTx []byte) error

DelLogTx deletes a row with the specified md5 hash in log_transaction

func (*DCDB) DeleteQueueBlock

func (db *DCDB) DeleteQueueBlock(hashHex string) error

DeleteQueueBlock deletes a row from queue_blocks with the specified hash

func (*DCDB) ExecSQL

func (db *DCDB) ExecSQL(query string, args ...interface{}) error

ExecSQL executes the query

func (*DCDB) ExecSQLGetAffect

func (db *DCDB) ExecSQLGetAffect(query string, args ...interface{}) (int64, error)

ExecSQLGetAffect executes the query and returns amount of affected rows

func (*DCDB) ExecSQLGetLastInsertID

func (db *DCDB) ExecSQLGetLastInsertID(query, table string, args ...interface{}) (string, error)

ExecSQLGetLastInsertID inserts a row and returns the last id

func (*DCDB) FindInFullNodes

func (db *DCDB) FindInFullNodes(myStateID, myWalletID int64) (int64, error)

FindInFullNodes returns id of the node

func (*DCDB) FormatQuery

func (db *DCDB) FormatQuery(q string) string

FormatQuery formats the query

func (*DCDB) GetAiID

func (db *DCDB) GetAiID(table string) (string, error)

GetAiID returns auto increment column

func (*DCDB) GetAll

func (db *DCDB) GetAll(query string, countRows int, args ...interface{}) ([]map[string]string, error)

GetAll returns the result of the query as slice of map[string]string

func (*DCDB) GetAllTables

func (db *DCDB) GetAllTables() ([]string, error)

GetAllTables returns the list of the tables

func (*DCDB) GetBinSign

func (db *DCDB) GetBinSign(forSign string) ([]byte, error)

GetBinSign returns a signature made with node private key

func (*DCDB) GetBlockDataFromBlockChain

func (db *DCDB) GetBlockDataFromBlockChain(blockID int64) (*BlockData, error)

GetBlockDataFromBlockChain returns the block information from the blockchain

func (*DCDB) GetBlockID

func (db *DCDB) GetBlockID() (int64, error)

GetBlockID return the latest block id from info_block

func (*DCDB) GetConfirmedBlockID

func (db *DCDB) GetConfirmedBlockID() (int64, error)

GetConfirmedBlockID returns the maximal block id from confirmations

func (*DCDB) GetFirstColumnName

func (db *DCDB) GetFirstColumnName(table string) (string, error)

GetFirstColumnName returns the name of the first column in the table

func (*DCDB) GetFirstColumnNamesPg

func (db *DCDB) GetFirstColumnNamesPg(table string) (string, error)

GetFirstColumnNamesPg returns the first name of the column with PostgreSQL request

func (*DCDB) GetFuel

func (db *DCDB) GetFuel() decimal.Decimal

GetFuel returns the fuel rate

func (*DCDB) GetHosts

func (db *DCDB) GetHosts() ([]string, error)

GetHosts returns the list of hosts

func (*DCDB) GetInfoBlock

func (db *DCDB) GetInfoBlock() (map[string]string, error)

GetInfoBlock returns the information about the latest block

func (*DCDB) GetLastBlockData

func (db *DCDB) GetLastBlockData() (map[string]int64, error)

GetLastBlockData returns the data of the latest block

func (*DCDB) GetList

func (db *DCDB) GetList(query string, args ...interface{}) *ListResult

GetList returns the result of the query as ListResult variable

func (*DCDB) GetMap

func (db *DCDB) GetMap(query string, name, value string, args ...interface{}) (map[string]string, error)

GetMap returns the map of strings as the result of query

func (*DCDB) GetMyStateID

func (db *DCDB) GetMyStateID() (int64, error)

GetMyStateID returns state id from config

func (*DCDB) GetMyStateIDAndWalletID

func (db *DCDB) GetMyStateIDAndWalletID() (int64, int64, error)

GetMyStateIDAndWalletID returns state id and wallet id from config

func (*DCDB) GetMyWalletID

func (db *DCDB) GetMyWalletID() (int64, error)

GetMyWalletID returns wallet id from config

func (*DCDB) GetNodeConfig

func (db *DCDB) GetNodeConfig() (map[string]string, error)

GetNodeConfig returns config parameters

func (*DCDB) GetNodePrivateKey

func (db *DCDB) GetNodePrivateKey() (string, error)

GetNodePrivateKey returns the private key from my_nodes_key

func (*DCDB) GetNodePublicKey

func (db *DCDB) GetNodePublicKey(waletID int64) ([]byte, error)

GetNodePublicKey returns the node public key of the wallet id

func (*DCDB) GetNodePublicKeyWalletOrCB

func (db *DCDB) GetNodePublicKeyWalletOrCB(walletID, stateID int64) ([]byte, error)

GetNodePublicKeyWalletOrCB returns node public key of wallet id or state id

func (*DCDB) GetPublicKeyWalletOrCitizen

func (db *DCDB) GetPublicKeyWalletOrCitizen(walletID, citizenID int64) ([]byte, error)

GetPublicKeyWalletOrCitizen returns public key of the wallet id or citizen id

func (*DCDB) GetSleepTime

func (db *DCDB) GetSleepTime(myWalletID, myStateID, prevBlockStateID, prevBlockWalletID int64) (int64, error)

GetSleepTime returns the waiting time for wallet id and state id

func (*DCDB) GetStateName

func (db *DCDB) GetStateName(stateID int64) (string, error)

GetStateName returns the name of the state

func (*DCDB) GetWalletIDByPublicKey

func (db *DCDB) GetWalletIDByPublicKey(publicKey []byte) (int64, error)

GetWalletIDByPublicKey converts public key to wallet id

func (*DCDB) InsertInLogTx

func (db *DCDB) InsertInLogTx(binaryTx []byte, time int64) error

InsertInLogTx inserts md5 hash and time into log_transaction

func (*DCDB) InsertReplaceTxInQueue

func (db *DCDB) InsertReplaceTxInQueue(data []byte) error

InsertReplaceTxInQueue replaces a row in queue_tx

func (*DCDB) IsCustomTable

func (db *DCDB) IsCustomTable(table string) (isCustom bool, err error)

IsCustomTable checks if the table is created by the users

func (*DCDB) IsIndex

func (db *DCDB) IsIndex(tblname, column string) (bool, error)

IsIndex checks if the table has the index for the column

func (*DCDB) IsNodeState

func (db *DCDB) IsNodeState(state int64, host string) bool

IsNodeState checks if the state is specified as node_stat_id in config file

func (*DCDB) IsState

func (db *DCDB) IsState(country string) (int64, error)

IsState returns the identifier of the state

func (*DCDB) IsTable

func (db *DCDB) IsTable(tblname string) bool

IsTable checks if there is a table with this name

func (*DCDB) NodesBan

func (db *DCDB) NodesBan(info string) error

NodesBan is reserved

func (*DCDB) NumIndexes

func (db *DCDB) NumIndexes(tblname string) (int, error)

NumIndexes returns the amount of the indexes in the table

func (*DCDB) OneRow

func (db *DCDB) OneRow(query string, args ...interface{}) *oneRow

OneRow returns the result of the query as one row

func (*DCDB) PrintSleep

func (db *DCDB) PrintSleep(v interface{}, sleep time.Duration)

PrintSleep writes the error to log and make a pause

func (*DCDB) QueryRows

func (db *DCDB) QueryRows(query string, args ...interface{}) (*sql.Rows, error)

QueryRows returns the result of the query

func (*DCDB) SendTx

func (db *DCDB) SendTx(txType int64, adminWallet int64, data []byte) (err error)

SendTx writes transaction info to transactions_status & queue_tx

func (*DCDB) SetAI

func (db *DCDB) SetAI(table string, AI int64) error

SetAI sets serial sequence for the table

func (*DCDB) Single

func (db *DCDB) Single(query string, args ...interface{}) *SingleResult

Single returns the single result of the query

func (*DCDB) UpdDaemonTime

func (db *DCDB) UpdDaemonTime(name string)

UpdDaemonTime is reserved

func (*DCDB) UpdMainLock

func (db *DCDB) UpdMainLock() error

UpdMainLock updates the lock time

func (*DCDB) UpdateFuel

func (db *DCDB) UpdateFuel()

UpdateFuel is reserved

type DaemonsChansType

type DaemonsChansType struct {
	ChBreaker chan bool
	ChAnswer  chan string
}

DaemonsChansType is a structure for deamons

type FieldInfo

type FieldInfo struct {
	Name     string      `json:"name"`
	HTMLType string      `json:"htmlType"`
	TxType   string      `json:"txType"`
	Title    string      `json:"title"`
	Value    interface{} `json:"value"`
	Param    string      `json:"param"`
}

FieldInfo contains the information of contract data field

type FormInfo

type FormInfo struct {
	TxName    string
	Unique    template.JS
	OnSuccess template.JS
	Fields    []FieldInfo
	AutoClose bool
	Silent    bool
}

FormInfo contains parameters of TxForm function

type ListResult

type ListResult struct {
	// contains filtered or unexported fields
}

ListResult is a structure for the list result

func (*ListResult) Int64

func (r *ListResult) Int64() ([]int64, error)

Int64 converts all string values to int64

func (*ListResult) String

func (r *ListResult) String() ([]string, error)

String return the slice of strings

type PageTpl

type PageTpl struct {
	Page     string
	Template string
	Unique   string
	Data     interface{} //*CommonPage
}

PageTpl is the main structure for the template page

type SelInfo

type SelInfo struct {
	ID   int64
	Name string
}

SelInfo is a structure for an item of selectable data

type SelList

type SelList struct {
	Cur  int64          `json:"cur"`
	List map[int]string `json:"list"`
}

SelList is a structure for selectable data

type SingleResult

type SingleResult struct {
	// contains filtered or unexported fields
}

SingleResult is a structure for the single result

func (*SingleResult) Bytes

func (r *SingleResult) Bytes() ([]byte, error)

Bytes returns []byte

func (*SingleResult) Float64

func (r *SingleResult) Float64() (float64, error)

Float64 converts string to float64

func (*SingleResult) Int

func (r *SingleResult) Int() (int, error)

Int converts bytes to int

func (*SingleResult) Int64

func (r *SingleResult) Int64() (int64, error)

Int64 converts bytes to int64

func (*SingleResult) String

func (r *SingleResult) String() (string, error)

String returns string

type TxBtnCont

type TxBtnCont struct {
	TxName    string
	Name      string
	Class     string
	ClassBtn  string
	Unique    template.JS
	OnSuccess template.JS
	Fields    []TxInfo
	AutoClose bool
	Silent    bool
}

TxBtnCont contains parameters of TxBtnCont function

type TxButtonInfo

type TxButtonInfo struct {
	TxName    string
	Name      string
	Class     string
	ClassBtn  string
	Unique    template.JS
	OnSuccess template.JS
	Fields    []TxInfo
	AutoClose bool
	Silent    bool
}

TxButtonInfo contains parameters of TxButton function

type TxInfo

type TxInfo struct {
	Name     string `json:"name"`
	ID       string `json:"id"`
	Value    string `json:"value"`
	HTMLType string `json:"htmlType"`
	Param    string `json:"param"`
}

TxInfo contains the information of contract data field in TxButton function

Jump to

Keyboard shortcuts

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