-
Notifications
You must be signed in to change notification settings - Fork 15
/
mlog.go
102 lines (92 loc) · 3.02 KB
/
mlog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package core
import (
"github.com/ellaism/go-ellaism/logger"
)
var mlogBlockchain = logger.MLogRegisterAvailable("blockchain", mLogLinesBlockchain)
var mlogTxPool = logger.MLogRegisterAvailable("txpool", mLogLinesTxPool)
// mLogLines is an private slice of all available mlog LINES.
// May be used for automatic mlog documentation generator, or
// for API usage/display/documentation otherwise.
var mLogLinesBlockchain = []logger.MLogT{
mlogBlockchainWriteBlock,
mlogBlockchainInsertBlocks,
}
var mLogLinesTxPool = []logger.MLogT{
mlogTxPoolAddTx,
mlogTxPoolValidateTx,
}
// Collect and document available mlog lines.
var mlogBlockchainWriteBlock = logger.MLogT{
Description: `Called when a single block written to the chain database.
A STATUS of NONE means it was written _without_ any abnormal chain event, such as a split.`,
Receiver: "BLOCKCHAIN",
Verb: "WRITE",
Subject: "BLOCK",
Details: []logger.MLogDetailT{
{"WRITE", "STATUS", "STRING"},
{"WRITE", "ERROR", "STRING_OR_NULL"},
{"BLOCK", "NUMBER", "BIGINT"},
{"BLOCK", "HASH", "STRING"},
{"BLOCK", "SIZE", "INT64"},
{"BLOCK", "TRANSACTIONS_COUNT", "INT"},
{"BLOCK", "GAS_USED", "BIGINT"},
{"BLOCK", "COINBASE", "STRING"},
{"BLOCK", "TIME", "BIGINT"},
{"BLOCK", "DIFFICULTY", "BIGINT"},
{"BLOCK", "UNCLES", "INT"},
{"BLOCK", "RECEIVED_AT", "BIGINT"},
{"BLOCK", "DIFF_PARENT_TIME", "BIGINT"},
},
}
var mlogBlockchainInsertBlocks = logger.MLogT{
Description: "Called when a chain of blocks is inserted into the chain database.",
Receiver: "BLOCKCHAIN",
Verb: "INSERT",
Subject: "BLOCKS",
Details: []logger.MLogDetailT{
{"BLOCKS", "COUNT", "INT"},
{"BLOCKS", "QUEUED", "INT"},
{"BLOCKS", "IGNORED", "INT"},
{"BLOCKS", "TRANSACTIONS_COUNT", "INT"},
{"BLOCKS", "LAST_NUMBER", "BIGINT"},
{"BLOCKS", "FIRST_HASH", "STRING"},
{"BLOCKS", "LAST_HASH", "STRING"},
{"INSERT", "TIME", "DURATION"},
},
}
var mlogBlockchainReorgBlocks = logger.MLogT{
Description: "Called when a chain split is detected and a subset of blocks are reoganized.",
Receiver: "BLOCKCHAIN",
Verb: "REORG",
Subject: "BLOCKS",
Details: []logger.MLogDetailT{
{"REORG", "LAST_COMMON_HASH", "STRING"},
{"REORG", "SPLIT_NUMBER", "BIGINT"},
{"BLOCKS", "OLD_START_HASH", "STRING"},
{"BLOCKS", "NEW_START_HASH", "STRING"},
},
}
var mlogTxPoolAddTx = logger.MLogT{
Description: `Called once when a valid transaction is added to tx pool.
$TO.NAME will be the account address hex or '[NEW_CONTRACT]' in case of a contract.`,
Receiver: "TXPOOL",
Verb: "ADD",
Subject: "TX",
Details: []logger.MLogDetailT{
{"TX", "FROM", "STRING"},
{"TX", "TO", "STRING"},
{"TX", "VALUE", "BIGINT"},
{"TX", "HASH", "STRING"},
},
}
var mlogTxPoolValidateTx = logger.MLogT{
Description: `Called once when validating a single transaction.
If transaction is invalid, TX.ERROR will be non-nil, otherwise it will be nil.`,
Receiver: "TXPOOL",
Verb: "VALIDATE",
Subject: "TX",
Details: []logger.MLogDetailT{
{"TX", "HASH", "STRING"},
{"TX", "ERROR", "STRING_OR_NULL"},
},
}