MCPcopy Create free account
hub / github.com/CPChain/chain / OffsetTime

Method OffsetTime

core/chain_makers.go:148–153  ·  view source on GitHub ↗

OffsetTime modifies the time instance of a block, implicitly changing its associated difficulty. It's useful to test scenarios where forking is not tied to chain length directly.

(milliseconds int64)

Source from the content-addressed store, hash-verified

146// associated difficulty. It's useful to test scenarios where forking is not
147// tied to chain length directly.
148func (b *BlockGen) OffsetTime(milliseconds int64) {
149 b.header.Time.Add(b.header.Time, new(big.Int).SetInt64(milliseconds))
150 if b.header.Time.Cmp(b.parent.Header().Time) <= 0 {
151 panic("block time out of range")
152 }
153}
154
155// GenerateChain creates a chain of n blocks. The first block's
156// parent will be the provided parent. db is used to store

Callers 4

testReorgFunction · 0.80
TestChainTxReorgsFunction · 0.80
TestReorgSideEventFunction · 0.80
AdjustTimeMethod · 0.80

Calls 3

CmpMethod · 0.80
HeaderMethod · 0.80
AddMethod · 0.65

Tested by 3

testReorgFunction · 0.64
TestChainTxReorgsFunction · 0.64
TestReorgSideEventFunction · 0.64