mongodb

package
v0.0.0-...-25cadc1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BloomByteLength represents the number of bytes used in a header log bloom.
	BloomByteLength = 256

	// BloomBitLength represents the number of bits used in a header log bloom.
	BloomBitLength = 8 * BloomByteLength
)

Variables

This section is empty.

Functions

func ToString

func ToString(queryMap interface{}) string

ToString converts the quer map to a string.

func ToStringD

func ToStringD(queryMap bson.D) string

ToStringD converts bson.D to a string.

Types

type Block

type Block struct {
	Difficulty      string        `json:"difficulty"`
	Extra           string        `json:"extraData"`
	GasLimit        string        `json:"gasLimit"`
	GasUsed         string        `json:"gasUsed"`
	Hash            string        `json:"hash"`
	Bloom           string        `json:"logsBloom"`
	Coinbase        string        `json:"miner"`
	MixDigest       string        `json:"mixHash"`
	Nonce           string        `json:"nonce"`
	Number          string        `json:"number"`
	ParentHash      string        `json:"parentHash"`
	ReceiptHash     string        `json:"receiptsRoot"`
	UncleHash       string        `json:"sha3Uncles"`
	Size            string        `json:"size"`
	Root            string        `json:"stateRoot"`
	Time            string        `json:"timestamp"`
	TotalDifficulty string        `json:"totalDifficulty"`
	TXs             []Transaction `json:"transactions"`
	TxHash          string        `json:"transactionsRoot"`
	Uncles          []string      `json:"uncles"`
}

Block represents a block header in the Ethereum blockchain.

func (*Block) ToMBlock

func (r *Block) ToMBlock() *MBlock

ToMBlock 转为为mongodb需要的bson格式

type BlockNonce

type BlockNonce [8]byte

A BlockNonce is a 64-bit hash which proves (combined with the mix-hash) that a sufficient amount of computation has been carried out on a block.

type Bloom

type Bloom [BloomByteLength]byte

Bloom represents a 2048 bit bloom filter.

type DataMessage

type DataMessage struct {
	ID            string `bson:"_id"`
	BlockNumber   int    `bson:"block_number"`
	TransactionID string `bson:"transaction_id"`
	SequenceNum   int    `bson:"sequence_num"`
	BlockHash     string `bson:"block_hash"`
	CursorNum     int    `bson:"cursor_num"`
	CursorLabel   int    `bson:"cursor_label"`
	Lifetime      int    `bson:"lifetime"`
	Sender        string `bson:"sender"`
	Cntract       string `bson:"contract"`
	Method        string `bson:"method"`
	Param         struct {
		Filehash string `bson:"filehash"`
		Info     struct {
			Username   string `bson:"username"`
			Filename   string `bson:"filename"`
			Filesize   uint64 `bson:"filesize"`
			Filepolicy string `bson:"filepolicy"`
			Filenumber uint64 `bson:"filenumber"`
			Simorass   uint64 `bson:"simorass"`
			Optype     uint64 `bson:"optype"`
			Storeaddr  string `bson:"storeaddr"`
		} `bson:"info"`
	} `bson:"param"`
	SigAlg      int    `bson:"sig_alg"`
	Signature   string `bson:"signature"`
	CreatedTime string `bson:"created_time"`
	Version     int    `bson:"version"`
}

DataMessage struct

type MBlock

type MBlock struct {
	Difficulty      bson.Decimal128 `bson:"difficulty"`
	Extra           string          `bson:"extraData"`
	GasLimit        bson.Decimal128 `bson:"gasLimit"`
	GasUsed         bson.Decimal128 `bson:"gasUsed"`
	Hash            string          `bson:"hash"`
	Bloom           string          `bson:"logsBloom"`
	Coinbase        string          `bson:"miner"`
	MixDigest       string          `bson:"mixHash"`
	Nonce           string          `bson:"nonce"`
	Number          bson.Decimal128 `bson:"number"`
	ParentHash      string          `bson:"parentHash"`
	ReceiptHash     string          `bson:"receiptsRoot"`
	UncleHash       string          `bson:"sha3Uncles"`
	Size            bson.Decimal128 `bson:"size"`
	Root            string          `bson:"stateRoot"`
	Time            bson.Decimal128 `bson:"timestamp"`
	TotalDifficulty bson.Decimal128 `bson:"totalDifficulty"`
	TXs             []MTransaction  `bson:"transactions"`
	TxHash          string          `bson:"transactionsRoot"`
	Uncles          []string        `bson:"uncles"`
}

MBlock represents a block header in Mongodbq.

type MTransaction

type MTransaction struct {
	BlockHash        string          `bson:"blockHash"`
	BlockNumber      bson.Decimal128 `bson:"blockNumber"`
	From             string          `bson:"from"`
	Gas              bson.Decimal128 `bson:"gas"`
	GasPrice         bson.Decimal128 `bson:"gasPrice"`
	Hash             string          `bson:"hash"`
	Input            string          `bson:"input"`
	Nonce            string          `bson:"nonce"`
	To               string          `bson:"to"`
	TransactionIndex bson.Decimal128 `bson:"transactionIndex"`
	Value            bson.Decimal128 `bson:"value"`
	V                string          `bson:"v"`
	R                string          `bson:"r"`
	S                string          `bson:"s"`
}

MTransaction represents a transaction that will serialize to the RPC representation of a transaction

type MongoContext

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

MongoContext struct

func GetSession

func GetSession(url string) (*MongoContext, error)

GetSession on sever

func (*MongoContext) GetCollection

func (c *MongoContext) GetCollection(db string, collection string) *mgo.Collection

GetCollection method

func (*MongoContext) SetCollection

func (c *MongoContext) SetCollection(collection string, s func(*mgo.Collection) error) error

SetCollection method

func (*MongoContext) SetCollectionByDB

func (c *MongoContext) SetCollectionByDB(db string, collection string, s func(*mgo.Collection) error) error

SetCollectionByDB on server

func (*MongoContext) SetCollectionCount

func (c *MongoContext) SetCollectionCount(collection string, s func(*mgo.Collection) (int, error)) (int, error)

SetCollectionCount method

type MongoRepository

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

MongoRepository struct

func NewMongoRepository

func NewMongoRepository(endpoint string) *MongoRepository

NewMongoRepository creates a new MongoRepository

func (*MongoRepository) CallDataSliceIPRequest

func (r *MongoRepository) CallDataSliceIPRequest(guid string) (*util.DataDBInfo, error)

CallDataSliceIPRequest on server

func (*MongoRepository) CallIsDataExists

func (r *MongoRepository) CallIsDataExists(merkleroothash string) (uint64, error)

CallIsDataExists check

func (*MongoRepository) CallNodeRequest

func (r *MongoRepository) CallNodeRequest(seedip string) (*util.NodeDBInfo, error)

CallNodeRequest on server

type NodeMessage

type NodeMessage struct {
	ID                 bson.ObjectId `bson:"_id"`
	MessageID          int           `bson:"message_id"`
	TransactionID      string        `bson:"transaction_id"`
	Authorization      []interface{} `bson:"authorization"`
	HandlerAccountName string        `bson:"handler_account_name"`
	Type               string        `bson:"type"`
	Node               struct {
		NodeID    string `bson:"node_id"`
		BasicInfo struct {
			NodeIP      string   `bson:"node_ip"`
			NodePort    string   `bson:"node_port"`
			NodeAddress string   `bson:"node_address"`
			SeedIP      string   `bson:"seed_ip"`
			SlaveIP     []string `bson:"slave_ip"`
		} `bson:"basic_info"`
	} `bson:"node"`
	CreatedAt time.Time `bson:"createdAt"`
}

NodeMessage struct

type Transaction

type Transaction struct {
	BlockHash        string `json:"blockHash"`
	BlockNumber      string `json:"blockNumber"`
	From             string `json:"from"`
	Gas              string `json:"gas"`
	GasPrice         string `json:"gasPrice"`
	Hash             string `json:"hash"`
	Input            string `json:"input"`
	Nonce            string `json:"nonce"`
	To               string `json:"to"`
	TransactionIndex string `json:"transactionIndex"`
	Value            string `json:"value"`
	V                string `json:"v"`
	R                string `json:"r"`
	S                string `json:"s"`
}

Transaction represents a transaction that will serialize to the RPC representation of a transaction

Jump to

Keyboard shortcuts

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