util

package
v0.0.0-...-9259d71 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestPrivkeyHex = []string{
	"4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01",
	"CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944",
	"B0BB75BC49A787A71F4834DA18614763B53A18291ECE6B5EDEC3AD19D150C3E7",
	"56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138",
	"2AFF1981291355322C7A6308D46A9C9BA311AA21D94F36B43FC6A6021A1334CF",
	"2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989",
}

TestPrivkeyHex :

View Source
var TestPrivkeyList = []crypto.PrivKey{
	HexToPrivkey("4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01"),
	HexToPrivkey("CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"),
	HexToPrivkey("B0BB75BC49A787A71F4834DA18614763B53A18291ECE6B5EDEC3AD19D150C3E7"),
	HexToPrivkey("56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138"),
	HexToPrivkey("2AFF1981291355322C7A6308D46A9C9BA311AA21D94F36B43FC6A6021A1334CF"),
	HexToPrivkey("2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989"),
}

TestPrivkeyList :

Functions

func BitMapBit

func BitMapBit(bitmap []byte, index uint32) bool

BitMapBit :index begin from 0, find the index bit, 1 or 0

func CalcBitMap

func CalcBitMap(ori, cur [][]byte, data []*types.ReceiptData) []byte

CalcBitMap big-end mode, that is bytes [0] [1]

tx index:     fedcba98 76543210

cur is subset of ori, receipts are align with cur txs, if the tx ty is OK in cur, find the tx in ori and set the index to 1, this function return ori's bitmap if all tx failed, the setBit will normalize result and just return nil slice

func CalcSubBitMap

func CalcSubBitMap(ori, sub [][]byte, data []*types.ReceiptData) []byte

CalcSubBitMap : cur is subset of ori, data are align with ori, this function return cur's bitmap if all tx failed, the setBit will normalize result and just return nil slice

func CheckBlock

func CheckBlock(client queue.Client, block *types.BlockDetail) error

CheckBlock : To check the block's validaty

func CheckFileExists

func CheckFileExists(fileName string) (bool, error)

CheckFileExists : check file exists or not

func CheckFileIsExist

func CheckFileIsExist(filename string) bool

CheckFileIsExist : check whether the file exists or not

func CheckPathExisted

func CheckPathExisted(path string) bool

CheckPathExisted : check the path exists or not

func CheckTxDup

func CheckTxDup(client queue.Client, txs []*types.TransactionCache, height int64) (transactions []*types.TransactionCache, err error)

CheckTxDup : check whether the tx is duplicated within the while chain

func CopyFile

func CopyFile(srcFile, dstFile string) (written int64, err error)

CopyFile : copy file

func CreateCoinsTx

func CreateCoinsTx(priv crypto.PrivKey, to string, amount int64) *types.Transaction

CreateCoinsTx : Create Coins Tx

func CreateManageTx

func CreateManageTx(priv crypto.PrivKey, key, op, value string) *types.Transaction

CreateManageTx : Create Manage Tx

func CreateNewBlock

func CreateNewBlock(parent *types.Block, txs []*types.Transaction) *types.Block

CreateNewBlock : Create a New Block

func CreateNoneBlock

func CreateNoneBlock(priv crypto.PrivKey, n int64) *types.Block

CreateNoneBlock : Create None Block

func CreateNoneTx

func CreateNoneTx(priv crypto.PrivKey) *types.Transaction

CreateNoneTx : Create None Tx

func CreateTxWithExecer

func CreateTxWithExecer(priv crypto.PrivKey, execer string) *types.Transaction

CreateTxWithExecer : Create Tx With Execer

func CreateTxWithTxHeight

func CreateTxWithTxHeight(priv crypto.PrivKey, to string, amount, expire int64) *types.Transaction

CreateTxWithTxHeight : Create Tx With Tx Height

func DeleteFile

func DeleteFile(fileName string) error

DeleteFile : delete the file

func DirEmpty

func DirEmpty(path string) (bool, error)

DirEmpty : DirEmpty

func DirExists

func DirExists(path string) (bool, error)

DirExists : 检查文件夹是否存在

func ExecAndCheckBlock

func ExecAndCheckBlock(qclient queue.Client, block *types.Block, txs []*types.Transaction, status int) (*types.Block, error)

ExecAndCheckBlock : Exec and Check Block

func ExecAndCheckBlock2

func ExecAndCheckBlock2(qclient queue.Client, block *types.Block, txs []*types.Transaction, result []int) (*types.Block, error)

ExecAndCheckBlock2 :

func ExecAndCheckBlockCB

func ExecAndCheckBlockCB(qclient queue.Client, block *types.Block, txs []*types.Transaction, cb func(int, *types.ReceiptData) error) (*types.Block, error)

ExecAndCheckBlockCB :

func ExecBlock

func ExecBlock(client queue.Client, prevStateRoot []byte, block *types.Block, errReturn bool, sync bool) (*types.BlockDetail, []*types.Transaction, error)

ExecBlock : just exec block

func ExecKVMemSet

func ExecKVMemSet(client queue.Client, prevStateRoot []byte, height int64, kvset []*types.KeyValue, sync bool) []byte

ExecKVMemSet : send kv values to memory store and set it in db

func ExecKVSetCommit

func ExecKVSetCommit(client queue.Client, hash []byte) error

ExecKVSetCommit : commit the data set opetation to db

func ExecKVSetRollback

func ExecKVSetRollback(client queue.Client, hash []byte) error

ExecKVSetRollback : do the db's roll back operation

func ExecTx

func ExecTx(client queue.Client, prevStateRoot []byte, block *types.Block) *types.Receipts

ExecTx : To send lists of txs within a block to exector for exection

func GenCoinsTxs

func GenCoinsTxs(priv crypto.PrivKey, n int64) (txs []*types.Transaction)

GenCoinsTxs : generate txs to be executed on exector coin

func GenNoneTxs

func GenNoneTxs(priv crypto.PrivKey, n int64) (txs []*types.Transaction)

GenNoneTxs : 创建一些 none 执行器的 交易列表,一般用于测试

func GenTxsTxHeigt

func GenTxsTxHeigt(priv crypto.PrivKey, n, height int64) (txs []*types.Transaction)

GenTxsTxHeigt : Gen Txs with Heigt

func Genaddress

func Genaddress() (string, crypto.PrivKey)

Genaddress : generate a address

func GetParaExecName

func GetParaExecName(paraName string, name string) string

GetParaExecName : 如果 name 没有 paraName 前缀,那么加上这个前缀

func HexToPrivkey

func HexToPrivkey(key string) crypto.PrivKey

HexToPrivkey : convert hex string to private key

func JSONPrint

func JSONPrint(t *testing.T, input interface{})

JSONPrint : print in json format

func MakeDir

func MakeDir(path string) error

MakeDir : MakeDir

func MakeStringToLower

func MakeStringToLower(in string, pos, count int) (out string, err error)

MakeStringToLower : 将给定的in字符串从pos开始一共count个转换为小写字母

func MakeStringToUpper

func MakeStringToUpper(in string, pos, count int) (out string, err error)

MakeStringToUpper : 将给定的in字符串从pos开始一共count个转换为大写字母

func OpenFile

func OpenFile(fileName string) (*os.File, error)

OpenFile : OpenFile

func Pwd

func Pwd() string

Pwd : Pwd

func ReadFile

func ReadFile(file string) ([]byte, error)

ReadFile : read file

func ReportErrEventToFront

func ReportErrEventToFront(logger log.Logger, client queue.Client, frommodule string, tomodule string, err error)

ReportErrEventToFront 上报指定错误信息到指定模块,目前只支持从store,blockchain,wallet写数据库失败时上报错误信息到wallet模块, 然后由钱包模块前端定时调用显示给客户

func WriteStringToFile

func WriteStringToFile(file, content string) (writeLen int, err error)

WriteStringToFile : write content to file

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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