util

package
v0.0.0-...-3606b63 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: BSD-3-Clause Imports: 25 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 : crypto.PrivKey list addr:12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv addr:14KEKbYtKKQm4wMthSK9J4La4nAiidGozt addr:1EbDHAXpoiewjPLX9uqoz38HsKqMXayZrF addr:1PUiGcbsccfxW3zuvHXZBJfznziph5miAo addr:1KcCVZLSQYRUwE5EXTsAoQs9LuJW6xwfQa addr:1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX

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(bases, subs [][]byte, subData []*types.ReceiptData) []byte

CalcBitMap subs are align with subData,get the bases' tx's bitmap from subs result if the tx ty is OK in subs, find the tx in base and set the index to 1, this function return base's bitmap if all tx failed, the setBit will normalize result and just return nil slice

func CalcBitMapByBitMap

func CalcBitMapByBitMap(bases, subs [][]byte, bitmap []byte) []byte

CalcBitMapByBitMap bitmap align with subs

func CalcSingleBitMap

func CalcSingleBitMap(bases [][]byte, data []*types.ReceiptData) []byte

CalcSingleBitMap calc bitmap to bases by data

func CheckBlock

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

CheckBlock : To check the block's validaty

func CheckDupTx

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

CheckDupTx : check use txs []*types.Transaction and not []*types.TransactionCache

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 CloseTestDB

func CloseTestDB(dir string, dbm db.DB)

CloseTestDB 创建一个测试数据库

func CreateCoinsBlock

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

CreateCoinsBlock : create coins block, n size

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 CreateTestDB

func CreateTestDB() (string, db.DB, db.KVDB)

CreateTestDB 创建一个测试数据库

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 DelDupKey

func DelDupKey(kvs []*types.KeyValue) []*types.KeyValue

DelDupKey 删除重复的key

func DelDupTx

func DelDupTx(txs []*types.TransactionCache) (ret []*types.TransactionCache)

DelDupTx 删除重复的交易

func ExecAndCheckBlock

func ExecAndCheckBlock(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, sync, checkblock bool) (*types.BlockDetail, []*types.Transaction, error)

ExecBlock : just exec block

func ExecBlockUpgrade

func ExecBlockUpgrade(client queue.Client, prevStateRoot []byte, block *types.Block, sync bool) error

ExecBlockUpgrade : just exec block

func ExecKVMemSet

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

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

func ExecKVSetCommit

func ExecKVSetCommit(client queue.Client, hash []byte, upgrade bool) 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, error)

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

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 TestingT, input interface{})

JSONPrint : print in json format

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 PrintKV

func PrintKV(kvs []*types.KeyValue)

PrintKV 打印KVList

func ReportErrEventToFront

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

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

func ResetDatadir

func ResetDatadir(cfg *types.Config, datadir string) string

ResetDatadir 重写datadir

func SaveKVList

func SaveKVList(kvdb db.DB, kvs []*types.KeyValue)

SaveKVList 保存kvs to database

Types

type HealthCheckServer

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

HealthCheckServer a node's health check server

func NewHealthCheckServer

func NewHealthCheckServer(c queue.Client) *HealthCheckServer

NewHealthCheckServer new json rpcserver object

func (*HealthCheckServer) Close

func (s *HealthCheckServer) Close()

Close NewHealthCheckServer close

func (*HealthCheckServer) Start

func (s *HealthCheckServer) Start(cfg *types.HealthCheck)

Start HealthCheckServer start

type MockModule

type MockModule struct {
	Key string
}

MockModule struct

func (*MockModule) Close

func (m *MockModule) Close()

Close method

func (*MockModule) SetQueueClient

func (m *MockModule) SetQueueClient(client queue.Client)

SetQueueClient method

func (*MockModule) Wait

func (m *MockModule) Wait()

Wait for ready

type TestingT

type TestingT interface {
	Error(args ...interface{})
	Log(args ...interface{})
}

TestingT 测试类型

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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