-
Notifications
You must be signed in to change notification settings - Fork 29
/
entity.go
44 lines (37 loc) · 973 Bytes
/
entity.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
package chain
import (
"github.com/0chain/gosdk/zmagmacore/time"
)
// Chain represents data structure that holds the chain data.
type Chain struct {
ID string
Version string
CreationDate time.Timestamp
OwnerID string
BlockWorker string
}
// serverChain is the chain object of the chain the server is responsible for.
var serverChain = new(Chain)
// SetServerChain sets the server chain object to package variable serverChain.
func SetServerChain(c *Chain) {
serverChain = c
}
// GetServerChain returns the chain object for the server chain.
func GetServerChain() *Chain {
return serverChain
}
// NewChain creates a new Chain.
func NewChain(id, OwnerID, blockWorker string) *Chain {
chain := Provider()
chain.ID = id
chain.OwnerID = OwnerID
chain.BlockWorker = blockWorker
return chain
}
// Provider returns entity for chain object.
func Provider() *Chain {
c := &Chain{}
c.Version = "1.0"
c.CreationDate = time.Now()
return c
}